1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 19:07:58 +01:00

normalize foldmarkers

This commit is contained in:
Doug Kearns
2007-11-19 07:13:20 +00:00
parent c83397064e
commit 5a3d51626c
11 changed files with 96 additions and 51 deletions

View File

@@ -793,7 +793,7 @@ vimperator.Buffer = function () //{{{
relText = new RegExp(relationship, "i"); relText = new RegExp(relationship, "i");
var elems = window.content.document.getElementsByTagName("link"); var elems = window.content.document.getElementsByTagName("link");
// links have higher priority than normal <a> hrefs // links have higher priority than normal <a> hrefs
for (var i = 0; i < elems.length; i++) for (var i = 0; i < elems.length; i++)
{ {
if (relText.test(elems[i].rel)) if (relText.test(elems[i].rel))
@@ -815,7 +815,7 @@ vimperator.Buffer = function () //{{{
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB); vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
return; return;
} }
else else
{ {
// images with alt text being href // images with alt text being href
var children = elems[i].childNodes; var children = elems[i].childNodes;

View File

@@ -673,7 +673,7 @@ vimperator.Commands = function () //{{{
case "import": BrowserImport(); break; case "import": BrowserImport(); break;
case "openfile": BrowserOpenFileWindow(); break; case "openfile": BrowserOpenFileWindow(); break;
case "pageinfo": BrowserPageInfo(); break; case "pageinfo": BrowserPageInfo(); break;
case "pagesource": BrowserViewSourceOfDocument(content.document); break; case "pagesource": BrowserViewSourceOfDocument(content.document); break;
case "places": PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS); break; case "places": PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS); break;
case "preferences": openPreferences(); break; case "preferences": openPreferences(); break;
// XXX what are onEnter.. and onExit...? // XXX what are onEnter.. and onExit...?

View File

@@ -26,14 +26,18 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Completion = function () // {{{ vimperator.Completion = function () //{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// the completion substrings, used for showing the longest common match // the completion substrings, used for showing the longest common match
var substrings = []; var substrings = [];
// function uses smartcase // function uses smartcase
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ] // list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
function buildLongestCommonSubstring(list, filter) //{{{ function buildLongestCommonSubstring(list, filter)
{ {
var filtered = []; var filtered = [];
var ignorecase = false; var ignorecase = false;
@@ -72,10 +76,10 @@ vimperator.Completion = function () // {{{
} }
} }
return filtered; return filtered;
} //}}} }
// this function is case sensitive and should be documented about input and output ;) // this function is case sensitive and should be documented about input and output ;)
function buildLongestStartingSubstring(list, filter) //{{{ function buildLongestStartingSubstring(list, filter)
{ {
var filtered = []; var filtered = [];
for (var i = 0; i < list.length; i++) for (var i = 0; i < list.length; i++)
@@ -102,13 +106,17 @@ vimperator.Completion = function () // {{{
} }
} }
return filtered; return filtered;
} //}}} }
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return { return {
// returns the longest common substring // returns the longest common substring
// used for the 'longest' setting for wildmode // used for the 'longest' setting for wildmode
getLongestSubstring: function () //{{{ getLongestSubstring: function ()
{ {
if (substrings.length == 0) if (substrings.length == 0)
return ""; return "";
@@ -120,9 +128,9 @@ vimperator.Completion = function () // {{{
longest = substrings[i]; longest = substrings[i];
} }
return longest; return longest;
}, //}}} },
dialog: function (filter) //{{{ dialog: function (filter)
{ {
substrings = []; substrings = [];
var nodes = [ var nodes = [
@@ -155,14 +163,14 @@ vimperator.Completion = function () // {{{
}); });
return buildLongestCommonSubstring(mapped, filter); return buildLongestCommonSubstring(mapped, filter);
}, //}}} },
// filter a list of urls // filter a list of urls
// //
// may consist of searchengines, filenames, bookmarks and history, // may consist of searchengines, filenames, bookmarks and history,
// depending on the 'complete' option // depending on the 'complete' option
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option // if the 'complete' argument is passed like "h", it temporarily overrides the complete option
url: function (filter, complete) //{{{ url: function (filter, complete)
{ {
var completions = []; var completions = [];
substrings = []; substrings = [];
@@ -182,9 +190,9 @@ vimperator.Completion = function () // {{{
} }
return completions; return completions;
}, //}}} },
search: function (filter) //{{{ search: function (filter)
{ {
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
@@ -195,7 +203,7 @@ vimperator.Completion = function () // {{{
return [[engine[0]], engine[1]]; return [[engine[0]], engine[1]];
}); });
return buildLongestCommonSubstring(mapped, filter); return buildLongestCommonSubstring(mapped, filter);
}, //}}} },
// TODO: support file:// and \ or / path separators on both platforms // TODO: support file:// and \ or / path separators on both platforms
file: function (filter) file: function (filter)
@@ -230,7 +238,7 @@ vimperator.Completion = function () // {{{
return buildLongestStartingSubstring(mapped, filter); return buildLongestStartingSubstring(mapped, filter);
}, },
help: function (filter) //{{{ help: function (filter)
{ {
var helpArray = [[["introduction"], "Introductory text"], var helpArray = [[["introduction"], "Introductory text"],
[["initialization"], "Initialization and startup"], [["initialization"], "Initialization and startup"],
@@ -255,9 +263,9 @@ vimperator.Completion = function () // {{{
}); });
return buildLongestCommonSubstring(helpArray, filter); return buildLongestCommonSubstring(helpArray, filter);
}, //}}} },
command: function (filter) //{{{ command: function (filter)
{ {
substrings = []; substrings = [];
var completions = []; var completions = [];
@@ -271,9 +279,9 @@ vimperator.Completion = function () // {{{
for (var command in vimperator.commands) for (var command in vimperator.commands)
completions.push([command.longNames, command.shortHelp]); completions.push([command.longNames, command.shortHelp]);
return buildLongestStartingSubstring(completions, filter); return buildLongestStartingSubstring(completions, filter);
}, //}}} },
option: function (filter, unfiltered) //{{{ option: function (filter, unfiltered)
{ {
substrings = []; substrings = [];
var optionCompletions = []; var optionCompletions = [];
@@ -350,9 +358,9 @@ vimperator.Completion = function () // {{{
} }
return optionCompletions; return optionCompletions;
}, //}}} },
buffer: function (filter) //{{{ buffer: function (filter)
{ {
substrings = []; substrings = [];
var items = []; var items = [];
@@ -386,9 +394,9 @@ vimperator.Completion = function () // {{{
return [$_[0][0], $_[1]]; return [$_[0][0], $_[1]];
}); });
return buildLongestCommonSubstring(items, filter); return buildLongestCommonSubstring(items, filter);
}, //}}} },
sidebar: function (filter) //{{{ sidebar: function (filter)
{ {
substrings = []; substrings = [];
var menu = document.getElementById("viewSidebarMenu"); var menu = document.getElementById("viewSidebarMenu");
@@ -405,9 +413,9 @@ vimperator.Completion = function () // {{{
}); });
return buildLongestCommonSubstring(mapped, filter); return buildLongestCommonSubstring(mapped, filter);
}, //}}} },
javascript: function (str) // {{{ javascript: function (str)
{ {
substrings = []; substrings = [];
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/); var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
@@ -481,12 +489,12 @@ vimperator.Completion = function () // {{{
} }
return buildLongestStartingSubstring(completions, filter); return buildLongestStartingSubstring(completions, filter);
}, // }}} },
// discard all entries in the 'urls' array, which don't match 'filter // discard all entries in the 'urls' array, which don't match 'filter
// urls must be of type [["url", "title"], [...]] or optionally // urls must be of type [["url", "title"], [...]] or optionally
// [["url", "title", keyword, [tags]], [...]] // [["url", "title", keyword, [tags]], [...]]
filterURLArray: function (urls, filter, tags) //{{{ filterURLArray: function (urls, filter, tags)
{ {
var filtered = []; var filtered = [];
// completions which don't match the url but just the description // completions which don't match the url but just the description
@@ -578,7 +586,7 @@ vimperator.Completion = function () // {{{
} }
return filtered.concat(additionalCompletions); return filtered.concat(additionalCompletions);
}, //}}} },
// generic helper function which checks if the given "items" array pass "filter" // generic helper function which checks if the given "items" array pass "filter"
// items must be an array of strings // items must be an array of strings
@@ -601,7 +609,7 @@ vimperator.Completion = function () // {{{
}, },
// FIXME: rename // FIXME: rename
exTabCompletion: function (str) //{{{ exTabCompletion: function (str)
{ {
var [count, cmd, special, args] = vimperator.commands.parseCommand(str); var [count, cmd, special, args] = vimperator.commands.parseCommand(str);
var completions = []; var completions = [];
@@ -644,9 +652,10 @@ vimperator.Completion = function () // {{{
} }
} }
return [start, completions]; return [start, completions];
} //}}} }
}; };
}; // }}} //}}}
}; //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -31,6 +31,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
vimperator.Editor = function () //{{{ vimperator.Editor = function () //{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// store our last search with f, F, t or T // store our last search with f, F, t or T
var lastFindChar = null; var lastFindChar = null;
var lastFindCharFunc = null; var lastFindCharFunc = null;
@@ -50,6 +54,10 @@ vimperator.Editor = function () //{{{
return ed.controllers.getControllerForCommand("cmd_beginLine"); return ed.controllers.getControllerForCommand("cmd_beginLine");
} }
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return { return {
line: function () line: function ()
@@ -248,7 +256,7 @@ vimperator.Editor = function () //{{{
{ {
this.executeCommand("cmd_selectCharNext", 1); this.executeCommand("cmd_selectCharNext", 1);
} }
while ( editor().selectionEnd != pos ); while (editor().selectionEnd != pos);
} }
else else
{ {
@@ -259,7 +267,7 @@ vimperator.Editor = function () //{{{
{ {
this.executeCommand("cmd_selectCharPrevious", 1); this.executeCommand("cmd_selectCharPrevious", 1);
} }
while ( editor().selectionStart != pos ); while (editor().selectionStart != pos);
} }
}, },
@@ -589,8 +597,8 @@ vimperator.Editor = function () //{{{
} }
} }
vimperator.echoerr("E24: No such abbreviation"); vimperator.echoerr("E24: No such abbreviation");
return false; return false;
}, },
removeAllAbbreviations: function (filter) removeAllAbbreviations: function (filter)
@@ -640,9 +648,10 @@ vimperator.Editor = function () //{{{
} }
} }
return true; return true;
} //}}} }
//}}}
}; };
//}}}
}; //}}} }; //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -186,7 +186,7 @@ vimperator.Events = function () //{{{
var tagname = elt.localName.toLowerCase(); var tagname = elt.localName.toLowerCase();
var type = elt.type.toLowerCase(); var type = elt.type.toLowerCase();
if ( (tagname == "input" && (type != "image")) || if ((tagname == "input" && (type != "image")) ||
tagname == "textarea" || tagname == "textarea" ||
// tagName == "SELECT" || // tagName == "SELECT" ||
// tagName == "BUTTON" || // tagName == "BUTTON" ||

View File

@@ -39,6 +39,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
// make sure you only create this object when the "vimperator" object is ready // make sure you only create this object when the "vimperator" object is ready
vimperator.Search = function () //{{{ vimperator.Search = function () //{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// FIXME: // FIXME:
//var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback //var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
var found = false; // true if the last search was successful var found = false; // true if the last search was successful
@@ -105,6 +109,10 @@ vimperator.Search = function () //{{{
searchString = pattern; searchString = pattern;
} }
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return { return {
// Called when the search dialog is asked for // Called when the search dialog is asked for
@@ -260,6 +268,7 @@ vimperator.Search = function () //{{{
} }
}; };
//}}}
}; //}}} }; //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -41,8 +41,8 @@ vimperator.Hints = function () //{{{
var hints = []; var hints = [];
var validHints = []; // store the indices of the "hints" array with valid elements var validHints = []; // store the indices of the "hints" array with valid elements
var escapeNumbers = false ; // escape mode for numbers. true -> treated as hint-text var escapeNumbers = false; // escape mode for numbers. true -> treated as hint-text
var activeTimeout = null; // needed for hinttimeout > 0 var activeTimeout = null; // needed for hinttimeout > 0
var canUpdate = false; var canUpdate = false;
// keep track of the documents which we generated the hints for // keep track of the documents which we generated the hints for
@@ -69,7 +69,7 @@ vimperator.Hints = function () //{{{
function updateStatusline() function updateStatusline()
{ {
vimperator.statusline.updateInputBuffer((escapeNumbers ? "\\ ": "" ) + // sign for escapeNumbers vimperator.statusline.updateInputBuffer((escapeNumbers ? "\\ ": "") + // sign for escapeNumbers
(hintString ? "\"" + hintString + "\"" : "") + (hintString ? "\"" + hintString + "\"" : "") +
(hintNumber > 0 ? " <" + hintNumber + ">" : "")); (hintNumber > 0 ? " <" + hintNumber + ">" : ""));
} }

