mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 21:37:58 +01:00
normalize the completion module's method names
This commit is contained in:
@@ -260,7 +260,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var items = vimperator.completion.getBufferCompletions("");
|
var items = vimperator.completion.buffer("");
|
||||||
vimperator.bufferwindow.show(items);
|
vimperator.bufferwindow.show(items);
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: move this to vimperator.buffers.get()
|
// TODO: move this to vimperator.buffers.get()
|
||||||
var items = vimperator.completion.getBufferCompletions("");
|
var items = vimperator.completion.buffer("");
|
||||||
var number, indicator, title, url;
|
var number, indicator, title, url;
|
||||||
|
|
||||||
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" + "<table>";
|
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" + "<table>";
|
||||||
@@ -451,7 +451,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
if (!vimperator.bufferwindow.visible())
|
if (!vimperator.bufferwindow.visible())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var items = vimperator.completion.getBufferCompletions("");
|
var items = vimperator.completion.buffer("");
|
||||||
vimperator.bufferwindow.show(items);
|
vimperator.bufferwindow.show(items);
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
},
|
},
|
||||||
@@ -784,7 +784,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
regexps = vimperator.options["nextpattern"].split(",");
|
regexps = vimperator.options["nextpattern"].split(",");
|
||||||
break;
|
break;
|
||||||
case "previous":
|
case "previous":
|
||||||
//TODO: accept prev\%[ious]
|
// TODO: accept prev\%[ious]
|
||||||
regexps = vimperator.options["previouspattern"].split(",");
|
regexps = vimperator.options["previouspattern"].split(",");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
|
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
|
||||||
"is selected, even if it cannot be identified uniquely.<br/>" +
|
"is selected, even if it cannot be identified uniquely.<br/>" +
|
||||||
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
|
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
|
||||||
completer: function (filter) { return vimperator.completion.getBufferCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.buffer(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["dia[log]"],
|
commandManager.add(new vimperator.Command(["dia[log]"],
|
||||||
@@ -988,7 +988,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"<li><code class=\"command\">:help o</code> for mappings (no pre- or postfix)</li>" +
|
"<li><code class=\"command\">:help o</code> for mappings (no pre- or postfix)</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"You can however use partial stings in the tab completion, so <code class=\"command\">:help he<Tab></code> completes <code class=\"command\">:help :help</code>.",
|
"You can however use partial stings in the tab completion, so <code class=\"command\">:help he<Tab></code> completes <code class=\"command\">:help :help</code>.",
|
||||||
completer: function (filter) { return vimperator.completion.getHelpCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.help(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["hist[ory]", "hs"],
|
commandManager.add(new vimperator.Command(["hist[ory]", "hs"],
|
||||||
@@ -1496,7 +1496,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"The items which are completed on <code class=\"mapping\"><Tab></code> are specified in the <code class=\"option\">'complete'</code> option.<br/>" +
|
"The items which are completed on <code class=\"mapping\"><Tab></code> are specified in the <code class=\"option\">'complete'</code> option.<br/>" +
|
||||||
"Without argument, reloads the current page.<br/>" +
|
"Without argument, reloads the current page.<br/>" +
|
||||||
"Without argument but with <code class=\"command\">!</code>, reloads the current page skipping the cache.",
|
"Without argument but with <code class=\"command\">!</code>, reloads the current page skipping the cache.",
|
||||||
completer: function (filter) { return vimperator.completion.getUrlCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.url(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["pa[geinfo]"],
|
commandManager.add(new vimperator.Command(["pa[geinfo]"],
|
||||||
@@ -1856,7 +1856,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"<code class=\"command\">:set option+={value}</code>, <code class=\"command\">:set option^={value}</code> and <code class=\"command\">:set option-={value}</code> " +
|
"<code class=\"command\">:set option+={value}</code>, <code class=\"command\">:set option^={value}</code> and <code class=\"command\">:set option-={value}</code> " +
|
||||||
"adds/multiplies/subtracts <code class=\"argument\">{value}</code> from a number option and appends/prepends/removes <code class=\"argument\">{value}</code> from a string option.<br/>" +
|
"adds/multiplies/subtracts <code class=\"argument\">{value}</code> from a number option and appends/prepends/removes <code class=\"argument\">{value}</code> from a string option.<br/>" +
|
||||||
"<code class=\"command\">:set all</code> shows the current value of all options and <code class=\"command\">:set all&</code> resets all options to their default values.<br/>",
|
"<code class=\"command\">:set all</code> shows the current value of all options and <code class=\"command\">:set all&</code> resets all options to their default values.<br/>",
|
||||||
completer: function (filter) { return vimperator.completion.getOptionCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.option(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
// TODO: sclose instead?
|
// TODO: sclose instead?
|
||||||
@@ -1910,7 +1910,7 @@ vimperator.Commands = function () //{{{
|
|||||||
shortHelp: "Open the sidebar window",
|
shortHelp: "Open the sidebar window",
|
||||||
help: "<code class=\"argument\">{name}</code> is any of the menu items listed under the standard Firefox View->Sidebar " +
|
help: "<code class=\"argument\">{name}</code> is any of the menu items listed under the standard Firefox View->Sidebar " +
|
||||||
"menu. Add-ons, Preferences and Downloads are also available in the sidebar.",
|
"menu. Add-ons, Preferences and Downloads are also available in the sidebar.",
|
||||||
completer: function (filter) { return vimperator.completion.getSidebarCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.sidebar(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["so[urce]"],
|
commandManager.add(new vimperator.Command(["so[urce]"],
|
||||||
@@ -1937,7 +1937,7 @@ vimperator.Commands = function () //{{{
|
|||||||
"The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.<br/>" +
|
"The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.<br/>" +
|
||||||
"~ is supported as a shortcut for the <var>$HOME</var> directory.<br/>" +
|
"~ is supported as a shortcut for the <var>$HOME</var> directory.<br/>" +
|
||||||
"If <code class=\"command\">!</code> is specified, errors are not printed.",
|
"If <code class=\"command\">!</code> is specified, errors are not printed.",
|
||||||
completer: function (filter) { return vimperator.completion.getFileCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.file(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["st[op]"],
|
commandManager.add(new vimperator.Command(["st[op]"],
|
||||||
@@ -1955,7 +1955,7 @@ vimperator.Commands = function () //{{{
|
|||||||
help: "Works only for commands that support it, currently:" +
|
help: "Works only for commands that support it, currently:" +
|
||||||
"<ul><li>:tab help</li>" +
|
"<ul><li>:tab help</li>" +
|
||||||
"<li>:tab prefs[!]</li></ul>",
|
"<li>:tab prefs[!]</li></ul>",
|
||||||
completer: function (filter) { return vimperator.completion.getCommandCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.command(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["tabl[ast]"],
|
commandManager.add(new vimperator.Command(["tabl[ast]"],
|
||||||
@@ -2023,7 +2023,7 @@ vimperator.Commands = function () //{{{
|
|||||||
shortHelp: "Open one or more URLs in a new tab",
|
shortHelp: "Open one or more URLs in a new tab",
|
||||||
help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" +
|
help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" +
|
||||||
"If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.",
|
"If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.",
|
||||||
completer: function (filter) { return vimperator.completion.getUrlCompletions(filter); }
|
completer: function (filter) { return vimperator.completion.url(filter); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
commandManager.add(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
|
|
||||||
vimperator.Completion = function () // {{{
|
vimperator.Completion = function () // {{{
|
||||||
{
|
{
|
||||||
// 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
|
||||||
@@ -74,7 +74,7 @@ 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 = [];
|
||||||
@@ -105,10 +105,9 @@ vimperator.Completion = function () // {{{
|
|||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
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)
|
||||||
@@ -158,14 +157,12 @@ 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) //{{{
|
||||||
*/
|
|
||||||
getUrlCompletions: function (filter, complete) //{{{
|
|
||||||
{
|
{
|
||||||
var completions = [];
|
var completions = [];
|
||||||
substrings = [];
|
substrings = [];
|
||||||
@@ -175,19 +172,19 @@ vimperator.Completion = function () // {{{
|
|||||||
for (var i = 0; i < cpt.length; i++)
|
for (var i = 0; i < cpt.length; i++)
|
||||||
{
|
{
|
||||||
if (cpt[i] == "s")
|
if (cpt[i] == "s")
|
||||||
completions = completions.concat(this.getSearchCompletions(filter));
|
completions = completions.concat(this.search(filter));
|
||||||
else if (cpt[i] == "b")
|
else if (cpt[i] == "b")
|
||||||
completions = completions.concat(vimperator.bookmarks.get(filter));
|
completions = completions.concat(vimperator.bookmarks.get(filter));
|
||||||
else if (cpt[i] == "h")
|
else if (cpt[i] == "h")
|
||||||
completions = completions.concat(vimperator.history.get(filter));
|
completions = completions.concat(vimperator.history.get(filter));
|
||||||
else if (cpt[i] == "f")
|
else if (cpt[i] == "f")
|
||||||
completions = completions.concat(this.getFileCompletions(filter, true));
|
completions = completions.concat(this.file(filter, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return completions;
|
return completions;
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
getSearchCompletions: function (filter) //{{{
|
search: function (filter) //{{{
|
||||||
{
|
{
|
||||||
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
|
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
|
||||||
|
|
||||||
@@ -201,7 +198,7 @@ vimperator.Completion = function () // {{{
|
|||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
// TODO: support file:// and \ or / path separators on both platforms
|
// TODO: support file:// and \ or / path separators on both platforms
|
||||||
getFileCompletions: function (filter)
|
file: function (filter)
|
||||||
{
|
{
|
||||||
// this is now also used as part of the url completion, so the
|
// this is now also used as part of the url completion, so the
|
||||||
// substrings shouldn't be cleared for that case
|
// substrings shouldn't be cleared for that case
|
||||||
@@ -233,7 +230,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return buildLongestStartingSubstring(mapped, filter);
|
return buildLongestStartingSubstring(mapped, filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
getHelpCompletions: function (filter) //{{{
|
help: function (filter) //{{{
|
||||||
{
|
{
|
||||||
var helpArray = [[["introduction"], "Introductory text"],
|
var helpArray = [[["introduction"], "Introductory text"],
|
||||||
[["initialization"], "Initialization and startup"],
|
[["initialization"], "Initialization and startup"],
|
||||||
@@ -243,7 +240,7 @@ vimperator.Completion = function () // {{{
|
|||||||
substrings = [];
|
substrings = [];
|
||||||
for (var command in vimperator.commands)
|
for (var command in vimperator.commands)
|
||||||
helpArray.push([command.longNames.map(function ($_) { return ":" + $_; }), command.shortHelp]);
|
helpArray.push([command.longNames.map(function ($_) { return ":" + $_; }), command.shortHelp]);
|
||||||
options = this.getOptionCompletions(filter, true);
|
options = this.option(filter, true);
|
||||||
helpArray = helpArray.concat(options.map(function ($_) {
|
helpArray = helpArray.concat(options.map(function ($_) {
|
||||||
return [
|
return [
|
||||||
$_[0].map(function ($_) { return "'" + $_ + "'"; }),
|
$_[0].map(function ($_) { return "'" + $_ + "'"; }),
|
||||||
@@ -260,7 +257,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return buildLongestCommonSubstring(helpArray, filter);
|
return buildLongestCommonSubstring(helpArray, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
getCommandCompletions: function (filter) //{{{
|
command: function (filter) //{{{
|
||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var completions = [];
|
var completions = [];
|
||||||
@@ -276,7 +273,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return buildLongestStartingSubstring(completions, filter);
|
return buildLongestStartingSubstring(completions, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
getOptionCompletions: function (filter, unfiltered) //{{{
|
option: function (filter, unfiltered) //{{{
|
||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var optionCompletions = [];
|
var optionCompletions = [];
|
||||||
@@ -355,7 +352,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return optionCompletions;
|
return optionCompletions;
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
getBufferCompletions: function (filter) //{{{
|
buffer: function (filter) //{{{
|
||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var items = [];
|
var items = [];
|
||||||
@@ -391,7 +388,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return buildLongestCommonSubstring(items, filter);
|
return buildLongestCommonSubstring(items, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
getSidebarCompletions: function (filter) //{{{
|
sidebar: function (filter) //{{{
|
||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var menu = document.getElementById("viewSidebarMenu");
|
var menu = document.getElementById("viewSidebarMenu");
|
||||||
@@ -517,11 +514,9 @@ vimperator.Completion = function () // {{{
|
|||||||
tags = tags.map(function (t) { return t.toLowerCase(); });
|
tags = tags.map(function (t) { return t.toLowerCase(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Longest Common Subsequence
|
||||||
* Longest Common Subsequence
|
// This shouldn't use buildLongestCommonSubstring
|
||||||
* This shouldn't use buildLongestCommonSubstring
|
// for performance reasons, so as not to cycle through the urls twice
|
||||||
* for performance reasons, so as not to cycle through the urls twice
|
|
||||||
*/
|
|
||||||
outer:
|
outer:
|
||||||
for (var i = 0; i < urls.length; i++)
|
for (var i = 0; i < urls.length; i++)
|
||||||
{
|
{
|
||||||
@@ -605,6 +600,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 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);
|
||||||
@@ -616,7 +612,7 @@ vimperator.Completion = function () // {{{
|
|||||||
var matches = str.match(/^(:*\d*)\w*$/);
|
var matches = str.match(/^(:*\d*)\w*$/);
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
completions = this.getCommandCompletions(cmd);
|
completions = this.command(cmd);
|
||||||
start = matches[1].length;
|
start = matches[1].length;
|
||||||
}
|
}
|
||||||
else // dynamically get completions as specified with the command's completer function
|
else // dynamically get completions as specified with the command's completer function
|
||||||
|
|||||||
Reference in New Issue
Block a user