diff --git a/content/buffers.js b/content/buffers.js index 329115dc..c3f85bb4 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -260,7 +260,7 @@ vimperator.Buffer = function () //{{{ } else { - var items = vimperator.completion.getBufferCompletions(""); + var items = vimperator.completion.buffer(""); vimperator.bufferwindow.show(items); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); } @@ -268,7 +268,7 @@ vimperator.Buffer = function () //{{{ else { // TODO: move this to vimperator.buffers.get() - var items = vimperator.completion.getBufferCompletions(""); + var items = vimperator.completion.buffer(""); var number, indicator, title, url; var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + ""; @@ -451,7 +451,7 @@ vimperator.Buffer = function () //{{{ if (!vimperator.bufferwindow.visible()) return false; - var items = vimperator.completion.getBufferCompletions(""); + var items = vimperator.completion.buffer(""); vimperator.bufferwindow.show(items); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); }, @@ -784,7 +784,7 @@ vimperator.Buffer = function () //{{{ regexps = vimperator.options["nextpattern"].split(","); break; case "previous": - //TODO: accept prev\%[ious] + // TODO: accept prev\%[ious] regexps = vimperator.options["previouspattern"].split(","); break; default: diff --git a/content/commands.js b/content/commands.js index 9bdbfa7f..32c985d1 100644 --- a/content/commands.js +++ b/content/commands.js @@ -653,7 +653,7 @@ vimperator.Commands = function () //{{{ "it is selected. With [!] the next buffer matching the argument " + "is selected, even if it cannot be identified uniquely.
" + "Use b 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]"], @@ -988,7 +988,7 @@ vimperator.Commands = function () //{{{ "
  • :help o for mappings (no pre- or postfix)
  • " + "" + "You can however use partial stings in the tab completion, so :help he<Tab> completes :help :help.", - completer: function (filter) { return vimperator.completion.getHelpCompletions(filter); } + completer: function (filter) { return vimperator.completion.help(filter); } } )); commandManager.add(new vimperator.Command(["hist[ory]", "hs"], @@ -1496,7 +1496,7 @@ vimperator.Commands = function () //{{{ "The items which are completed on <Tab> are specified in the 'complete' option.
    " + "Without argument, reloads the current page.
    " + "Without argument but with !, 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]"], @@ -1856,7 +1856,7 @@ vimperator.Commands = function () //{{{ ":set option+={value}, :set option^={value} and :set option-={value} " + "adds/multiplies/subtracts {value} from a number option and appends/prepends/removes {value} from a string option.
    " + ":set all shows the current value of all options and :set all& resets all options to their default values.
    ", - completer: function (filter) { return vimperator.completion.getOptionCompletions(filter); } + completer: function (filter) { return vimperator.completion.option(filter); } } )); // TODO: sclose instead? @@ -1910,7 +1910,7 @@ vimperator.Commands = function () //{{{ shortHelp: "Open the sidebar window", help: "{name} 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.", - completer: function (filter) { return vimperator.completion.getSidebarCompletions(filter); } + completer: function (filter) { return vimperator.completion.sidebar(filter); } } )); 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.
    " + "~ is supported as a shortcut for the $HOME directory.
    " + "If ! 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]"], @@ -1955,7 +1955,7 @@ vimperator.Commands = function () //{{{ help: "Works only for commands that support it, currently:" + "", - completer: function (filter) { return vimperator.completion.getCommandCompletions(filter); } + completer: function (filter) { return vimperator.completion.command(filter); } } )); commandManager.add(new vimperator.Command(["tabl[ast]"], @@ -2023,7 +2023,7 @@ vimperator.Commands = function () //{{{ shortHelp: "Open one or more URLs in a new tab", help: "Like :open but open URLs in a new tab.
    " + "If used with !, the 'tabopen' value of the 'activate' 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]"], diff --git a/content/completion.js b/content/completion.js index f894e15f..eaa8815e 100644 --- a/content/completion.js +++ b/content/completion.js @@ -28,7 +28,7 @@ the terms of any one of the MPL, the GPL or the LGPL. 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 = []; // function uses smartcase @@ -74,7 +74,7 @@ vimperator.Completion = function () // {{{ 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) //{{{ { var filtered = []; @@ -105,10 +105,9 @@ vimperator.Completion = function () // {{{ } //}}} return { - /* - * returns the longest common substring - * used for the 'longest' setting for wildmode - */ + + // returns the longest common substring + // used for the 'longest' setting for wildmode getLongestSubstring: function () //{{{ { if (substrings.length == 0) @@ -158,14 +157,12 @@ 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 - */ - getUrlCompletions: function (filter, complete) //{{{ + // 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) //{{{ { var completions = []; substrings = []; @@ -175,19 +172,19 @@ vimperator.Completion = function () // {{{ for (var i = 0; i < cpt.length; i++) { if (cpt[i] == "s") - completions = completions.concat(this.getSearchCompletions(filter)); + completions = completions.concat(this.search(filter)); else if (cpt[i] == "b") completions = completions.concat(vimperator.bookmarks.get(filter)); else if (cpt[i] == "h") completions = completions.concat(vimperator.history.get(filter)); else if (cpt[i] == "f") - completions = completions.concat(this.getFileCompletions(filter, true)); + completions = completions.concat(this.file(filter, true)); } return completions; }, //}}} - getSearchCompletions: function (filter) //{{{ + search: function (filter) //{{{ { 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 - getFileCompletions: function (filter) + file: function (filter) { // this is now also used as part of the url completion, so the // substrings shouldn't be cleared for that case @@ -233,7 +230,7 @@ vimperator.Completion = function () // {{{ return buildLongestStartingSubstring(mapped, filter); }, - getHelpCompletions: function (filter) //{{{ + help: function (filter) //{{{ { var helpArray = [[["introduction"], "Introductory text"], [["initialization"], "Initialization and startup"], @@ -243,7 +240,7 @@ vimperator.Completion = function () // {{{ substrings = []; for (var command in vimperator.commands) 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 ($_) { return [ $_[0].map(function ($_) { return "'" + $_ + "'"; }), @@ -260,7 +257,7 @@ vimperator.Completion = function () // {{{ return buildLongestCommonSubstring(helpArray, filter); }, //}}} - getCommandCompletions: function (filter) //{{{ + command: function (filter) //{{{ { substrings = []; var completions = []; @@ -276,7 +273,7 @@ vimperator.Completion = function () // {{{ return buildLongestStartingSubstring(completions, filter); }, //}}} - getOptionCompletions: function (filter, unfiltered) //{{{ + option: function (filter, unfiltered) //{{{ { substrings = []; var optionCompletions = []; @@ -355,7 +352,7 @@ vimperator.Completion = function () // {{{ return optionCompletions; }, //}}} - getBufferCompletions: function (filter) //{{{ + buffer: function (filter) //{{{ { substrings = []; var items = []; @@ -391,7 +388,7 @@ vimperator.Completion = function () // {{{ return buildLongestCommonSubstring(items, filter); }, //}}} - getSidebarCompletions: function (filter) //{{{ + sidebar: function (filter) //{{{ { substrings = []; var menu = document.getElementById("viewSidebarMenu"); @@ -517,11 +514,9 @@ vimperator.Completion = function () // {{{ tags = tags.map(function (t) { return t.toLowerCase(); }); } - /* - * Longest Common Subsequence - * This shouldn't use buildLongestCommonSubstring - * for performance reasons, so as not to cycle through the urls twice - */ + // Longest Common Subsequence + // This shouldn't use buildLongestCommonSubstring + // for performance reasons, so as not to cycle through the urls twice outer: for (var i = 0; i < urls.length; i++) { @@ -605,6 +600,7 @@ vimperator.Completion = function () // {{{ return false; }, + // FIXME: rename exTabCompletion: function (str) //{{{ { var [count, cmd, special, args] = vimperator.commands.parseCommand(str); @@ -616,7 +612,7 @@ vimperator.Completion = function () // {{{ var matches = str.match(/^(:*\d*)\w*$/); if (matches) { - completions = this.getCommandCompletions(cmd); + completions = this.command(cmd); start = matches[1].length; } else // dynamically get completions as specified with the command's completer function