View File

@@ -27,11 +27,19 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.IO = function () vimperator.IO = function ()//{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
var environmentService = Components.classes["@mozilla.org/process/environment;1"] var environmentService = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment); .getService(Components.interfaces.nsIEnvironment);
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return { return {
MODE_RDONLY: 0x01, MODE_RDONLY: 0x01,
@@ -235,6 +243,7 @@ vimperator.IO = function ()
ofstream.close(); ofstream.close();
} }
}; };
}; //}}}
};//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -26,8 +26,12 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.modes = (function () vimperator.modes = (function ()//{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
var main = 1; // NORMAL var main = 1; // NORMAL
var extended = 0; // NONE var extended = 0; // NONE
@@ -123,6 +127,10 @@ vimperator.modes = (function ()
} }
} }
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return { return {
// main modes, only one should ever be active // main modes, only one should ever be active
@@ -224,6 +232,7 @@ vimperator.modes = (function ()
} }
}; };
})(); //}}}
})();//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.util = { vimperator.util = { //{{{
escapeHTML: function (str) escapeHTML: function (str)
{ {
@@ -208,6 +208,6 @@ vimperator.util = {
return strNum[0] + " " + unitVal[unitIndex]; return strNum[0] + " " + unitVal[unitIndex];
} }
}; };//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -627,8 +627,8 @@ const vimperator = (function () //{{{
vimperator.globalVariables = {}; vimperator.globalVariables = {};
// TODO: move elsewhere // TODO: move elsewhere
vimperator.registerCallback("submit", vimperator.modes.EX, function (command) { vimperator.execute(command); } ); vimperator.registerCallback("submit", vimperator.modes.EX, function (command) { vimperator.execute(command); });
vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); } ); vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); });
// first time intro message // first time intro message
if (vimperator.options.getPref("firsttime", true)) if (vimperator.options.getPref("firsttime", true))