1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 21:27: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

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

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
vimperator.Search = function () //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// FIXME:
//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
@@ -105,6 +109,10 @@ vimperator.Search = function () //{{{
searchString = pattern;
}
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return {
// Called when the search dialog is asked for
@@ -260,6 +268,7 @@ vimperator.Search = function () //{{{
}
};
//}}}
}; //}}}
// vim: set fdm=marker sw=4 ts=4 et:

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.
}}} ***** END LICENSE BLOCK *****/
vimperator.IO = function ()
vimperator.IO = function ()//{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
var environmentService = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return {
MODE_RDONLY: 0x01,
@@ -235,6 +243,7 @@ vimperator.IO = function ()
ofstream.close();
}
};
};
//}}}
};//}}}
// 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.modes = (function ()
vimperator.modes = (function ()//{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
var main = 1; // NORMAL
var extended = 0; // NONE
@@ -123,6 +127,10 @@ vimperator.modes = (function ()
}
}
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return {
// main modes, only one should ever be active
@@ -224,6 +232,7 @@ vimperator.modes = (function ()
}
};
})();
//}}}
})();//}}}
// 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.
}}} ***** END LICENSE BLOCK *****/
vimperator.util = {
vimperator.util = { //{{{
escapeHTML: function (str)
{
@@ -208,6 +208,6 @@ vimperator.util = {
return strNum[0] + " " + unitVal[unitIndex];
}
};
};//}}}
// vim: set fdm=marker sw=4 ts=4 et: