From ee73cd05a90b20572f7eb7b33862ee0a954c4f10 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Thu, 31 Jan 2008 22:57:59 +0000 Subject: [PATCH] biggest commit ever: cvs diff -u |wc -l -> 2491 lines; Removed all inline help --- content/commands.js | 551 +++++++++++------------------------------- content/completion.js | 33 +-- content/help.js | 280 --------------------- content/mappings.js | 384 ++++------------------------- content/options.js | 119 +-------- content/util.js | 32 ++- content/vimperator.js | 2 +- 7 files changed, 206 insertions(+), 1195 deletions(-) delete mode 100644 content/help.js diff --git a/content/commands.js b/content/commands.js index 35e9cb99..6849bb59 100644 --- a/content/commands.js +++ b/content/commands.js @@ -72,16 +72,8 @@ vimperator.Command = function (specs, action, extraInfo) //{{{ this.action = action; - // TODO: build a better default usage string - this.usage = [this.specs[0]]; - if (extraInfo) { - //var flags = extraInfo.flags || 0; - - if (extraInfo.usage) - this.usage = extraInfo.usage; - this.help = extraInfo.help || null; this.shortHelp = extraInfo.shortHelp || null; this.completer = extraInfo.completer || null; @@ -564,8 +556,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["addo[ns]"], function () { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); }, { - shortHelp: "Show available Browser Extensions and Themes", - help: "You can add/remove/disable browser extensions from this dialog.
Be aware that not all Firefox extensions work, because Vimperator overrides some key bindings and changes Firefox's GUI." + shortHelp: "Show available Browser Extensions and Themes" } )); commandManager.add(new vimperator.Command(["ba[ck]"], @@ -591,10 +582,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["[count]ba[ck][!] [url]"], shortHelp: "Go back in the browser history", - help: "Count is supported, :3back goes back 3 pages in the browser history.
" + - "The special version :back! goes to the beginning of the browser history.", completer: function (filter) { var sh = getWebNavigation().sessionHistory; @@ -614,10 +602,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"], function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); }, { - usage: ["[count]bd[elete][!]"], - shortHelp: "Delete current buffer (=tab)", - help: "Count is supported, :2bd removes two tabs and the one to the right is selected. " + - "Do :bdelete! to select the tab to the left after removing the current tab." + shortHelp: "Delete current buffer (=tab)" } )); commandManager.add(new vimperator.Command(["beep"], @@ -651,14 +636,7 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("Exxx: Could not add bookmark `" + title + "'", vimperator.commandline.FORCE_SINGLELINE); }, { - usage: ["bma[rk] [-title=title] [-keyword=kw] [-tags=tag1,tag2] [url]"], shortHelp: "Add a bookmark", - help: "If you don't add a custom title, either the title of the web page or the URL is taken as the title.
" + - "You can omit the optional [url] argument, so just do :bmark to bookmark the currently loaded web page with a default title and without any tags.
" + - "The following options are interpreted:
" + - " -title=\"custom title\"
" + - " -tags=comma,separated,tag,list
" + - " -keyword=keyword
", args: [[["-title", "-t"], OPTION_STRING], [["-tags", "-T"], OPTION_LIST], [["-keyword", "-k"], OPTION_STRING, function (arg) { return /\w/.test(arg); }]] @@ -675,12 +653,7 @@ vimperator.Commands = function () //{{{ vimperator.bookmarks.list(res.args.join(" "), tags, special); }, { - usage: ["bmarks[!] [filter]"], shortHelp: "List or open multiple bookmarks", - help: "Open the message window at the bottom of the screen with all bookmarks which match [filter] either in the title or URL.
" + - "The special version :bmarks! works the same as :bmarks except it opens all the found bookmarks in new tabs.
" + - "Filter can also contain the following options:
" + - "-tags=comma,separated,tag,list
", completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; }, args: [[["-tags", "-T"], OPTION_LIST]] } @@ -688,13 +661,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["b[uffer]"], function (args, special) { vimperator.buffer.switchTo(args, special); }, { - usage: ["b[uffer][!] {url|index}"], shortHelp: "Go to buffer from buffer list", - help: "Argument can be either the buffer index or the full URL.
" + - "If argument is neither a full URL nor an index but uniquely identifies a buffer, " + - "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.buffer(filter); } } )); @@ -759,9 +726,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["dia[log] [firefox-dialog]"], - shortHelp: "Open a firefox-dialog", - help: "Available dialogs: use completion on :dialog <tab>", + shortHelp: "Open a Firefox dialog", completer: function (filter) { return vimperator.completion.dialog(filter); } } )); @@ -777,10 +742,7 @@ vimperator.Commands = function () //{{{ vimperator.buffer.list(special); }, { - usage: ["buffers[!]"], - shortHelp: "Show a list of all buffers (=tabs)", - help: "The special version :buffers! opens the buffer list in a persistent preview window. " + - "Call the special version of this command again to close the window." + shortHelp: "Show a list of all buffers (=tabs)" } )); commandManager.add(new vimperator.Command(["delbm[arks]"], @@ -794,13 +756,7 @@ vimperator.Commands = function () //{{{ vimperator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE); }, { - usage: ["delbm[arks] [url]"], shortHelp: "Delete a bookmark", - help: "Deletes all bookmarks which match the [url]. " + - "If omitted, [url] defaults to the URL of the current buffer. " + - "Use <Tab> key on a string to complete the URL which you want to delete.
" + - "The following options WILL be interpreted in the future:
" + - " [!] a special version to delete ALL bookmarks
", completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; } } )); @@ -814,9 +770,7 @@ vimperator.Commands = function () //{{{ vimperator.echo(vimperator.io.getCurrentDirectory()); }, { - usage: ["cd [-|path]"], shortHelp: "Change the current directory", - help: ":cd - changes to the last directory.", completer: function (filter) { return vimperator.completion.file(filter, true); } } )); @@ -868,9 +822,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["com[mand][!] [{attr}...] {cmd} {rep}"], - shortHelp: "Lists and defines commands", - help: "To be written - but it works similar to vim's :command" /*, + shortHelp: "Lists and defines commands" /*, args: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }], [["-bang"], OPTION_NOARG], [["-bar"], OPTION_NOARG]] */ @@ -920,12 +872,7 @@ vimperator.Commands = function () //{{{ vimperator.marks.remove(args, special); }, { - usage: ["delm[arks] {marks}", "delm[arks]!"], - shortHelp: "Delete the specified marks", - help: "Marks are presented as a list. Example:
" + - ":delmarks Aa b p deletes marks A, a, b and p
" + - ":delmarks b-p deletes all marks in the range b to p
" + - ":delmarks! deletes all marks for the current buffer" + shortHelp: "Delete the specified marks" } )); @@ -950,23 +897,17 @@ vimperator.Commands = function () //{{{ vimperator.quickmarks.remove(args); }, { - usage: ["delqm[arks] {marks}", "delqm[arks]!"], - shortHelp: "Delete the specified QuickMarks", - help: "QuickMarks are presented as a list. Example:
" + - ":delqmarks Aa b p deletes QuickMarks A, a, b and p
" + - ":delqmarks b-p deletes all QuickMarks in the range b to p
" + - ":delqmarks! deletes all QuickMarks" + shortHelp: "Delete the specified QuickMarks" } )); commandManager.add(new vimperator.Command(["downl[oads]", "dl"], function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); }, { - shortHelp: "Show progress of current downloads", - help: "Open the original Firefox download dialog in a new tab.
" + - "Here, downloads can be paused, canceled and resumed." + shortHelp: "Show progress of current downloads" } )); + // TODO: move helper function somewhere else? function argToString(arg, color) { if (!arg) @@ -1003,11 +944,7 @@ vimperator.Commands = function () //{{{ vimperator.echo(res); }, { - usage: ["ec[ho] {expr}"], shortHelp: "Display a string at the bottom of the window", - help: "Useful for showing informational messages. Multiple lines can be separated by \\n.
" + - "{expr} can either be a quoted string, or any expression which can be fed to eval() like 4+5. " + - "You can also view the source code of objects and functions if the return value of {expr} is an object or function.", completer: function (filter) { return vimperator.completion.javascript(filter); } } )); @@ -1019,9 +956,7 @@ vimperator.Commands = function () //{{{ vimperator.echoerr(res); }, { - usage: ["echoe[rr] {expr}"], shortHelp: "Display an error string at the bottom of the window", - help: "Just like :ec[ho], but echoes the result highlighted in red. Useful for showing important messages.", completer: function (filter) { return vimperator.completion.javascript(filter); } } )); @@ -1038,13 +973,23 @@ vimperator.Commands = function () //{{{ vimperator.execute(args); }, { - usage: ["exe[cute] {expr1} [ ... ]"], - shortHelp: "Execute the string that results from the evaluation of {expr1} as an Ex command.", - help: "Example: :execute echo \"test\" shows a message with the text "test".
" + shortHelp: "Execute the string that results from the evaluation of {expr1} as an Ex command." } )); commandManager.add(new vimperator.Command(["exu[sage]"], - function (args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); }, + function (args, special, count, modifiers) + { + var usage = ""; + for (let command in vimperator.commands) + { + usage += ""; + } + usage += "
:" + + vimperator.util.escapeHTML(command.name) + "" + + vimperator.util.escapeHTML(command.shortHelp) + "
"; + + vimperator.echo(usage, vimperator.commandline.FORCE_MULTILINE); + }, { shortHelp: "Show help for Ex commands" } @@ -1072,10 +1017,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["[count]fo[rward][!] [url]"], shortHelp: "Go forward in the browser history", - help: "Count is supported, :3forward goes forward 3 pages in the browser history.
" + - "The special version :forward! goes to the end of the browser history.", completer: function (filter) { var sh = getWebNavigation().sessionHistory; @@ -1095,40 +1037,59 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["ha[rdcopy]"], function () { getBrowser().contentWindow.print(); }, { - shortHelp: "Print current document", - help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc." - } - )); - commandManager.add(new vimperator.Command(["H[elp]"], - function (args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); }, - { - usage: ["H[elp] {subject}"], - shortHelp: "Open the help window", - help: "You can jump to the specified {subject} with :help {subject}.
" + - "Make sure you use the full Vim notation when jumping to {subject}. This means:
" + - "" + - "You can however use partial strings in the tab completion, so :help he<Tab> completes :help :help.", - completer: function (filter) { return vimperator.completion.help(filter); } + shortHelp: "Print current document" } )); commandManager.add(new vimperator.Command(["h[elp]"], - function (args, special, count, modifiers) { vimperator.Help((args || "intro")); }, + function (args, special, count, modifiers) { - shortHelp: "Not all help converted to new format, use :Help if you don't find your information.", - completer: function (filter) { return vimperator.completion.Help(filter); } + function jumpToTag(file, tag) + { + vimperator.open("chrome://vimperator/locale/" + file); + setTimeout(function() { + var elem = vimperator.buffer.getElement('@class="tag" and text()="' + tag + '"'); + if (elem) + window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context + else + dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' ); + }, 200); + } + + if (!args) + { + vimperator.open("chrome://vimperator/locale/intro.html"); + return; + } + + var [, items] = vimperator.completion.help(args); + var partialMatch = -1; + for (var i = 0; i < items.length; i++) + { + if (items[i][0] == args) + { + jumpToTag(items[i][1], items[i][0]); + return; + } + else if (partialMatch == -1 && items[i][0].indexOf(args) > -1) + { + partialMatch = i; + } + } + + if (partialMatch > -1) + jumpToTag(items[partialMatch][1], items[partialMatch][0]); + else + vimperator.echoerr("E149: Sorry, no help for " + args); + }, + { + shortHelp: "Display help", + completer: function (filter) { return vimperator.completion.help(filter); } } )); commandManager.add(new vimperator.Command(["hist[ory]", "hs"], function (args, special) { vimperator.history.list(args, special); }, { - usage: ["hist[ory][!] [filter]"], shortHelp: "Show recently visited URLs", - help: "Open the message window at the bottom of the screen with all history items which match [filter] either in the title or URL.
" + - "The special version :history! works the same as :history except it opens all the found items in new tabs.
", completer: function (filter) { return [0, vimperator.history.get(filter)]; } } )); @@ -1170,15 +1131,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["javas[cript] {cmd}", "javascript <<{endpattern}\\n{script}\\n{endpattern}", "javascript[!]"], // \\n is changed to
in the help.js code shortHelp: "Run any JavaScript command through eval()", - help: "Acts as a JavaScript interpreter by passing the argument to eval().
" + - ":javascript alert('Hello world') shows a dialog box with the text \"Hello world\".
" + - ":javascript <<EOF reads all the lines until a line starting with 'EOF' is found, and interpret them with the JavaScript eval() function.
" + - "The special version :javascript! opens the JavaScript console of Firefox.
" + - "Rudimentary <Tab> completion is available for :javascript {cmd}<Tab> (but not yet for the " + - ":js <<EOF multiline widget). Be aware that Vimperator needs to run {cmd} through eval() " + - "to get the completions, which could have unwanted side effects.", completer: function (filter) { return vimperator.completion.javascript(filter); } } )); @@ -1271,12 +1224,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["let {var-name} [+-.]= {expr1}", "let {var-name}", "let"], - shortHelp: "Sets or lists a variable", - help: "Sets the variable {var-name} " + - "to the value of the expression {expr1}." + - "If no expression is given, the value of the variable is displayed." + - "Without arguments, displays a list of all variables." + shortHelp: "Sets or lists a variable" } )); // code for abbreviations @@ -1297,11 +1245,7 @@ vimperator.Commands = function () //{{{ vimperator.editor.listAbbreviations("!", lhs); }, { - usage: ["ab[breviate] {lhs} {rhs}", "ab[breviate] {lhs}", "ab[breviate]"], - shortHelp: "Abbreviate a key sequence", - help: "Abbreviate {lhs} to {rhs}.
" + - "If only {lhs} given, list that particual abbreviation.
" + - "List all abbreviations, if no arguments to are given.
" + shortHelp: "Abbreviate a key sequence" } )); commandManager.add(new vimperator.Command(["ca[bbrev]"], @@ -1321,9 +1265,7 @@ vimperator.Commands = function () //{{{ vimperator.editor.listAbbreviations("c", lhs); }, { - usage: ["ca[bbrev] {lhs} {rhs}", "ca[bbrev] {lhs}", "ca[bbrev]"], - shortHelp: "Abbreviate a key sequence for Command-line mode", - help: "Same as :ab[reviate], but for Command-line mode only." + shortHelp: "Abbreviate a key sequence for Command-line mode" } )); commandManager.add(new vimperator.Command(["ia[bbrev]"], @@ -1342,34 +1284,19 @@ vimperator.Commands = function () //{{{ else vimperator.editor.listAbbreviations("i", lhs); }, - { - usage: ["ia[bbrev] {lhs} {rhs}", "ia[bbrev] {lhs}", "ia[bbrev]"], - shortHelp: "Abbreviate a key sequence for Insert mode", - help: "Same as :ab[breviate], but for Insert mode only." - } + { shortHelp: "Abbreviate a key sequence for Insert mode" } )); commandManager.add(new vimperator.Command(["una[bbreviate]"], function (args) { vimperator.editor.removeAbbreviation("!", args); }, - { - usage: ["una[bbreviate] {lhs}"], - shortHelp: "Remove an abbreviation" - } + { shortHelp: "Remove an abbreviation" } )); commandManager.add(new vimperator.Command(["cuna[bbrev]"], function (args) { vimperator.editor.removeAbbreviation("c", args); }, - { - usage: ["cuna[bbrev] {lhs}"], - shortHelp: "Remove an abbreviation for Command-line mode", - help: "Same as :una[bbreviate], but for Command-line mode only." - } + { shortHelp: "Remove an abbreviation for Command-line mode" } )); commandManager.add(new vimperator.Command(["iuna[bbrev]"], function (args) { vimperator.editor.removeAbbreviation("i", args); }, - { - usage: ["iuna[bbrev] {lhs}"], - shortHelp: "Remove an abbreviation for Insert mode", - help: "Same as :una[bbreviate], but for Insert mode only." - } + { shortHelp: "Remove an abbreviation for Insert mode" } )); commandManager.add(new vimperator.Command(["abc[lear]"], function (args) { vimperator.editor.removeAllAbbreviations("!"); }, @@ -1426,16 +1353,6 @@ vimperator.Commands = function () //{{{ }, { shortHelp: "Execute commands automatically on events", - help: ":au[tocmd] {event} {pat} {cmd}
" + - "Add {cmd} to the list of commands Vimperator will execute on {event}

" + - ":autocmd[!] {events} {pat}
" + - "list/remove autocommands filtered be {events} and {pat}
" + - ":autocmd[!] {events}
" + - "list/remove autocommands matching {events}
" + - ":autocmd[!] * {pat}
" + - "list/remove autocommands matching {pat}
" + - ":autocmd[!]
" + - "list/remove all autocommands", completer: function (filter) { return vimperator.completion.autocommands(filter); } } )); @@ -1453,9 +1370,7 @@ vimperator.Commands = function () //{{{ vimperator.echo(str, vimperator.commandline.FORCE_MULTILINE); }, { - usage: ["mac[ros] [regex]"], - shortHelp: "List macros matching a regex", - help: "List recorded macros matching the optional regular expression. If no regex is given, list all." + shortHelp: "List macros matching a regex" } )); commandManager.add(new vimperator.Command(["delmac[ros]"], @@ -1467,9 +1382,7 @@ vimperator.Commands = function () //{{{ vimperator.events.deleteMacros(arg); }, { - usage: ["delmac[ros] [regex]"], - shortHelp: "Delete macros matching a regex", - help: "Delete recorded macros matching a regular expression." + shortHelp: "Delete macros matching a regex" } )); commandManager.add(new vimperator.Command(["pl[ay]"], @@ -1481,7 +1394,6 @@ vimperator.Commands = function () //{{{ vimperator.events.playMacro(arg); }, { - usage: ["pl[ay] "], shortHelp: "Play a macro", completer: function (filter) { return vimperator.completion.macros(filter); } } @@ -1521,30 +1433,15 @@ vimperator.Commands = function () //{{{ } commandManager.add(new vimperator.Command(["map"], function (args) { map(args, [vimperator.modes.NORMAL], false); }, - { - usage: ["map {lhs} {rhs}", "map {lhs}", "map"], - shortHelp: "Map the key sequence {lhs} to {rhs}", - help: "The {rhs} is remapped, allowing for nested and recursive mappings.
" + - "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" - } + { shortHelp: "Map the key sequence {lhs} to {rhs}" } )); commandManager.add(new vimperator.Command(["cm[ap]"], function (args) { map(args, [vimperator.modes.COMMAND_LINE], false); }, - { - usage: ["cmap {lhs} {rhs}", "cmap {lhs}", "cmap"], - shortHelp: "Map the key sequence {lhs} to {rhs} (in command-line mode)", - help: "The {rhs} is remapped, allowing for nested and recursive mappings.
" + - "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" - } + { shortHelp: "Map the key sequence {lhs} to {rhs} (in command-line mode)" } )); commandManager.add(new vimperator.Command(["im[ap]"], function (args) { map(args, [vimperator.modes.INSERT, vimperator.modes.TEXTAREA], false); }, - { - usage: ["imap {lhs} {rhs}", "imap {lhs}", "imap"], - shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)", - help: "The {rhs} is remapped, allowing for nested and recursive mappings.
" + - "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" - } + { shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)" } )); commandManager.add(new vimperator.Command(["mapc[lear]"], function (args) @@ -1558,9 +1455,7 @@ vimperator.Commands = function () //{{{ vimperator.mappings.removeAll(vimperator.modes.NORMAL); }, { - shortHelp: "Remove all mappings", - help: "All user-defined mappings which were set by " + - ":map or :noremap are cleared." + shortHelp: "Remove all mappings" } )); commandManager.add(new vimperator.Command(["cmapc[lear]"], @@ -1575,9 +1470,7 @@ vimperator.Commands = function () //{{{ vimperator.mappings.removeAll(vimperator.modes.COMMAND_LINE); }, { - shortHelp: "Remove all mappings (in command-line mode)", - help: "All user-defined mappings which were set by " + - ":cmap or :cnoremap are cleared." + shortHelp: "Remove all mappings (in command-line mode)" } )); commandManager.add(new vimperator.Command(["imapc[lear]"], @@ -1593,9 +1486,7 @@ vimperator.Commands = function () //{{{ vimperator.mappings.removeAll(vimperator.modes.TEXTAREA); }, { - shortHelp: "Remove all mappings (in insert mode)", - help: "All user-defined mappings which were set by " + - ":imap or :inoremap are cleared." + shortHelp: "Remove all mappings (in insert mode)" } )); commandManager.add(new vimperator.Command(["ma[rk]"], @@ -1620,7 +1511,6 @@ vimperator.Commands = function () //{{{ vimperator.marks.add(args); }, { - usage: ["ma[rk] {a-zA-Z}"], shortHelp: "Mark current location within the web page" } )); @@ -1638,9 +1528,7 @@ vimperator.Commands = function () //{{{ vimperator.marks.list(filter); }, { - usage: ["marks [arg]"], - shortHelp: "Show all location marks of current web page", - help: "If [arg] is specified then limit the list to those marks mentioned." + shortHelp: "Show all location marks of current web page" } )); commandManager.add(new vimperator.Command(["mkv[imperatorrc]"], @@ -1705,23 +1593,12 @@ vimperator.Commands = function () //{{{ vimperator.io.writeFile(file, line); }, { - usage: ["mkv[imperatorrc] [file]"], - shortHelp: "Write current key mappings and changed options to [file]", - help: "If no [file] is specified then ~/.vimperatorrc is written unless this file already exists. " + - "The special version will overwrite [file] if it exists.
" + - "WARNING: this differs from Vim's behavior which defaults to writing the file in the current directory." + shortHelp: "Write current key mappings and changed options to [file]" } )); commandManager.add(new vimperator.Command(["noh[lsearch]"], - function (args) - { - vimperator.search.clear(); - }, - { - shortHelp: "Remove the search highlighting", - help: "The document highlighting is turned back on when another search command is used or the " + - "'hlsearch' option is set." - } + function (args) { vimperator.search.clear(); }, + { shortHelp: "Remove the search highlighting" } )); commandManager.add(new vimperator.Command(["norm[al]"], function (args, special) @@ -1735,37 +1612,22 @@ vimperator.Commands = function () //{{{ vimperator.events.feedkeys(args, special); }, { - usage: ["norm[al][!] {commands}"], - shortHelp: "Execute Normal mode commands", - help: "Example: :normal 20j scrolls 20 lines down. " + - "If the [!] is specified mappings will not be used." + shortHelp: "Execute Normal mode commands" } )); // TODO: remove duplication in :map commandManager.add(new vimperator.Command(["no[remap]"], function (args) { map(args, [vimperator.modes.NORMAL], true); }, - { - usage: ["no[remap] {lhs} {rhs}", "no[remap] {lhs}", "no[remap]"], - shortHelp: "Map the key sequence {lhs} to {rhs}", - help: "No remapping of the {rhs} is performed." - } + { shortHelp: "Map the key sequence {lhs} to {rhs}" } )); // XXX: TODO: remove duplication in :cmap commandManager.add(new vimperator.Command(["cno[remap]"], function (args) { map(args, [vimperator.modes.COMMAND_LINE], true); }, - { - usage: ["cno[remap] {lhs} {rhs}", "cno[remap] {lhs}", "cno[remap]"], - shortHelp: "Map the key sequence {lhs} to {rhs} (in command-line mode)", - help: "No remapping of the {rhs} is performed." - } + { shortHelp: "Map the key sequence {lhs} to {rhs} (in command-line mode)" } )); commandManager.add(new vimperator.Command(["ino[remap]"], function (args) { map(args, [vimperator.modes.INSERT, vimperator.modes.TEXTAREA], true); }, - { - usage: ["ino[remap] {lhs} {rhs}", "ino[remap] {lhs}", "ino[remap]"], - shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)", - help: "No remapping of the {rhs} is performed." - } + { shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)" } )); commandManager.add(new vimperator.Command(["o[pen]", "e[dit]"], function (args, special) @@ -1783,44 +1645,17 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["o[pen] [url] [, url]"], shortHelp: "Open one or more URLs in the current tab", - help: "Multiple URLs can be separated with \", \". Note that the space after the comma is required.
" + - "Each token is analyzed and in this order:
" + - "
    " + - "
  1. Opened as a local file if it is an existing relative or absolute filename. " + - "
    • :open /etc/fstab shows the file system table.
    • " + - "
    • :open ../other/foo.html in your home directory opens \"/home/other/foo.html\"
  2. " + - "
  3. 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 (:open wikipedia linus torvalds " + - "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, open the $FIREFOX_PROFILE/searchplugins/*.xml file of the search engine, and add/change " + - "<Alias>myalias</Alias>
  4. " + - "
  5. Opened with the default search engine or keyword (specified with the 'defsearch' option) " + - "if the first word is no search engine (:open linus torvalds opens a Google search for linux torvalds).
  6. " + - "
  7. Passed directly to Firefox in all other cases (:open www.osnews.com, www.slashdot.org " + - "opens OSNews in the current, and Slashdot in a new background tab).
  8. " + - "
" + - "You can use :open -tags linux torvalds<Tab> to complete bookmarks " + - "with tag \"linux\" and which contain \"torvalds\". Note that -tags support is only available for tab completion, not for the actual command.
" + - "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.url(filter); } } )); commandManager.add(new vimperator.Command(["pa[geinfo]"], function () { vimperator.buffer.showPageInfo(true); }, - { - shortHelp: "Show various page information", - help: "See :help 'pageinfo' for available options" - } + { shortHelp: "Show various page information" } )); commandManager.add(new vimperator.Command(["pc[lose]"], function () { vimperator.previewwindow.hide(); }, - { - shortHelp: "Close preview window on bottom of screen" - } + { shortHelp: "Close preview window on bottom of screen" } )); commandManager.add(new vimperator.Command(["pref[erences]", "prefs"], function (args, special, count, modifiers) @@ -1847,11 +1682,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["pref[erences][!]"], - shortHelp: "Show Browser Preferences", - help: "You can change the browser preferences from this dialog. " + - "Be aware that not all Firefox preferences work, because Vimperator overrides some key bindings and changes Firefox's GUI.
" + - ":prefs! opens about:config in the current tab where you can change advanced Firefox preferences." + shortHelp: "Show Browser Preferences" } )); commandManager.add(new vimperator.Command(["qma[rk]"], @@ -1872,10 +1703,7 @@ vimperator.Commands = function () //{{{ vimperator.quickmarks.add(matches[1], matches[2]); }, { - usage: ["qma[rk] {a-zA-Z0-9} [url]"], - shortHelp: "Mark a URL with a letter for quick access", - help: "You can also mark whole groups like this:
" + - ":qmark f http://forum1.com, http://forum2.com, imdb some artist" + shortHelp: "Mark a URL with a letter for quick access" } )); commandManager.add(new vimperator.Command(["qmarks"], @@ -1892,25 +1720,16 @@ vimperator.Commands = function () //{{{ vimperator.quickmarks.list(filter); }, { - usage: ["qmarks [arg]"], - shortHelp: "Show all QuickMarks", - help: "If [arg] is specified then limit the list to those QuickMarks mentioned." + shortHelp: "Show all QuickMarks" } )); commandManager.add(new vimperator.Command(["q[uit]"], function () { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); }, - { - shortHelp: "Quit current tab", - help: "If this is the last tab in the window, close the window. If this was the " + - "last window, close Vimperator. When quitting Vimperator, the session is not stored." - } + { shortHelp: "Quit current tab" } )); commandManager.add(new vimperator.Command(["quita[ll]", "qa[ll]"], function () { vimperator.quit(false); }, - { - shortHelp: "Quit Vimperator", - help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored." - } + { shortHelp: "Quit Vimperator", } )); commandManager.add(new vimperator.Command(["redr[aw]"], function () @@ -1919,33 +1738,19 @@ vimperator.Commands = function () //{{{ getInterface(Components.interfaces.nsIDOMWindowUtils); wu.redraw(); }, - { - shortHelp: "Redraw the screen", - help: "Useful to update the screen halfway executing a script or function." - } + { shortHelp: "Redraw the screen", } )); commandManager.add(new vimperator.Command(["re[load]"], function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }, - { - usage: ["re[load][!]"], - shortHelp: "Reload current page", - help: "Forces reloading of the current page. If ! is given, skip the cache." - } + { shortHelp: "Reload current page" } )); commandManager.add(new vimperator.Command(["reloada[ll]"], function (args, special) { vimperator.tabs.reloadAll(special); }, - { - usage: ["reloada[ll][!]"], - shortHelp: "Reload all pages", - help: "Forces reloading of all pages. If ! is given, skip the cache." - } + { shortHelp: "Reload all pages" } )); commandManager.add(new vimperator.Command(["res[tart]"], function () { vimperator.restart(); }, - { - shortHelp: "Force the browser to restart", - help: "Useful when installing extensions." - } + { shortHelp: "Force the browser to restart" } )); commandManager.add(new vimperator.Command(["sav[eas]", "w[rite]"], function (args, special) @@ -1962,10 +1767,7 @@ vimperator.Commands = function () //{{{ saveDocument(window.content.document, special); }, { - shortHelp: "Save current web page to disk", - help: "Opens the original Firefox \"Save page as...\" dialog.
" + - "There, you can save the current web page to disk with various options. " + - "Use ! to save the file with a default filename to the current working directory, skipping the Save as... prompt" + shortHelp: "Save current web page to disk" } )); commandManager.add(new vimperator.Command(["se[t]"], @@ -2214,21 +2016,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["se[t][!]", "se[t] {option}?", "se[t] [no]{option}", "se[t] {option}[+-]={value}", "se[t] {option}! | inv{option}", "se[t] {option}&"], shortHelp: "Set an option", - help: "Temporarily change an option for the current session only. If you want " + - "to change an option permanently, put it in your ~/.vimperatorrc configuration file.
" + - ":set without an argument shows all Vimperator options which differ from their default values.
" + - ":set! without an argument shows all about:config preferences which differ from their default values.
" + - "There are three types of options: boolean, number and string. " + - "Boolean options must be set with :set option and :set nooption. " + - "Number and string option types must be set with :set option={value}.
" + - ":set option! and :set invoption invert the value of a boolean option.
" + - ":set option? or :set option(for string and list options) shows the current value of an option.
" + - ":set option& resets an option to its default value.
" + - ":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, special) { return vimperator.completion.option(filter, special); } } )); @@ -2279,10 +2067,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["sidebar {name}"], 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.sidebar(filter); } } )); @@ -2299,43 +2084,24 @@ vimperator.Commands = function () //{{{ vimperator.source(args, special); }, { - usage: ["so[urce][!] {file}"], shortHelp: "Read Ex commands from {file}", - help: "You can either source files which mostly contain Ex commands like map < gt " + - "and put JavaScript code within a:
" + - "js <<EOF
hello = function () {
  alert(\"Hello world\");
}
EOF
section.
" + - "Or you can alternatively source a file which ends in .js, these files are automatically sourced as pure JavaScript files.
" + - "NOTE: In both cases you must add functions to the global window object like shown above, functions written as:
" + - "function hello2() {
  alert(\"Hello world\");
}
are only available within the scope of the script.

" + - "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.file(filter, true); } } )); commandManager.add(new vimperator.Command(["st[op]"], BrowserStop, - { - shortHelp: "Stop loading", - help: "Stop loading current web page." - } + { shortHelp: "Stop loading" } )); commandManager.add(new vimperator.Command(["tab"], function (args) { vimperator.execute(args, { inTab: true }); }, { - usage: ["tab {cmd}"], shortHelp: "Execute {cmd} and tell it to output in a new tab", - help: "Works only for commands that support it, currently:" + - "", completer: function (filter) { return vimperator.completion.command(filter); } } )); commandManager.add(new vimperator.Command(["tabl[ast]"], function () { vimperator.tabs.select("$", false); }, - { - shortHelp: "Switch to the last tab" - } + { shortHelp: "Switch to the last tab" } )); commandManager.add(new vimperator.Command(["tabm[ove]"], function (args, special) @@ -2353,10 +2119,7 @@ vimperator.Commands = function () //{{{ vimperator.tabs.move(getBrowser().mCurrentTab, args, special); }, { - usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"], - shortHelp: "Move the current tab after tab N", - help: "When N is 0 the current tab is made the first one. Without N the current tab is made the last one. " + - "N can also be prefixed with '+' or '-' to indicate a relative movement. If ! is specified the movement wraps around the start or end of the tab list." + shortHelp: "Move the current tab after tab N" } )); commandManager.add(new vimperator.Command(["tabn[ext]", "tn[ext]"], @@ -2381,16 +2144,12 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["tabn[ext] [count]"], - shortHelp: "Switch to the next or [count]th tab", - help: "Cycles to the first tab when the last is selected and {count} is not specified." + shortHelp: "Switch to the next or [count]th tab" } )); commandManager.add(new vimperator.Command(["tabo[nly]"], function () { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); }, - { - shortHelp: "Close all other tabs" - } + { shortHelp: "Close all other tabs" } )); commandManager.add(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], function (args, special) @@ -2405,10 +2164,7 @@ vimperator.Commands = function () //{{{ vimperator.open("about:blank", where); }, { - usage: ["tabopen [url] [, url]"], 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.url(filter); } } )); @@ -2424,17 +2180,12 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("E488: Trailing characters"); }, { - usage: ["tabp[revious] [count]"], - shortHelp: "Switch to the previous tab or go [count] tabs back", - help: "Wraps around from the first tab to the last tab." + shortHelp: "Switch to the previous tab or go [count] tabs back" } )); commandManager.add(new vimperator.Command(["tabr[ewind]", "tabfir[st]"], function () { vimperator.tabs.select(0, false); }, - { - usage: ["tabr[ewind]", "tabfir[st]"], - shortHelp: "Switch to the first tab" - } + { shortHelp: "Switch to the first tab" } )); commandManager.add(new vimperator.Command(["time"], function (args, special, count) @@ -2519,12 +2270,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["{count}time[!] {code|:command}"], - shortHelp: "Profile a piece of code or a command", - help: "Runs {code} {count} times (default 1) and returns the elapsed time. " + - "{code} is always passed to JavaScript's eval(), which might be slow, so take the results with a grain of salt.
" + - "If {code} starts with a :, it is executed as a Vimperator command.
" + - "Use the special version with [!] if you just want to run any command multiple times without showing profiling statistics." + shortHelp: "Profile a piece of code or a command" } )); commandManager.add(new vimperator.Command(["u[ndo]"], @@ -2549,10 +2295,7 @@ vimperator.Commands = function () //{{{ undoCloseTab(count - 1); }, { - usage: ["[count]u[ndo][!] [url]"], shortHelp: "Undo closing of a tab", - help: "If a count is given, don't close the last but the [count]th last tab. " + - "With [url] restores the tab matching the url.", completer: function (filter) { // get closed-tabs from nsSessionStore @@ -2591,8 +2334,7 @@ vimperator.Commands = function () //{{{ undoCloseTab(); // doesn't work with i as the index to undoCloseTab }, { - shortHelp: "Undo closing of all closed tabs", - help: "Firefox stores up to 10 closed tabs, even after a browser restart." + shortHelp: "Undo closing of all closed tabs" } )); commandManager.add(new vimperator.Command(["unl[et]"], @@ -2621,10 +2363,7 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["unl[et][!] {name} ..."], - shortHelp: "Deletes a variable.", - help: "Deletes the variable {name}." + - "Several variable names can be given." + shortHelp: "Deletes a variable." } )); commandManager.add(new vimperator.Command(["unm[ap]"], @@ -2644,9 +2383,7 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("E31: No such mapping"); }, { - usage: ["unm[ap] {lhs}"], - shortHelp: "Remove the mapping of {lhs}", - help: "" + shortHelp: "Remove the mapping of {lhs}" } )); commandManager.add(new vimperator.Command(["cunm[ap]"], @@ -2666,9 +2403,7 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("E31: No such mapping"); }, { - usage: ["cunm[ap] {lhs}"], - shortHelp: "Remove the mapping of {lhs} (in command-line mode)", - help: "" + shortHelp: "Remove the mapping of {lhs} (in command-line mode)" } )); commandManager.add(new vimperator.Command(["iunm[ap]"], @@ -2697,9 +2432,7 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("E31: No such mapping"); }, { - usage: ["iunm[ap] {lhs}"], - shortHelp: "Remove the mapping of {lhs} (in insert mode)", - help: "" + shortHelp: "Remove the mapping of {lhs} (in insert mode)" } )); commandManager.add(new vimperator.Command(["ve[rsion]"], @@ -2712,9 +2445,7 @@ vimperator.Commands = function () //{{{ "\nVimperator " + vimperator.version + " running on:\n" + navigator.userAgent); }, { - usage: ["ve[rsion][!]"], - shortHelp: "Show version information", - help: "You can show the Firefox version page with :version!." + shortHelp: "Show version information" } )); commandManager.add(new vimperator.Command(["vie[wsource]"], @@ -2745,26 +2476,30 @@ vimperator.Commands = function () //{{{ } }, { - usage: ["vie[wsource][!] [url]"], - shortHelp: "View source code of current document", - help: "When ! is given, it is opened with the external editor." + shortHelp: "View source code of current document" } )); commandManager.add(new vimperator.Command(["viu[sage]"], - function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); }, + function (args, special, count, modifiers) + { + var usage = ""; + for (let mapping in vimperator.mappings) + { + usage += ""; + } + usage += "
" + + vimperator.util.escapeHTML(mapping.names[0]) + "" + + vimperator.util.escapeHTML(mapping.shortHelp || "") + "
"; + + vimperator.echo(usage, vimperator.commandline.FORCE_MULTILINE); + }, { shortHelp: "Show help for normal mode commands" } )); commandManager.add(new vimperator.Command(["winc[lose]", "wc[lose]"], - function (args) - { - window.close(); - }, - { - usage: ["winc[ose] [url] [, url]"], - shortHelp: "Close window" - } + function (args) { window.close(); }, + { shortHelp: "Close window" } )); commandManager.add(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"], function (args) @@ -2775,19 +2510,12 @@ vimperator.Commands = function () //{{{ vimperator.open("about:blank", vimperator.NEW_WINDOW); }, { - usage: ["wino[pen] [url] [, url]"], - shortHelp: "Open one or more URLs in a new window", - help: "Like :open but open URLs in a new window.
" + shortHelp: "Open one or more URLs in a new window" } )); commandManager.add(new vimperator.Command(["wqa[ll]", "wq", "xa[ll]"], function () { vimperator.quit(true); }, - { - usage: ["wqa[ll]", "xa[ll]"], - shortHelp: "Save the session and quit", - help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.
" + - ":wq is different as in Vim, as it closes the window instead of just one tab by popular demand. Complain on the mailing list, if you want to change that." - } + { shortHelp: "Save the session and quit" } )); commandManager.add(new vimperator.Command(["zo[om]"], function (args, special) @@ -2827,11 +2555,7 @@ vimperator.Commands = function () //{{{ vimperator.buffer.textZoom = level; }, { - usage: ["zo[om][!] [value]", "zo[om][!] +{value} | -{value}"], - shortHelp: "Set zoom value of current web page", - help: "If {value} can be an absolute value between 1 and 2000% or a relative value if prefixed with - or +. " + - "If {value} is omitted, zoom is reset to 100%.
" + - "Normally this command operates on the text zoom, if used with [!] it operates on full zoom." + shortHelp: "Set zoom value of current web page" } )); commandManager.add(new vimperator.Command(["!", "run"], @@ -2850,12 +2574,7 @@ vimperator.Commands = function () //{{{ vimperator.echo(vimperator.util.escapeHTML(output)); }, { - usage: ["!{cmd}"], - shortHelp: "Run a command", - help: "Runs {cmd} through system() and displays its output. " + - "Any '!' in {cmd} is replaced with the previous external command. " + - "But not when there is a backslash before the '!', then that backslash is removed.
" + - "Input redirection (< foo) not done, also do not run commands which require stdin or it will hang Firefox!" + shortHelp: "Run a command" } )); //}}} diff --git a/content/completion.js b/content/completion.js index 436db45e..bdd5c130 100644 --- a/content/completion.js +++ b/content/completion.js @@ -287,36 +287,13 @@ vimperator.Completion = function () //{{{ }, help: function (filter) - { - var helpArray = [[["introduction"], "Introductory text"], - [["initialization"], "Initialization and startup"], - [["mappings"], "Normal mode commands"], - [["commands"], "Ex commands"], - [["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages' - substrings = []; - for (var command in vimperator.commands) - helpArray.push([command.longNames.map(function ($_) { return ":" + $_; }), command.shortHelp]); - options = this.option(filter, false, true); - helpArray = helpArray.concat(options.map(function ($_) { - return [ - $_[0].map(function ($_) { return "'" + $_ + "'"; }), - $_[1] - ]; - })); - for (var map in vimperator.mappings) - helpArray.push([map.names, map.shortHelp]); - - // unfiltered, use the first command - if (!filter) - return [0, helpArray.map(function ($_) { return [$_[0][0], $_[1]]; })]; - - return [0, buildLongestCommonSubstring(helpArray, filter)]; - }, - - Help: function (filter) { var res = []; - var files = ["intro.html", "options.html", "motion.html", "starting.html", "browsing.html", "various.html", "developer.html"]; + // they are sorted by relevance, not alphabetically + var files = ["intro.html", "starting.html", "browsing.html", "motion.html", + "options.html", "tabs.html", "marks.html", "repeat.html", + "autocommands.html", "developer.html", "various.html"]; + for (var file in files) { try diff --git a/content/help.js b/content/help.js deleted file mode 100644 index 0f39c2b1..00000000 --- a/content/help.js +++ /dev/null @@ -1,280 +0,0 @@ -/***** BEGIN LICENSE BLOCK ***** {{{ -Version: MPL 1.1/GPL 2.0/LGPL 2.1 - -The contents of this file are subject to the Mozilla Public License Version -1.1 (the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the -License. - -(c) 2006-2008: Martin Stubenschrott - -Alternatively, the contents of this file may be used under the terms of -either the GNU General Public License Version 2 or later (the "GPL"), or -the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -in which case the provisions of the GPL or the LGPL are applicable instead -of those above. If you wish to allow use of your version of this file only -under the terms of either the GPL or the LGPL, and not to allow others to -use your version of this file under the terms of the MPL, indicate your -decision by deleting the provisions above and replace them with the notice -and other provisions required by the GPL or the LGPL. If you do not delete -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.help = function (section, easter) //{{{ -{ - if (easter) - { - vimperator.echoerr("E478: Don't panic!"); - return; - } - - if ((arguments[3] && arguments[3].inTab))// || !window.content.document.open) - vimperator.open("about:blank", vimperator.NEW_TAB); - else - vimperator.open("about:blank"); - - /* commands = array where help information is located - * beg = string which is printed before the commmand/option/mapping name - * end = string which is printed after the commmand/option/mapping name - * func = called with 'command', result is a string is prepended to the help text - */ - function makeHelpString(commands, beg, end, func) - { - var ret = ""; - for (var command in commands) - ret += vimperator.util.generateHelp(command); - - return ret; - } - - function makeOptionsHelpString(command) - { - var ret = ""; - ret = command.type + ' (default: '; - if (command.type == "boolean") - { - if (command.defaultValue == true) - ret += "on"; - else - ret += "off"; - } - else - { - if (typeof command.defaultValue == "string" && command.defaultValue.length == 0) - ret += "''"; - else - ret += command.defaultValue; - } - - ret += ")
"; - return ret; - } - - var header = '

Vimperator

' + - '

First there was a Navigator, then there was an Explorer.\n' + - 'Later it was time for a Konqueror. Now it\'s time for an Imperator, the VIMperator :)

'; - - var introduction = 'introduction

Introduction

' + - '

Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. ' + - 'It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.

' + - - '

Warning: To provide the most authentic Vim experience, the Firefox menubar and toolbar were hidden.
' + - 'If you really need them, type: :set guioptions+=mT to get them back.\n' + - 'If you don\'t like Vimperator at all, you can uninstall it by typing :addons and remove/disable it.\n' + - 'If you like it, but can\'t remember the shortcuts, press F1 or :help to get this help window back.

' + - - '

Vimperator was written by Martin Stubenschrott. ' + - 'If you appreciate my work on Vimperator and want to encourage me working on it more, you can either send me greetings, patches or make a donation:

' + - - '
' + - '' + - '' + - - '' + - '' + - '
' + - - '

Of course as a believer in free open source software, only make a donation if you really like Vimperator and the money doesn\'t hurt - otherwise just use it, recommend it and like it :)

'; - - var initialization = 'initialization

Initialization

' + - '

At startup Vimperator sources a user RC file, containing Ex commands, and any JavaScript files found in the plugin directory.

' + - '

The RC file may be named .vimperatorrc or _vimperatorrc. The search order is:

' + - '
    ' + - '
  • Unix and Mac - ~/.vimperatorrc then ~/_vimperatorrc
  • ' + - '
  • Windows - ~/_vimperatorrc then ~/.vimperatorrc
  • ' + - '
' + - '

The plugin directory is named:

' + - '
    ' + - '
  • Unix and Mac - ~/.vimperator/plugin
  • ' + - '
  • Windows - ~/vimperator/plugin
  • ' + - '
' + - '

The user\'s $HOME(~) directory is determined as follows:

' + - '
    ' + - '
  • Unix and Mac - $HOME is used.
  • ' + - '
  • Windows - if $HOME is set then this is used, otherwise $USERPROFILE or finally $HOMEDRIVE$HOMEPATH.
  • ' + - '
' + - '$VIMPERATOR_HOME can be used to override the calculated $HOME directory.'; - - var mappings = 'mappings

Mappings

' + - '

The denotion of modifier keys is like in Vim, so C- means the Control key, M- the Meta key, A- the Alt key and S- the Shift key.

' + - ''; - mappings = makeHelpString(vimperator.mappings, "", "", null); - //mappings += '
'; - if (section && section == "holy-grail") - mappings += '

You found it, Arthur!

\n'; - - var commands = 'commands

Commands

' + - '\n'; - commands = makeHelpString(vimperator.commands, ":", "", null); - //commands += '
'; - if (section && section == "42") - commands += '

What is the meaning of life, the universe and everything?
' + - 'Douglas Adams, the only person who knew what this question really was about is
' + - 'now dead, unfortunately. So now you might wonder what the meaning of death
' + - 'is...

\n'; - - var options = 'options

Options

' + - '\n'; - options += makeHelpString(vimperator.options, "'", "'", makeOptionsHelpString); - options += '
'; - - var fulldoc = '\n' + - '\n' + - '\n\nVimperator Help\n' + - // XXX: stylesheet broken here? Have to add it in the vimperator.xul file - '\n' + - '\n\n
\n' + - 'version ' + vimperator.version + '\n' + - header + - introduction + - initialization + - mappings + - commands + - options + - '\n
\n\n'; - - dump(mappings + commands + "\n\n\n"); - - var doc = window.content.document; - dump("before open\n"); - - try - { - doc.open(); - } - catch (e) - { - dump("catched open\n"); - // FIXME: what's this all about then, eh? Works the same for if it's removed. -- djk - // when the url is "about:" or any other xhtml page the doc is not open - // then retry again in 250ms but just once - if (arguments[3] && arguments[3].recursive) - return false; - - vimperator.open("about:blank"); - setTimeout(function () { vimperator.help(section, false, null, { recursive: true }); }, 250); - return; - } - dump("before write\n"); - doc.write(fulldoc); - dump("after write\n"); - doc.close(); - dump("closed doc\n"); - - - // TODO: change to getBoundingClientRect() for FF 3.0 - function cumulativeOffset(element) - { - var valueT = 0, valueL = 0; - if (!element) - return [0, 0]; - - do - { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } - while (element); - - return [valueL, valueT]; - } - - // FIXME - setTimeout(function () { - if (section) - { - function findSectionElement(section) - { - return vimperator.buffer.evaluateXPath('//code[@class="tag" and text()="' + section + '"] | id("' + section + '")') - .snapshotItem(0); - } - - var element = findSectionElement(section); - if (!element) - { - var firstChar = section.charAt(0); - if (firstChar != ":" && firstChar != "'") - { - element = findSectionElement(":" + section); - if (!element) - element = findSectionElement("'" + section + "'"); - } - } - if (!element) - { - vimperator.echoerr("E149: Sorry, no help for " + section); - return; - } - // FIXME: H2 elements are currently wrapped in DIVs so this works - var pos = cumulativeOffset(element.parentNode); - // horizontal offset is annoying, set it to 0 (use pos[0] if you want horizontal offset) - window.content.scrollTo(0, pos[1]); - } - }, 0); -}; //}}} - - -// New style help -vimperator.Help = function(section) -{ - function jumpToTag(file, tag) - { - vimperator.open("chrome://vimperator/locale/" + file); - setTimeout(function() { - var elem = vimperator.buffer.getElement('@class="tag" and text()="' + tag + '"'); - if (elem) - window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context - else - dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' ); - }, 200); - } - - var [, items] = vimperator.completion.Help(); - var partialMatch = -1; - for (var i = 0; i < items.length; i++) - { - if (items[i][0] == section) - { - jumpToTag(items[i][1], items[i][0]); - return; - } - else if (partialMatch == -1 && items[i][0].indexOf(section) > -1) - { - partialMatch = i; - } - } - - if (partialMatch > -1) - jumpToTag(items[partialMatch][1], items[partialMatch][0]); - else - vimperator.echoerr("E149: Sorry, no help for " + section); -}; - -// vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/mappings.js b/content/mappings.js index 030b3ad6..d2d255bd 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -35,36 +35,14 @@ vimperator.Map = function (modes, cmds, action, extraInfo) //{{{ this.names = cmds; this.action = action; - this.usage = [this.names[0]]; - if (extraInfo) { this.flags = extraInfo.flags || 0; - if (extraInfo.usage) - { - this.usage = extraInfo.usage; - } - else - { - this.usage = this.names[0]; // only the first command name - if (this.flags & vimperator.Mappings.flags.COUNT) - this.usage = "[count]" + this.usage; - if (this.flags & vimperator.Mappings.flags.ARGUMENT) - this.usage += " {arg}"; - this.usage = [this.usage]; // FIXME: usage an array - needed for the help - } - - this.help = extraInfo.help || null; - this.shortHelp = extraInfo.shortHelp || null; + this.shortHelp = extraInfo.shortHelp || ""; this.rhs = extraInfo.rhs || null; this.noremap = extraInfo.noremap || false; - - // TODO: are these limited to HINTS mode? - // Only set for hints maps - this.cancelMode = extraInfo.cancelMode || false; - this.alwaysActive = extraInfo.alwaysActive || false; } }; @@ -276,7 +254,6 @@ vimperator.Mappings = function () //{{{ list: function (modes, filter) { - // modes means, a map must exist in both modes in order to get listed var maps = user[modes[0]]; // duplicate (reference) (first mode where it must match) var output = []; @@ -384,32 +361,25 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map(allModes, [""], function () { vimperator.help(null); }, { - shortHelp: "Open help window", - help: "The default section is shown, if you need help for a specific topic, try :help <F1>." + shortHelp: "Open help window" } )); addDefaultMap(new vimperator.Map(allModes, ["", ""], vimperator.events.onEscape, { - shortHelp: "Focus content", - help: "Exits any command line or hint mode and returns to browser mode.
" + - "Also focuses the web page, in case a form field has focus and eats our key presses." + shortHelp: "Focus content" } )); addDefaultMap(new vimperator.Map(noninsertModes, [":"], function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }, - { - shortHelp: "Start command line mode", - help: "In command line mode, you can perform extended commands, which may require arguments." - } + { shortHelp: "Start command line mode" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.CARET], [""], function () { document.commandDispatcher.advanceFocus(); }, { shortHelp: "Advance keyboard focus" } )); - addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.CARET, vimperator.modes.INSERT, vimperator.modes.TEXTAREA], - [""], + addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.CARET, vimperator.modes.INSERT, vimperator.modes.TEXTAREA], [""], function () { document.commandDispatcher.rewindFocus(); }, { shortHelp: "Rewind keyboard focus" } )); @@ -421,52 +391,29 @@ vimperator.Mappings = function () //{{{ // which takes care of the mode setting vimperator.options.setFirefoxPref("accessibility.browsewithcaret", true); }, - { - shortHelp: "Start caret mode", - help: "This mode resembles the Vim normal mode where you see a text cursor and can move around. " + - "If you want to select text in this mode, press v to start its Visual mode." - } + { shortHelp: "Start caret mode" } )); addDefaultMap(new vimperator.Map(allModes, [""], function () { vimperator.modes.passAllKeys = true; }, - { - shortHelp: "Temporarily quit Vimperator mode", - help: "Disable all Vimperator keys except <Esc> and pass them to the next event handler.
" + - "This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore.
" + - "To exit this mode, press <Esc>. If you also need to pass <Esc>" + - "in this mode to the web page, prepend it with <C-v>." - } + { shortHelp: "Temporarily quit Vimperator mode" } )); addDefaultMap(new vimperator.Map(allModes, [""], function () { vimperator.modes.passNextKey = true; }, - { - shortHelp: "Pass through next key", - help: "If you need to pass a certain key to a JavaScript form field or another extension prefix the key with <C-v>.
" + - "Also works to unshadow Firefox shortcuts like <C-o> which are otherwise hidden in Vimperator.
" + - "When Vimperator mode is temporarily disabled with <C-q>, <C-v> will pass the next key to Vimperator instead of the web page." - } + { shortHelp: "Pass through next key" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], BrowserStop, - { - shortHelp: "Stop loading", - help: "Stops loading the current web page." - } + { shortHelp: "Stop loading" } )); addDefaultMap(new vimperator.Map(allModes, [""], function () { return; }, - { - shortHelp: "Do nothing", - help: "This command is useful for disabling a specific mapping. " + - ":map <C-n> <Nop> will prevent <C-n> from doing anything." - } + { shortHelp: "Do nothing" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]f"], function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, { shortHelp: "Focus next frame", - help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red. Does not wrap.", flags: vimperator.Mappings.flags.COUNT } )); @@ -474,23 +421,20 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, { shortHelp: "Focus previous frame", - help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red. Does not wrap.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]]"], function (count) { vimperator.buffer.followDocumentRelationship("next"); }, { - shortHelp: "go to 'next' or '>' if it exists. Beep otherwise.", - help: "Opens link labeled with next or >. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.", + shortHelp: "Follow a link labeled to 'next' or '>' if it exists", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["[["], function (count) { vimperator.buffer.followDocumentRelationship("previous"); }, { - shortHelp: "go to 'prev', 'previous' or '<' if it exists. Beep otherwise.", - help: "Opens link labeled with prev, previous or <. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.", + shortHelp: "Follow a link labeled to 'prev', 'previous' or '<' if it exists", flags: vimperator.Mappings.flags.COUNT } )); @@ -502,40 +446,24 @@ vimperator.Mappings = function () //{{{ title = " -title=\"" + vimperator.buffer.title + "\""; vimperator.commandline.open(":", "bmark " + vimperator.buffer.URL + title, vimperator.modes.EX); }, - { - shortHelp: "Open a prompt to bookmark the current URL", - help: "Look at :bmark for more information." - } + { shortHelp: "Open a prompt to bookmark the current URL" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["A"], function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); }, - { - shortHelp: "Toggle bookmarked state of current URL", - help: "Add/remove a bookmark for the current location, depending if it already is bookmarked or not. " + - "In contrast to the :bmark command, the bookmark is just 'starred' " + - "which means it is placed in the 'Unfiled Bookmarks Folder' instead of the bookmarks menu." - } + { shortHelp: "Toggle bookmarked state of current URL" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["b"], function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); }, - { - shortHelp: "Open a prompt to switch buffers", - help: "Typing the corresponding number switches to this buffer." - } + { shortHelp: "Open a prompt to switch buffers" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["B"], function () { vimperator.buffer.list(true); }, - { - shortHelp: "Toggle buffer list", - help: "Toggles the display of the buffer list which shows all opened tabs.
" + - "WARNING: This mapping may be removed/changed in future." - } + { shortHelp: "Toggle buffer list" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gb"], function (count) { vimperator.buffer.switchTo(null, null, count, false); }, { shortHelp: "Repeat last :buffer[!] command", - help: "This is useful to quickly jump between buffers which have a similar URL or title.", flags: vimperator.Mappings.flags.COUNT } )); @@ -543,7 +471,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.switchTo(null, null, count, true); }, { shortHelp: "Repeat last :buffer[!] command in reverse direction", - help: "Just like gb but in the other direction.", flags: vimperator.Mappings.flags.COUNT } )); @@ -551,8 +478,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); }, { shortHelp: "Delete current buffer (=tab)", - help: "Count is supported, 2d removes the current and next tab and the one to the right is selected. " + - "Does not wrap if [count] is larger than available tabs to the right.", flags: vimperator.Mappings.flags.COUNT } )); @@ -560,40 +485,24 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); }, { shortHelp: "Delete current buffer (=tab)", - help: "Count is supported, 2D removes the current and previous tab and the one to the left is selected. " + - "Does not wrap if [count] is larger than available tabs to the left.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["~"], function () { vimperator.open("~"); }, - { - shortHelp: "Open home directory", - help: "You can also use the hints to create the probably fastest file browser on earth." - } + { shortHelp: "Open home directory" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gf"], function () { vimperator.commands.viewsource(); }, - { - shortHelp: "View source", - help: "Opens the source code of the current website with the internal editor in the current tab." - } + { shortHelp: "View source" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gF"], function () { vimperator.commands.viewsource(null, true); }, - { - shortHelp: "View source with an external editor", - help: "Opens the source code of the current website with the external editor specified " + - "by the 'editor' option. For now the external editor " + - "must be able to download and open files from a remote URL." - } + { shortHelp: "View source with an external editor" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gh"], BrowserHome, - { - shortHelp: "Go home", - help: "Opens the homepage in the current tab." - } + { shortHelp: "Go home" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gH"], function () @@ -602,11 +511,7 @@ vimperator.Mappings = function () //{{{ vimperator.open(homepages, /\bhomepage\b/.test(vimperator.options["activate"]) ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); }, - { - shortHelp: "Go home in a new tab", - help: "Opens the homepage in a new tab. " + - "Whether the new tab is activated or not depends on the 'activate' option.
" - } + { shortHelp: "Go home in a new tab" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gi"], function () @@ -624,17 +529,12 @@ vimperator.Mappings = function () //{{{ vimperator.beep(); } }, - { - shortHelp: "Focus last used input field" - } + { shortHelp: "Focus last used input field" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["go"], function (arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); }, { shortHelp: "Jump to a QuickMark in the current tab", - usage: ["go{a-zA-Z0-9}"], - help: "Open any QuickMark in the current tab. You can mark any URLs with M{a-zA-Z0-9}. " + - "These QuickMarks are persistent across browser sessions.", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -647,10 +547,6 @@ vimperator.Mappings = function () //{{{ }, { shortHelp: "Jump to a QuickMark in a new tab", - usage: ["gn{a-zA-Z0-9}"], - help: "Works like go{a-zA-Z0-9} but opens the QuickMark in a new tab. " + - "Whether the new tab is activated or not depends on the 'activate' option.
" + - "Mnemonic: Go in a new tab. gt would make more sense but is already taken.", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -661,10 +557,7 @@ vimperator.Mappings = function () //{{{ /\bpaste\b/.test(vimperator.options["activate"]) ? vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); }, - { - shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer", - help: "Works like P, but inverts the 'activate' option." - } + { shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g0", "g^"], function (count) { vimperator.tabs.select(0); }, @@ -678,7 +571,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); }, { shortHelp: "Go to the next tab", - help: "Cycles to the first tab, when the last is selected.
Count is supported: 3gt goes to the third tab.", flags: vimperator.Mappings.flags.COUNT } )); @@ -686,7 +578,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); }, { shortHelp: "Go {count} pages back", - help: "Wraps around from the first tab to the last tab.
Count is supported: 3gT goes three tabs back.", flags: vimperator.Mappings.flags.COUNT } )); @@ -711,11 +602,7 @@ vimperator.Mappings = function () //{{{ else vimperator.tabs.select(index); }, - { - shortHelp: "Select the alternate tab", - usage: [""], - help: "The alternate tab is the last selected tab. This provides a quick method of toggling between two tabs." - } + { shortHelp: "Select the alternate tab" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["m"], function (arg) @@ -730,8 +617,6 @@ vimperator.Mappings = function () //{{{ }, { shortHelp: "Set mark at the cursor position", - usage: ["m{a-zA-Z}"], - help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -739,8 +624,6 @@ vimperator.Mappings = function () //{{{ function (arg) { vimperator.marks.jumpTo(arg); }, { shortHelp: "Jump to the mark in the current buffer", - usage: ["'{a-zA-Z}"], - help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -757,32 +640,20 @@ vimperator.Mappings = function () //{{{ }, { shortHelp: "Add new QuickMark for current URL", - usage: ["M{a-zA-Z0-9}"], - help: "You can go to a marked URL in the current tab with go{a-zA-Z0-9} or in a new tab with gn{a-zA-Z0-9}. " + - "These QuickMarks are persistent across browser sessions.", flags: vimperator.Mappings.flags.ARGUMENT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["o"], function () { vimperator.commandline.open(":", "open ", vimperator.modes.EX); }, - { - shortHelp: "Open one or more URLs in the current tab", - help: "See :open for more details." - } + { shortHelp: "Open one or more URLs in the current tab" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["O"], function () { vimperator.commandline.open(":", "open " + vimperator.buffer.URL, vimperator.modes.EX); }, - { - shortHelp: "Open one or more URLs in the current tab, based on current location", - help: "Works like o, but preselects current URL in the :open query." - } + { shortHelp: "Open one or more URLs in the current tab, based on current location" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["p", ""], function () { vimperator.open(readFromClipboard()); }, - { - shortHelp: "Open (put) a URL based on the current clipboard contents in the current buffer", - help: "You can also just select (for non-X11 users: copy) some non-URL text, and search for it with the default search engine or keyword (specified by the 'defsearch' option) with p." - } + { shortHelp: "Open (put) a URL based on the current clipboard contents in the current buffer" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["P"], function () @@ -791,63 +662,41 @@ vimperator.Mappings = function () //{{{ /\bpaste\b/.test(vimperator.options["activate"]) ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); }, - { - shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer", - help: "Works like p, but opens a new tab.
" + - "Whether the new buffer is activated, depends on the 'activate' option." - } + { shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.commands.redraw(); }, { shortHelp: "Redraw the screen", - help: "Works like :redraw.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["r"], function () { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }, - { - shortHelp: "Reload", - help: "Forces reloading of the current page." - } + { shortHelp: "Reload current page" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["R"], function () { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }, - { - shortHelp: "Reload while skipping the cache", - help: "Forces reloading of the current page skipping the cache." - } + { shortHelp: "Reload while skipping the cache" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["t"], function () { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); }, - { - shortHelp: "Open one or more URLs in a new tab", - help: "Like o but open URLs in a new tab.
" + - "See :tabopen for more details." - } + { shortHelp: "Open one or more URLs in a new tab" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["T"], function () { vimperator.commandline.open(":", "tabopen " + vimperator.buffer.URL, vimperator.modes.EX); }, - { - shortHelp: "Open one or more URLs in a new tab, based on current location", - help: "Works like t, but preselects current URL in the :tabopen query." - } + { shortHelp: "Open one or more URLs in a new tab, based on current location" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["u"], function (count) { vimperator.commands.undo("", false, count); }, { shortHelp: "Undo closing of a tab", - help: "If a count is given, don't close the last but the [count]th last tab.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["y"], function () { vimperator.copyToClipboard(vimperator.buffer.URL, true); }, - { - shortHelp: "Yank current location to the clipboard", - help: "When running in X11 the location is also put into the selection, which can be pasted with the middle mouse button." - } + { shortHelp: "Yank current location to the clipboard" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL, vimperator.modes.VISUAL], ["Y"], function () @@ -858,17 +707,13 @@ vimperator.Mappings = function () //{{{ else vimperator.beep(); }, - { - shortHelp: "Copy selected text", - help: "The currently selected text is copied to the system clipboard." - } + { shortHelp: "Copy selected text" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zi", "+"], function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, false); }, { shortHelp: "Enlarge text zoom of current web page", - help: "Mnemonic: zoom in", flags: vimperator.Mappings.flags.COUNT } )); @@ -876,7 +721,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, false); }, { shortHelp: "Enlarge text zoom of current web page by a larger amount", - help: "Mnemonic: zoom more", flags: vimperator.Mappings.flags.COUNT } )); @@ -884,7 +728,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, false); }, { shortHelp: "Reduce text zoom of current web page", - help: "Mnemonic: zoom out", flags: vimperator.Mappings.flags.COUNT } )); @@ -892,7 +735,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, false); }, { shortHelp: "Reduce text zoom of current web page by a larger amount", - help: "Mnemonic: zoom reduce", flags: vimperator.Mappings.flags.COUNT } )); @@ -900,7 +742,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.textZoom = count > 1 ? count : 100; }, { shortHelp: "Set text zoom value of current web page", - help: "Zoom value can be between 1 and 2000%. If it is omitted, text zoom is reset to 100%.", flags: vimperator.Mappings.flags.COUNT } )); @@ -908,7 +749,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, true); }, { shortHelp: "Enlarge full zoom of current web page", - help: "Mnemonic: zoom in", flags: vimperator.Mappings.flags.COUNT } )); @@ -916,7 +756,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, true); }, { shortHelp: "Enlarge full zoom of current web page by a larger amount", - help: "Mnemonic: zoom more", flags: vimperator.Mappings.flags.COUNT } )); @@ -924,7 +763,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, true); }, { shortHelp: "Reduce full zoom of current web page", - help: "Mnemonic: zoom out", flags: vimperator.Mappings.flags.COUNT } )); @@ -932,7 +770,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, true); }, { shortHelp: "Reduce full zoom of current web page by a larger amount", - help: "Mnemonic: zoom reduce", flags: vimperator.Mappings.flags.COUNT } )); @@ -940,25 +777,17 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.fullZoom = count > 1 ? count : 100; }, { shortHelp: "Set full zoom value of current web page", - help: "Zoom value can be between 1 and 2000%. If it is omitted, full zoom is reset to 100%.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["ZQ"], function () { vimperator.quit(false); }, - { - shortHelp: "Quit and don't save the session", - help: "Works like :qall." - } + { shortHelp: "Quit and don't save the session" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["ZZ"], function () { vimperator.quit(true); }, - { - shortHelp: "Quit and save the session", - help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.
" + - "Works like :xall." - } + { shortHelp: "Quit and save the session" } )); function incrementURL(count) { @@ -986,7 +815,6 @@ vimperator.Mappings = function () //{{{ function (count) { incrementURL(-(count > 1 ? count : 1)); }, { shortHelp: "Decrement last number in URL", - help: "Decrements the last number in URL by 1, or by count if given.", flags: vimperator.Mappings.flags.COUNT } )); @@ -994,7 +822,6 @@ vimperator.Mappings = function () //{{{ function (count) { incrementURL(count > 1 ? count : 1); }, { shortHelp: "Increment last number in URL", - help: "Increments the last number in URL by 1, or by count if given.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1002,22 +829,16 @@ vimperator.Mappings = function () //{{{ // scrolling commands addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["0", "^"], function () { vimperator.buffer.scrollStart(); }, - { - shortHelp: "Scroll to the absolute left of the document", - help: "Unlike in Vim, 0 and ^ work exactly the same way." - } + { shortHelp: "Scroll to the absolute left of the document" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["$"], function () { vimperator.buffer.scrollEnd(); }, - { - shortHelp: "Scroll to the absolute right of the document" - } + { shortHelp: "Scroll to the absolute right of the document" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gg", ""], function (count) { vimperator.buffer.scrollToPercentile(count > 0 ? count : 0); }, { shortHelp: "Goto the top of the document", - help: "When used with [count] like in 35gg, it scrolls to 35% of the document.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1025,7 +846,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, { shortHelp: "Goto the end of the document", - help: "When used with [count] like in 35G, it scrolls to 35% of the document.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1033,8 +853,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, { shortHelp: "Scroll document to the left", - help: "Count is supported: 10h will move 10 times as much to the left.
" + - "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT } )); @@ -1042,8 +860,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, { shortHelp: "Scroll document down", - help: "Count is supported: 10j will move 10 times as much down.
" + - "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT } )); @@ -1051,8 +867,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, { shortHelp: "Scroll document up", - help: "Count is supported: 10k will move 10 times as much up.
" + - "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT } )); @@ -1060,8 +874,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollByScrollSize(count, 1); }, { shortHelp: "Scroll window downwards in the buffer", - help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + - "If [count] is given 'scroll' is first set to this value.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1069,8 +881,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollByScrollSize(count, -1); }, { shortHelp: "Scroll window upwards in the buffer", - help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + - "If [count] is given 'scroll' is first set to this value.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1078,8 +888,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, { shortHelp: "Scroll document to the right", - help: "Count is supported: 10l will move 10 times as much to the right.
" + - "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT } )); @@ -1087,7 +895,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, { shortHelp: "Scroll up a full page", - help: "Scroll window [count] pages Backwards (upwards) in the buffer.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1095,7 +902,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, { shortHelp: "Scroll down a full page", - help: "Scroll window [count] pages Forwards (downwards) in the buffer.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1105,17 +911,12 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.buffer.showPageInfo(false); }, { shortHelp: "Print the current file name", - help: "Also shows some additional file information like file size or the last modified date. " + - "If {count} is given print the current file name with full path.", flags: vimperator.Mappings.flags.COUNT } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g"], function (count) { vimperator.buffer.showPageInfo(true); }, - { - shortHelp: "Print file information", - help: "Same as :pa[geinfo]." - } + { shortHelp: "Print file information" } )); @@ -1124,7 +925,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { shortHelp: "Go to an older position in the jump list", - help: "The jump list is just the browser history for now.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1132,7 +932,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { shortHelp: "Go to a newer position in the jump list", - help: "The jump list is just the browser history for now.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1140,7 +939,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { shortHelp: "Go back in the browser history", - help: "Count is supported: 3H goes back 3 steps.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1148,7 +946,6 @@ vimperator.Mappings = function () //{{{ function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { shortHelp: "Go forward in the browser history", - help: "Count is supported: 3L goes forward 3 steps.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1193,7 +990,6 @@ vimperator.Mappings = function () //{{{ }, { shortHelp: "Go to parent directory", - help: "Count is supported: 2gu on http://www.example.com/dir1/dir2/file.htm would open http://www.example.com/dir1/.", flags: vimperator.Mappings.flags.COUNT } )); @@ -1208,44 +1004,18 @@ vimperator.Mappings = function () //{{{ } vimperator.open(uri.protocol + "//" + (uri.host || "") + "/"); }, - { - shortHelp: "Go to the root of the website", - help: "gU on http://www.example.com/dir1/dir2/file.htm opens http://www.example.com/.
" + - "When browsing a local directory, it goes to the root directory." - } + { shortHelp: "Go to the root of the website" } )); // hint managment addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["f"], function () { vimperator.hints.show(vimperator.modes.QUICK_HINT); }, - { - shortHelp: "Start QuickHint mode", - usage: ["f{hint}"], - help: "In QuickHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a unique number.
" + - "You can now either type this number or type any part of the URL which you want to follow, and it is followed as soon as it can be uniquely identified. " + - "Often it is can be useful to combine these techniques to narrow down results with some letters, and then typing a single digit to make the match unique.
" + - "Pressing <leader> (defaults to :let mapleader = \"\\\") toggles 'escape-mode', where numbers are treated as normal text.
" + - "<Esc> stops this mode at any time." - } + { shortHelp: "Start QuickHint mode" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["F"], function () { vimperator.hints.show(vimperator.modes.QUICK_HINT, "t"); }, - { - shortHelp: "Start QuickHint mode, but open link in a new tab", - usage: ["F{hint}"], - help: "Like normal QuickHint mode (activated with f) but opens the link in a new tab." - } + { shortHelp: "Start QuickHint mode, but open link in a new tab" } )); -// addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["F"], -// function () { vimperator.echo("Always HINT mode not available anymore"); }, -// { -// shortHelp: "Start AlwaysHint mode (CURRENTLY DISABLED)", -// help: "In AlwaysHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a label.
" + -// "If you then press the keys for a label, it is followed as soon as it can be uniquely identified. Labels stay active after following a hint in this mode, press <Esc> to stop this mode.
" + -// "This hint mode is especially useful for browsing large sites like Forums as hints are automatically regenerated when switching to a new document.
" + -// "Also, most Ctrl-prefixed shortcut keys are available in this mode for navigation." -// } -// )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [";"], function (arg) { @@ -1258,33 +1028,6 @@ vimperator.Mappings = function () //{{{ }, { shortHelp: "Start an extended hint mode", - usage: [";{mode}{hint}"], - help: "ExtendedHint mode is useful, since in this mode you can yank link locations, open them in a new window or save images.
" + - "If you want to yank the location of hint 24, press ;y to start this hint mode. " + - "Then press 24 to copy the hint location.

" + - "{mode} can be either one of:
" + - "
    " + - "
  • ; to focus a link and hover it with the mouse
  • " + - "
  • a to save its destination (prompting for save location)
  • " + - "
  • s to save its destination
  • " + - "
  • o to open its location in the current tab
  • " + - "
  • t to open its location in a new tab
  • " + - "
  • O to open its location in an :open query
  • " + - "
  • T to open its location in a :tabopen query
  • " + - "
  • v to view its destination source
  • " + - "
  • w to open its destination in a new window
  • " + - "
  • W to open its location in a :winopen query
  • " + - "
  • y to yank its destination location
  • " + - "
  • Y to yank its text description
  • " + - "
" + - "Additionally there are two {mode}s, which will start an AlwaysHint mode:
" + - "
    " + - "
  • f to open its location in the current tab
  • " + - "
  • F to open its location in a new tab
  • " + - "
" + - "These work like the f or F mappings but will keep you in AlwaysHint mode. " + - "This is useful if you want to open many links of one page without pressing f or F each time.
" + - "Hintable elements for all extended hint modes can be set in the 'extendedhinttags' XPath string.", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -1292,50 +1035,24 @@ vimperator.Mappings = function () //{{{ // search management addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["/"], function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_FORWARD); }, - { - shortHelp: "Search forward for a pattern", - usage: ["/{pattern}[/]"], - help: "Search forward for the first occurrence of {pattern}.
" + - "If \"\\c\" appears anywhere in the pattern the whole pattern is handled as though 'ignorecase' is on. " + - "\"\\C\" forces case-sensitive matching for the whole pattern.
" + - "If \"\\l\" appears in the pattern only the text of links is searched for a match as though 'linksearch' is on. " + - "\"\\L\" forces the entire page to be searched for a match." - } + { shortHelp: "Search forward for a pattern" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["?"], function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_BACKWARD); }, - { - shortHelp: "Search backwards for a pattern", - usage: ["?{pattern}[?]"], - help: "Search backward for the first occurrence of {pattern}.
" + - "If \"\\c\" appears anywhere in the pattern the whole pattern is handled as though 'ignorecase' is on. " + - "\"\\C\" forces case-sensitive matching for the whole pattern.
" + - "If \"\\l\" appears in the pattern only the text of links is searched for a match as though 'linksearch' is on. " + - "\"\\L\" forces the entire page to be searched for a match.
" + - "NOTE: incremental searching currently only works in the forward direction." - } + { shortHelp: "Search backwards for a pattern" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["n"], function () { vimperator.search.findAgain(false); }, - { - shortHelp: "Find next", - help: "Repeat the last search 1 time (until count is supported)." - } + { shortHelp: "Find next" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["N"], function () { vimperator.search.findAgain(true); }, - { - shortHelp: "Find previous", - help: "Repeat the last search 1 time (until count is supported) in the opposite direction." - } + { shortHelp: "Find previous" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["q"], function (arg) { vimperator.events.startRecording(arg); }, { - shortHelp: "record a keysequence into a macro", - help: "Available macros are {0-9a-zA-Z} (uppercase to append)." + - "type 'q' to stop recording.", - + shortHelp: "Record a keysequence into a macro", flags: vimperator.Mappings.flags.ARGUMENT } )); @@ -1347,7 +1064,7 @@ vimperator.Mappings = function () //{{{ vimperator.events.playMacro(arg); }, { - shortHelp: "Execute the contents of macro {0-9a-z}. @@ repeats the previous @{0-9a-z}", + shortHelp: "Play a macro", flags: vimperator.Mappings.flags.ARGUMENT | vimperator.Mappings.flags.COUNT } )); @@ -1366,10 +1083,7 @@ vimperator.Mappings = function () //{{{ } addDefaultMap(new vimperator.Map([vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["v"], function (count) { vimperator.modes.set(vimperator.modes.VISUAL, vimperator.mode); }, - { - shortHelp: "Start visual mode", - help: "Works for caret mode and textarea mode." - } + { shortHelp: "Start visual mode" } )); addDefaultMap(new vimperator.Map([vimperator.modes.CARET], ["j", ""], function (count) diff --git a/content/options.js b/content/options.js index 9858c6cb..b10aa867 100644 --- a/content/options.js +++ b/content/options.js @@ -35,15 +35,10 @@ vimperator.Option = function (names, type, extraInfo) //{{{ this.name = names[0]; this.names = names; - this.usage = this.names; this.type = type; if (extraInfo) { - if (extraInfo.usage) - this.usage = extraInfo.usage; - - this.help = extraInfo.help || null; this.shortHelp = extraInfo.shortHelp || null; // "", 0 are valid default values @@ -193,8 +188,8 @@ vimperator.Options = function () //{{{ var value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data; // Try in case it's a localized string (will throw an exception if not) if (!branch.prefIsLocked(name) && !branch.prefHasUserValue(name) && - /^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) - value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; + /^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) + value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; return value; case branch.PREF_INT: return branch.getIntPref(name); @@ -343,7 +338,6 @@ vimperator.Options = function () //{{{ list: function (onlyNondefault) { - // TODO: columns like Vim? var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + ""; var name, value, def; @@ -484,13 +478,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["activate", "act"], "stringlist", { shortHelp: "Define when tabs are automatically activated", - help: "Available items:
" + - "
    " + - "
  • homepage: gH mapping
  • " + - "
  • quickmark: go and gn mappings
  • " + - "
  • tabopen: :tabopen[!] command
  • " + - "
  • paste: P and gP mappings
  • " + - "
", defaultValue: "homepage,quickmark,tabopen,paste", validator: function (value) { @@ -501,15 +488,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["complete", "cpt"], "charlist", { shortHelp: "Items which are completed at the :[tab]open prompt", - help: "Available items:
" + - "
    " + - "
  • s: Search engines and keyword URLs
  • " + - "
  • f: Local files
  • " + - "
  • b: Bookmarks
  • " + - "
  • h: History
  • " + - "
" + - "The order is important, so :set complete=bs would list bookmarks first, and then any available quick searches.
" + - "Add 'sort' to the 'wildoptions' option if you want all entries sorted.", defaultValue: "sfbh", validator: function (value) { return !/[^sfbh]/.test(value); } } @@ -517,18 +495,12 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["defsearch", "ds"], "string", { shortHelp: "Set the default search engine", - help: "The default search engine is used in the :[tab]open [arg] command " + - "if [arg] neither looks like a URL or like a specified search engine/keyword.", defaultValue: "google" } )); optionManager.add(new vimperator.Option(["editor"], "string", { shortHelp: "Set the external text editor", - help: "Sets the editor to run when <C-i> " + - "is pressed in INSERT and TEXTAREA modes. Note that Vimperator will " + - "not behave correctly if the editor forks its own process, such as with " + - "gvim without the -f argument.", defaultValue: "gvim -f" } )); @@ -556,13 +528,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["guioptions", "go"], "charlist", { shortHelp: "Show or hide the menu, toolbar and scrollbars", - help: "Supported characters:
" + - "
    " + - "
  • m: menubar
  • " + - "
  • T: toolbar
  • " + - "
  • b: bookmark bar
  • " + - "
" + - "You can also hide the tab bar with :set showtabline=0.", setter: function (value) { setGuiOptions(value); }, defaultValue: "", validator: function (value) { return !/[^mTb]/.test(value); } @@ -571,7 +536,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["hinttimeout", "hto"], "number", { shortHelp: "Automatically follow non unique numerical hint after {arg} ms", - help: "Set to 0 (the default) to only follow numeric hints after pressing <Return> or when the hint is unique.", defaultValue: 0, validator: function (value) { return value >= 0; } } @@ -617,29 +581,18 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["incsearch", "is"], "boolean", { shortHelp: "Show where the search pattern matches as it is typed", - help: "NOTE: Incremental searching currently only works in the forward direction.", defaultValue: true } )); optionManager.add(new vimperator.Option(["insertmode", "im"], "boolean", { shortHelp: "Use Insert mode as the default for text areas", - help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " + - "Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.", defaultValue: true } )); optionManager.add(new vimperator.Option(["laststatus", "ls"], "number", { shortHelp: "Show the status line", - help: "Determines when the last window will have a status line. " + - "Possible values:
" + - "
    " + - "
  • 0: never
  • " + - "
  • 1: only if there are multiple windows
  • " + - "
  • 2: always
  • " + - "
" + - "NOTE: laststatus=1 not implemented yet.", defaultValue: 2, setter: function (value) { setLastStatus(value); }, validator: function (value) { return (value >= 0 && value <= 2); } @@ -648,7 +601,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["linksearch", "lks"], "boolean", { shortHelp: "Limit the search to hyperlink text", - help: "This includes (X)HTML elements with an \"href\" atrribute and XLink \"simple\" links.", defaultValue: false } )); @@ -661,21 +613,12 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["nextpattern"], "stringlist", { shortHelp: "Patterns to use when guessing the 'next' page in a document sequence", - help: "Each pattern, in order, is matched against all links in the page with the first match being used.
" + - "The patterns are case insensitive regular expressions.", defaultValue: "\\bnext,^>$,^(>>|»)$,^(>|»),(>|»)$" } )); optionManager.add(new vimperator.Option(["pageinfo", "pa"], "charlist", { shortHelp: "Desired info on :pa[geinfo]", - help: "Available items:
" + - "
    " + - "
  • g: general info
  • " + - "
  • f: feeds
  • " + - "
  • m: meta tags
  • " + - "
" + - "The order matters", defaultValue: "gfm", validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); } } @@ -683,15 +626,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["popups", "pps"], "number", { shortHelp: "Where to show requested popup windows", - help: "Define where to show requested popup windows. Does not apply to windows which are opened by middle clicking a link, they always open in a new tab. " + - "Possible values:
" + - "
    " + - "
  • 0: Force to open in the current tab (NOTE: this can stop some web sites from working correctly!)
  • " + - "
  • 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
  • " + - "
" + - "NOTE: This option does not change the popup blocker of Firefox in any way.", defaultValue: 1, setter: function (value) { setPopups(value); }, validator: function (value) { return (value >= 0 && value <= 3); } @@ -700,17 +634,12 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["preload"], "boolean", { shortHelp: "Speed up first time history/bookmark completion", - help: "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.
" + - "In order to also speed up first time access, it is cached at startup, if this option is set (recommended).", defaultValue: true } )); optionManager.add(new vimperator.Option(["previewheight", "pvh"], "number", { shortHelp: "Default height for preview window", - help: "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. " + - "Close the preview window with :pclose.
" + - "NOTE: Option currently disabled", defaultValue: 10, validator: function (value) { return (value >= 1 && value <= 50); } } @@ -718,17 +647,12 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["previouspattern"], "stringlist", { shortHelp: "Patterns to use when guessing the 'previous' page in a document sequence", - help: "Each pattern, in order, is matched against all links in the page with the first match being used.
" + - "The patterns are case insensitive regular expressions.", defaultValue: "\\bprev|previous\\b,^<$,^(<<|«)$,^(<|«),(<|«)$" } )); optionManager.add(new vimperator.Option(["scroll", "scr"], "number", { shortHelp: "Number of lines to scroll with C-u and C-d commands", - help: "The number of lines scrolled defaults to half the window size. " + - "When a {count} is specified to the <C-u> or <C-d> commands this is used to set the value of 'scroll' and also used for the current command. " + - "The value can be reset to half the window height with :set scroll=0.", defaultValue: 0, validator: function (value) { return value >= 0; } } @@ -742,13 +666,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["showstatuslinks", "ssli"], "number", { shortHelp: "Show the destination of the link under the cursor in the status bar", - help: "Also links which are focused by keyboard commands like <Tab> are shown. " + - "Possible values:
" + - "
    " + - "
  • 0: Don't show link destination
  • " + - "
  • 1: Show the link in the status line
  • " + - "
  • 2: Show the link in the command line
  • " + - "
", defaultValue: 1, validator: function (value) { return (value >= 0 && value <= 2); } } @@ -756,12 +673,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["showtabline", "stal"], "number", { shortHelp: "Control when to show the tab bar of opened web pages", - help: "Possible values:
" + - "
    " + - "
  • 0: Never show tab bar
  • " + - "
  • 1: Show tab bar only if more than one tab is open
  • " + - "
  • 2: Always show tab bar
  • " + - "
", setter: function (value) { setShowTabline(value); }, defaultValue: 2, validator: function (value) { return (value >= 0 && value <= 2); } @@ -770,16 +681,12 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["smartcase", "scs"], "boolean", { shortHelp: "Override the 'ignorecase' option if the pattern contains uppercase characters", - help: "This is only used if the 'ignorecase' option is set.", defaultValue: true } )); optionManager.add(new vimperator.Option(["titlestring"], "string", { shortHelp: "Change the title of the browser window", - help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + - "\"Title of web page - Vimperator\".
If you don't like that, you can restore it with: " + - ":set titlestring=Mozilla Firefox.", setter: function (value) { setTitleString(value); }, defaultValue: "Vimperator" } @@ -787,7 +694,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["usermode", "um"], "boolean", { shortHelp: "Show current website with a minimal style sheet to make it easily accessible", - help: "Note that this is a local option for now, later it may be split into a global and :setlocal part", setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; }, getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; }, defaultValue: false @@ -796,8 +702,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["verbose", "vbs"], "number", { shortHelp: "Define which type of messages are logged", - help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with :javascript!.
" + - "The highest value is 9, being the most verbose mode.", defaultValue: 0, validator: function (value) { return (value >= 0 && value <= 9); } } @@ -812,20 +716,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["wildmode", "wim"], "stringlist", { shortHelp: "Define how command line completion works", - help: "It is a comma-separated list of parts, where each part specifies " + - "what to do for each consecutive use of the completion key. The first part " + - "specifies the behavior for the first use of the completion key, the second part " + - "for the second use, etc.
" + - "These are the possible values for each part:
" + - "
--- Options ---
" + - "" + - "" + - "" + - "" + - "" + - "" + - "
''Complete only the first match
'full'Complete the next full match. After the last, the original string is used.
'longest'Complete till the longest common string.
'list'When more than one match, list all matches.
'list:full'When more than one match, list all matches and complete first match.
'list:longest'When more than one match, list all matches and complete till the longest common string.
" + - "When there is only a single match, it is fully completed regardless of the case.", defaultValue: "list:full", validator: function (value) { @@ -836,11 +726,6 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["wildoptions", "wop"], "stringlist", { shortHelp: "Change how command line completion is done", - help: "A list of words that change how command line completion is done.
" + - "Currently only one word is allowed:
" + - "" + - "" + - "
sortAlways sorts completion list, overriding the 'complete' option.
", defaultValue: "", validator: function (value) { return /^(sort|)$/.test(value); } } diff --git a/content/util.js b/content/util.js index 194c1250..396b33de 100644 --- a/content/util.js +++ b/content/util.js @@ -209,8 +209,7 @@ vimperator.util = { //{{{ }, // generates an Asciidoc help entry, "command" can also be a mapping - // TODO: must be refactored, once we get rid of command.usage - generateHelp: function (command) + generateHelp: function (command, extraHelp) { var start = "", end = ""; if (command instanceof vimperator.Command) @@ -233,27 +232,24 @@ vimperator.util = { //{{{ ret += "\n" // the usage information for the command - for (var j = 0; j < command.usage.length; j++) - { - var usage = command.usage[j].replace(/{/, "\\\\{").replace(/}/, "\\\\}"); - usage = usage.replace(/'/, "\\'").replace(/`/, "\\`"); - ret += "||" + start + usage + end + "||"; - if (command.usage[j].length > 15 || j < command.usage.length - 1) - ret += " +"; + var usage = command.names[0]; + if (command.specs) // for :commands + usage = command.specs[0]; - ret += "\n"; - } - ret += "________________________________________________________________________________\n" + usage = usage.replace(/{/, "\\\\{").replace(/}/, "\\\\}"); + usage = usage.replace(/'/, "\\'").replace(/`/, "\\`"); + ret += "||" + start + usage + end + "||"; + if (usage.length > 15) + ret += " +"; + + ret += "\n________________________________________________________________________________\n" // the actual help text if (command.shortHelp) { - ret += command.shortHelp; // the help description - if (command.help) - { - //ret += ". +\n"; - ret += ". " + command.help; // the help description - } + ret += command.shortHelp + "."; // the help description + if (extraHelp) + ret += " +\n" + extraHelp; } else ret += "Sorry, no help available"; diff --git a/content/vimperator.js b/content/vimperator.js index 775b7d61..022a81c7 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -650,7 +650,7 @@ const vimperator = (function () //{{{ if (vimperator.options.getPref("firsttime", true)) { setTimeout(function () { - vimperator.help(null, null, null, { inTab: true }); + vimperator.commands.help(); vimperator.options.setPref("firsttime", false); }, 1000); }