diff --git a/common/content/buffer.js b/common/content/buffer.js index 688ba8da..e4b7450e 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -156,7 +156,7 @@ function Buffer() //{{{ options.add(["pageinfo", "pa"], "Desired info on :pa[geinfo]", "charlist", "gfm", { - completer: function (filter) [[k, v[1]] for ([k, v] in Iterator(pageInfo))], + completer: function (context) [[k, v[1]] for ([k, v] in Iterator(pageInfo))], validator: Option.validateCompleter }); @@ -169,7 +169,7 @@ function Buffer() //{{{ "Show the destination of the link under the cursor in the status bar", "number", 1, { - completer: function (filter) [ + completer: function (context) [ ["0", "Don't show link destination"], ["1", "Show the link in the status line"], ["2", "Show the link in the command line"] @@ -355,8 +355,7 @@ function Buffer() //{{{ function () { liberator.open(util.readFromClipboard(), - /\bpaste\b/.test(options["activate"]) ? - liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB); + liberator[options.get("activate").has("paste") ? "NEW_BACKGROUND_TAB" : "NEW_TAB"]); }); mappings.add(myModes, ["p", ""], diff --git a/common/content/hints.js b/common/content/hints.js index 7ca6801b..ee8c0c9a 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -73,10 +73,10 @@ function Hints() //{{{ t: Mode("Follow hint in a new tab", function (elem) buffer.followLink(elem, liberator.NEW_TAB)), b: Mode("Follow hint in a background tab", function (elem) buffer.followLink(elem, liberator.NEW_BACKGROUND_TAB)), w: Mode("Follow hint in a new window", function (elem) buffer.followLink(elem, liberator.NEW_WINDOW), extended), - F: Mode("Follow hint sequence in tabs", hintSequenceElement), - O: Mode("Preselect hint in an :open query", function (elem, loc) commandline.open(":", "open " + loc, modes.EX)), - T: Mode("Preselect hint in a :tabopen query", function (elem, loc) commandline.open(":", "tabopen " + loc, modes.EX)), - W: Mode("Preselect hint in a :winopen query", function (elem, loc) commandline.open(":", "winopen " + loc, modes.EX)), + F: Mode("Open multiple hints in tabs", hintAction_F), + O: Mode(":open URL based on hint location", function (elem, loc) commandline.open(":", "open " + loc, modes.EX)), + T: Mode(":tabopen URL based on hint location", function (elem, loc) commandline.open(":", "tabopen " + loc, modes.EX)), + W: Mode(":winopen URL based on hint location", function (elem, loc) commandline.open(":", "winopen " + loc, modes.EX)), v: Mode("View hint source", function (elem, loc) buffer.viewSource(loc, false), extended), V: Mode("View hint source in external editor", function (elem, loc) buffer.viewSource(loc, true), extended), y: Mode("Yank hint location", function (elem, loc) util.copyToClipboard(loc, true)), @@ -84,12 +84,11 @@ function Hints() //{{{ }; // Used to open multiple hints - function hintSequenceElement(elem) + function hintAction_F(elem) { buffer.followLink(elem, liberator.NEW_BACKGROUND_TAB); - // Move to next element in sequence - // TODO: Maybe we find a *simple* way to keep the hints displayed rather than + // TODO: Maybe we find a *simple* way to keep the hints displayed rather than // showing them again, or is this short flash actually needed as a "usability // feature"? --mst hints.show("F"); @@ -574,10 +573,12 @@ function Hints() //{{{ "How links are matched", "string", "contains", { - completer: function (filter) - { - return [[m, ""] for each (m in ["contains", "wordstartswith", "firstletters", "custom"])]; - }, + completer: function (context) [ + ["contains", "The typed characters are split on whitespace. The resulting groups must all appear in the hint."], + ["wordstartswith", "The typed characters are split on whitespace. The resulting groups must all match the beginings of words, in order."], + ["firstletters", "Behaves like wordstartswith, but all groups much match a sequence of words."], + ["custom", "Delegate to a custom function: liberator.plugins.customHintMatcher(hintString)"], + ], validator: Option.validateCompleter }); @@ -605,7 +606,7 @@ function Hints() //{{{ // does. --tpp mappings.add(myModes, ["F"], "Start QuickHint mode, but open link in a new tab", - function () { options.getPref("browser.tabs.loadInBackground") ? hints.show("b") : hints.show("t"); }); + function () { hints.show(options.getPref("browser.tabs.loadInBackground") ? "b" : "t"); }); mappings.add(myModes, [";"], "Start an extended hint mode", diff --git a/common/content/liberator.js b/common/content/liberator.js index 4478c61d..d6a1b8c8 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -153,7 +153,7 @@ const liberator = (function () //{{{ group.setter(value); return value; }, - completer: function (filter) + completer: function (context) { let opts = [v.opts for ([k, v] in Iterator(groups))]; opts = opts.map(function (opt) [[k, v[0]] for ([k, v] in Iterator(opt))]); diff --git a/common/content/tabs.js b/common/content/tabs.js index 0fcefb70..ee4c1b85 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -140,14 +140,11 @@ function Tabs() //{{{ return value; }, - completer: function (filter) - { - return [ - ["0", "Never show tab bar"], - ["1", "Show tab bar only if more than one tab is open"], - ["2", "Always show tab bar"] - ]; - }, + completer: function (context) [ + ["0", "Never show tab bar"], + ["1", "Show tab bar only if more than one tab is open"], + ["2", "Always show tab bar"] + ], validator: Option.validateCompleter }); @@ -157,15 +154,12 @@ function Tabs() //{{{ "Define when tabs are automatically activated", "stringlist", "homepage,quickmark,tabopen,paste", { - completer: function (filter) - { - return [ - ["homepage", "gH mapping"], - ["quickmark", "go and gn mappings"], - ["tabopen", ":tabopen[!] command"], - ["paste", "P and gP mappings"] - ]; - }, + completer: function (context) [ + ["homepage", "gH mapping"], + ["quickmark", "go and gn mappings"], + ["tabopen", ":tabopen[!] command"], + ["paste", "P and gP mappings"] + ], validator: Option.validateCompleter }); @@ -173,17 +167,14 @@ function Tabs() //{{{ "Define which commands should output in a new tab by default", "stringlist", "", { - completer: function (filter) - { - return [ - ["all", "All commands"], - ["addons", ":addo[ns] command"], - ["downloads", ":downl[oads] command"], - ["help", ":h[elp] command"], - ["javascript", ":javascript! or :js! command"], - ["prefs", ":pref[erences]! or :prefs! command"] - ]; - }, + completer: function (context) [ + ["all", "All commands"], + ["addons", ":addo[ns] command"], + ["downloads", ":downl[oads] command"], + ["help", ":h[elp] command"], + ["javascript", ":javascript! or :js! command"], + ["prefs", ":pref[erences]! or :prefs! command"] + ], validator: Option.validateCompleter }); @@ -204,16 +195,13 @@ function Tabs() //{{{ return value; }, - completer: function (filter) - { - return [ - ["0", "Force to open in the current tab"], - ["1", "Always open in a new tab"], - ["2", "Open in a new window if it has a specific requested size (default in Firefox)"], - ["3", "Always open in a new window"], - ["4", "Open in the same tab unless it has a specific requested size"] - ]; - }, + completer: function (context) [ + ["0", "Force to open in the current tab"], + ["1", "Always open in a new tab"], + ["2", "Open in a new window if it has a specific requested size (default in Firefox)"], + ["3", "Always open in a new window"], + ["4", "Open in the same tab unless it has a specific requested size"] + ], validator: Option.validateCompleter }); let fragment = liberator.has("MacUnix") ? "tab-mac" : "tab"; diff --git a/common/content/ui.js b/common/content/ui.js index f67f89a5..12e34a68 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -122,10 +122,11 @@ function CommandLine() //{{{ }, /** - * move up or (if backward) down in the history + * Move forward or backward in history. * - * @param {boolean} backward - * @param {boolean} matchCurrent XXX: what? + * @param {boolean} backward Direction to move. + * @param {boolean} matchCurrent Search for matches starting + * with the current input value. */ select: function (backward, matchCurrent) { @@ -590,7 +591,7 @@ function CommandLine() //{{{ var multilineCallback = null; /** - * @private - highlight the messageBox according to group + * Highlight the messageBox according to group. */ function setHighlightGroup(group) { @@ -598,7 +599,7 @@ function CommandLine() //{{{ } /** - * @private - Determines whether the command line should be visible. + * Determines whether the command line should be visible. * * @return {boolean} */ @@ -606,7 +607,7 @@ function CommandLine() //{{{ !(modes.extended & (modes.INPUT_MULTILINE | modes.OUTPUT_MULTILINE)); /** - * @private - set the prompt to val styled with highlightGroup + * Set the command-line prompt. * * @param {string} val * @param {string} highlightGroup @@ -620,7 +621,8 @@ function CommandLine() //{{{ } /** - * @private - set the command to cmd and move the user's cursor to the end. + * Set the command-line input value. The caret is reset to the + * end of the line. * * @param {string} cmd */ @@ -632,12 +634,12 @@ function CommandLine() //{{{ } /** - * @private - display a message styled with highlightGroup - * and, if forceSingle is true, ensure it takes only one line. + * Display a message in the command-line area. * * @param {string} str * @param {string} highlightGroup - * @param {boolean} forceSingle + * @param {boolean} forceSingle If provided, don't let over-long + * messages move to the MOW. */ function echoLine(str, highlightGroup, forceSingle) { @@ -655,13 +657,12 @@ function CommandLine() //{{{ } /** - * Display a multiline message, possible through a "more" like interface - * - * TODO: resize upon a window resize + * Display a multiline message. * * @param {string} str * @param {string} highlightGroup */ + // TODO: resize upon a window resize function echoMultiline(str, highlightGroup) { let doc = multilineOutputWidget.contentDocument; @@ -707,7 +708,7 @@ function CommandLine() //{{{ } /** - * @private - ensure that the Multiline input widget is the + * Ensure that the Multiline input widget is the * correct size. */ function autosizeMultilineInputWidget() @@ -718,14 +719,12 @@ function CommandLine() //{{{ } /** - * @private - eval()s a javascript expression - * and returns a string suitable to be echo'd. - * - * If useColor is true, util.objectToString will - * colorize object output. + * eval() a JavaScript expression and return a string suitable + * to be echoed. * * @param {string} arg - * @param {boolean} useColor + * @param {boolean} useColor When true, the result is a + * highlighted XML object. */ function echoArgumentToString(arg, useColor) { @@ -793,7 +792,7 @@ function CommandLine() //{{{ "Items which are completed at the :[tab]open prompt", "charlist", "sfl", { - completer: function completer(filter) [k for each (k in completion.urlCompleters)], + completer: function (context) [k for each (k in completion.urlCompleters)], validator: Option.validateCompleter }); @@ -832,18 +831,15 @@ function CommandLine() //{{{ "Define how command line completion works", "stringlist", "list:full", { - completer: function completer(filter) - { - return [ - // Why do we need ""? - ["", "Complete only the first match"], - ["full", "Complete the next full match"], - ["longest", "Complete to longest common string"], - ["list", "If more than one match, list all matches"], - ["list:full", "List all and complete first match"], - ["list:longest", "List all and complete common string"] - ]; - }, + completer: function (context) [ + // Why do we need ""? + ["", "Complete only the first match"], + ["full", "Complete the next full match"], + ["longest", "Complete to longest common string"], + ["list", "If more than one match, list all matches"], + ["list:full", "List all and complete first match"], + ["list:longest", "List all and complete common string"] + ], validator: Option.validateCompleter, checkHas: function (value, val) { @@ -995,9 +991,6 @@ function CommandLine() //{{{ storage.styles.removeSheet(true, "silent-mode"); }, - /** - * XXX: This function is not used! - */ runSilently: function (fn, self) { let wasSilent = this.silent; @@ -1026,14 +1019,14 @@ function CommandLine() //{{{ get message() messageBox.value, /** - * Changes the command line to display the following prompt (usually ":") - * followed by the command, in the given mode. Valid modes are - * attributes of the "modes" variable, and modes.EX is probably - * a good choice. + * Open the command line. The main mode is set to + * COMMAND_LINE, the extended mode to extendedMode. + * Further, callbacks defined for extendedMode are + * triggered as appropriate (see {@link Liberator#registerCallback}). * * @param {string} prompt * @param {string} cmd - * @param {number} mode + * @param {number} extendedMode */ open: function open(prompt, cmd, extendedMode) { @@ -1060,9 +1053,10 @@ function CommandLine() //{{{ }, /** - * Removes any input from the command line, without executing its - * contents. Removes any "More" windows or other such output. - * Pressing in EX mode normally has this effect. + * Closes the command line. This is ordinarilly triggered + * automatically by a mode change. Will not hide the command + * line immediately if called directly after a successful + * command, otherwise it will. */ close: function close() { @@ -1099,7 +1093,8 @@ function CommandLine() //{{{ /** - * Hide any auto-completion/More-ing that is happening. + * Hides the command line, and shows any status messages that + * are under it. */ hide: function hide() { @@ -1107,19 +1102,24 @@ function CommandLine() //{{{ }, /** - * Output the given string onto the command line coloured - * using the rules according to highlightGroup. If not - * given higlightGroup defaults to commandline.HL_NORMAL - * and other possibe values are at commandline.HL_[A-Z]*. - * - * Flags can be any of: - * commandline.APPEND_TO_MESSAGES (causes message to be added to the messagesHistory) - * commandline.FORCE_SINGLELINE | commandline.DISALLOW_MULTILINE - * commandline.FORCE_MULTILINE + * Output the given string onto the command line. With no + * flags, the message will be shown in the status line if it's + * short enough to fit, and contains no new lines, and isn't + * XML. Otherwise, it will be shown in the MOW. * * @param {string} str - * @param {string} highlightGroup - * @param {number} flags + * @param {string} highlightGroup The Highlight group for the + * message. @default "Normal" + * @param {number} flags Changes the bahavior as follows: + * commandline.APPEND_TO_MESSAGES - Causes message to be added to the messages + * history, and shown by :messages. + * commandline.FORCE_SINGLELINE - Forbids the command from + * being pushed to the MOW if it's too long or of + * there are already status messages being shown. + * commandline.DISALLOW_MULTILINE - Cancels the operation if + * the MOW is already visible. + * commandline.FORCE_MULTILINE - Forces the message to + * appear in the MOW. */ echo: function echo(str, highlightGroup, flags) { @@ -1169,21 +1169,15 @@ function CommandLine() //{{{ }, /** - * Prompt the user for a string and execute the given - * callback with that as the only argument on - * extra can have any of the following attributes: + * Prompt the user. Sets modes.main to COMMAND_LINE, which the + * user may pop at any time to close the prompt. * - * onChange: A function to be called with the current input every time it changes - * completer: A function called with a ?context? when the user tries to tabcomplete - * promptHighlight: The HighlightGroup to use (default commandline.HL_QUESTION, others - * can be found at commandline.HL_[A-Z]*) - * - * This function sets the mode to modes.COMMAND_LINE, and thus popping the mode will - * stop further input from being waited for (useful for stopping onChange) - * - * @param {string} prompt + * @param {string} prompt The input prompt to use. * @param {function(string)} callback - * @param {Object} extra + * @param {object} extra + * @... {function} onChange - A function to be called with the current input every time it changes + * @... {function(CompletionContext)} completer - A completion function for the user's input. + * @... {string} promptHighlight - The HighlightGroup used for the prompt. @default "Question" */ input: function input(prompt, callback, extra) { @@ -1212,6 +1206,7 @@ function CommandLine() //{{{ * @param {RegExp} untilRegexp * @param {function(string)} callbackFunc */ + // FIXME: Buggy, especially when pasting. Shouldn't use a RegExp. inputMultiline: function inputMultiline(untilRegexp, callbackFunc) { // Kludge. @@ -1232,11 +1227,13 @@ function CommandLine() //{{{ }, /** - * Handle events, the come from liberator when liberator.mode = modes.COMMAND_LINE - * but also takes blur/focus/input events raw from #liberator-commandline-command - * in the XUL + * Handles all command line events. All key events are passed + * here when COMMAND_LINE mode is active, as well as all + * input, keyup, focus, and blur events sent to the + * command-line XUL element. * * @param {Event} event + * @private */ onEvent: function onEvent(event) { @@ -1970,14 +1967,11 @@ function StatusLine() //{{{ return value; }, - completer: function completer(filter) - { - return [ - ["0", "Never display status line"], - ["1", "Display status line only if there are multiple windows"], - ["2", "Always display status line"] - ]; - }, + completer: function completer(context) [ + ["0", "Never display status line"], + ["1", "Display status line only if there are multiple windows"], + ["2", "Always display status line"] + ], validator: Option.validateCompleter }); diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index 7e89fe7d..45b7a70b 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -792,9 +792,9 @@ function History() //{{{ function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); }, { bang: true, - completer: function (context) { context.quote = null, completion.history(context); }, - options: [[["-max", "-m"], options.OPTION_INT]] + completer: function (context) { context.quote = null; completion.history(context); }, // completer: function (filter) completion.history(filter) + options: [[["-max", "-m"], options.OPTION_INT]] }); /////////////////////////////////////////////////////////////////////////////}}} diff --git a/vimperator/locale/en-US/browsing.txt b/vimperator/locale/en-US/browsing.txt index aebc802a..ff373878 100644 --- a/vimperator/locale/en-US/browsing.txt +++ b/vimperator/locale/en-US/browsing.txt @@ -40,21 +40,21 @@ The first URL is opened in the current tab, and all other URLs are opened in new tabs. Each token is analyzed and in this order: -. Opened as a local file if it is an existing relative or absolute filename. - * [c]:open /etc/fstab[c] shows the file system table. - * [c]:open ../other/foo.html[c] in your home directory opens - [a]/home/other/foo.html[a] -. Opened with the specified search engine if the token looks like a search - string and the first word is the name of a search engine ([c]:open wikipedia - linus torvalds[c] opens the Wikipedia entry for linus torvalds). The short - name of a search engine is automatically guessed from its name. If you want - to set a custom name, you can change it with [c]:dialog searchengines[c]. -. Opened with the default search engine or keyword (specified with the - 'defsearch' option) if the first word is no search engine ([c]:open linus - torvalds[c] opens a Google search for linux torvalds). -. Passed directly to Firefox in all other cases ([c]:open www.osnews.com, - www.slashdot.org[c] opens OSNews in the current, and Slashdot in a new - background tab). +1. Opened as a local file if it is an existing relative or absolute filename. + - [c]:open /etc/fstab[c] shows the file system table. + - [c]:open ../other/foo.html[c] in your home directory opens + [a]/home/other/foo.html[a] +2. Opened with the specified search engine if the token looks like a search + string and the first word is the name of a search engine ([c]:open wikipedia + linus torvalds[c] opens the Wikipedia entry for linus torvalds). The short + name of a search engine is automatically guessed from its name. If you want + to set a custom name, you can change it with [c]:dialog searchengines[c]. +3. Opened with the default search engine or keyword (specified with the + 'defsearch' option) if the first word is no search engine ([c]:open linus + torvalds[c] opens a Google search for linux torvalds). +4. Passed directly to Firefox in all other cases ([c]:open www.osnews.com, + www.slashdot.org[c] opens OSNews in the current, and Slashdot in a new + background tab). You can use [c]:open -tags linux torvalds[c] to complete bookmarks with tag "linux" and which contain "torvalds". Note that -tags support is only diff --git a/vimperator/locale/en-US/hints.txt b/vimperator/locale/en-US/hints.txt index 21796974..d4bc1059 100644 --- a/vimperator/locale/en-US/hints.txt +++ b/vimperator/locale/en-US/hints.txt @@ -51,9 +51,9 @@ this hint mode. Then press [a]24[a] to copy the hint location. * |;b| [m]b[m] to open its location in a new background tab * |;w| [m]w[m] to open its destination in a new window * |;F| [m]F[m] to follow a sequence of [m][m]-delimited hints in background tabs -* |;O| [m]O[m] to preselect its location in an [c]:open[c] query -* |;T| [m]T[m] to preselect its location in a [c]:tabopen[c] query -* |;W| [m]W[m] to preselect its location in a [c]:winopen[c] query +* |;O| [m]O[m] to [c]:open[c] a URL based on hint location +* |;T| [m]T[m] to [c]:tabopen[c] a URL based on its location +* |;W| [m]W[m] to [c]:winopen[c] a URL based on its location * |;v| [m]v[m] to view its destination source * |;V| [m]V[m] to view its destination source in the external editor * |;y| [m]y[m] to yank its destination location diff --git a/vimperator/locale/en-US/starting.txt b/vimperator/locale/en-US/starting.txt index 0e6d060d..b971a2f4 100644 --- a/vimperator/locale/en-US/starting.txt +++ b/vimperator/locale/en-US/starting.txt @@ -7,27 +7,26 @@ section:Initialization[initialization,startup] At startup, Vimperator completes the following tasks in order. -. Vimperator can perform user initialization commands. When - one of the following is successfully located, it is executed, and no - further locations are tried. +1. Vimperator can perform user initialization commands. When +one of the following is successfully located, it is executed, and no +further locations are tried. +|$VIMPERATOR_INIT| - .. |$VIMPERATOR_INIT| _$VIMPERATOR_INIT_ -- May contain a single ex - command (e.g., - "[c]:source {file}[c]"). - .. [a]\~/_vimperatorrc[a] -- Windows only. If this file exists, its - contents are executed. - .. [a]\~/.vimperatorrc[a] -- If this file exists, its contents are - executed. + a. _$VIMPERATOR_INIT_ -- May contain a single ex command (e.g., + "[c]:source {file}[c]"). + b. [a]\~/_vimperatorrc[a] -- Windows only. If this file exists, its contents + are executed. + c. [a]\~/.vimperatorrc[a] -- If this file exists, its contents are executed. -. If 'exrc' is set, then any RC file in the current directory is also sourced. +2. If 'exrc' is set, then any RC file in the current directory is also sourced. -. All directories in 'runtimepath' are searched for a "plugin" - subdirectory and all yet unloaded plugins are loaded. For each - plugin directory, all *.\{js,vimp} files (including those in further - subdirectories) are sourced alphabetically. No plugins will be sourced - if 'noloadplugins' is set. Any particular plugin will not be loaded - if it has already been loaded (e.g., by an earlier [c]:loadplugins[c] - command). +3. All directories in 'runtimepath' are searched for a "plugin" +subdirectory and all yet unloaded plugins are loaded. For each plugin +directory, all *.\{js,vimp} files (including those in further +subdirectories) are sourced alphabetically. No plugins will be sourced +if 'noloadplugins' is set. Any particular plugin will not be loaded if +it has already been loaded (e.g., by an earlier [c]:loadplugins[c] +command). The user's ~ (i.e., "home") directory is determined as follows: