diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js
index 28b56928..64d44ad2 100644
--- a/chrome/content/vimperator/commands.js
+++ b/chrome/content/vimperator/commands.js
@@ -34,483 +34,6 @@ const FUNCTION = 4;
const COMPLETEFUNC = 5;
-/* all built-in :ex-commands of Vimperator
- * format:
- * [
- * 0: [all names of this command],
- * 1: usage,
- * 2: short help
- * 3: helptext
- * 4: function (arguments in this order: args, special, count, modifiers)
- * 5: completefunc
- * ]
- */
-var g_commands = [/*{{{*/
- [
- ["addo[ns]"],
- ["addo[ns]"],
- "Show available Browser Extensions and Themes",
- "You can add/remove/disable browser extensions from this dialog.
Be aware that not all Firefox extensions work, because Vimperator overrides some keybindings and changes Firefox's GUI.",
- function(args) { vimperator.commands.addons(args); },
- null
- ],
- [
- ["ba[ck]"],
- ["{count}ba[ck][!]"],
- "Go back in the browser history",
- "Count is supported, :3back goes back 3 pages in the browser history.
"+
- "The special version :back! goes to the beginning of the browser history.",
- function(args, special, count) { if(special) historyGoToBeginning(); else stepInHistory(count > 0 ? -1 * count : -1); },
- null
- ],
- [
- ["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
- ["{count}bd[elete][!]"],
- "Delete current buffer (=tab)",
- "Count WILL be supported in future releases, then :2bd removes two tabs and the one the right is selected.
Do :bdelete! to select the tab to the left after removing the current tab.",
- function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, special, 0); },
- null
- ],
- [
- ["beep"],
- ["beep"],
- "Play a system beep",
- null,
- function() { /*vimperator.*/beep(); },
- null
- ],
- [
- ["bma[dd]"],
- ["bma[dd] [-tTk] [url]"],
- "Add a bookmark",
- "If you don't add a custom title, either the title of the webpage or the URL will be taken as the title.
" +
- "Tags WILL be some mechanism to classify bookmarks. Assume, you tag a url with the tags \"linux\" and \"computer\" you'll be able to search for bookmarks containing these tags.
" +
- "You can omit the optional [url] field, so just do :bmadd to bookmark the currently loaded web page with a default title and without any tags.
" +
- " -t \"custom title\"
" +
- "The following options will be interpreted in the future:
" +
- " -T comma,separated,tag,list
"+
- " -k keyword
",
- bmadd,
- null
- ],
- [
- ["bmd[el]"],
- ["bmd[el] [-T] {url}"],
- "Delete a bookmark",
- "Deletes all bookmarks which matches the url AND the specified tags. Use <Tab> key on a regular expression to complete the url which you want to delete.
" +
- "The following options WILL be interpretted in the future:
" +
- " -T comma,separated,tag,list
",
- bmdel,
- function(filter) { return get_bookmark_completions(filter); }
- ],
- [
- ["bookm[arks]", "bm"],
- ["bm[!] [-T] {regexp}"],
- "Show bookmarks",
- "Open the preview window at the bottom of the screen for all bookmarks which match the regexp either in the title or URL.
" +
- "Close this window with :pclose or open entries with double click in the current tab or middle click in a new tab.
" +
- "The following options WILL be interpretted in the future:
" +
- " -T comma,separated,tag,list
",
- bmshow,
- function(filter) { return get_bookmark_completions(filter); }
- ],
- [
- ["b[uffer]"],
- ["b[uffer] {url|index}"],
- "Go to buffer from buffer list",
- "Argument can be either the buffer index or the full URL.",
- buffer_switch,
- function (filter) { return get_buffer_completions(filter); }
- ],
- [
- ["buffers", "files", "ls", "tabs"],
- ["buffers"],
- "Show a list of all buffers (=tabs)",
- "If the list is already shown, close the preview window.",
- toggleBufferList,
- null
- ],
- [
- ["downl[oads]", "dl"],
- ["downl[oads]"],
- "Show progress of current downloads",
- "Open the original Firefox download dialog in a new tab.
"+
- "Here, downloads can be paused, canceled and resumed.",
- function() { openURLsInNewTab("chrome://mozapps/content/downloads/downloads.xul", true); },
- null
- ],
- [
- ["ec[ho]"],
- ["ec[ho]"],
- "Display a string at the bottom of the window",
- "Echo all arguments of this command. Useful for showing informational messages.
Multiple lines WILL be seperated by \\n.",
- function(args) { vimperator.echo(args); } ,
- null
- ],
- [
- ["echoe[rr]"],
- ["echoe[rr]"],
- "Display an error string at the bottom of the window",
- "Echo all arguments of this command highlighted in red. Useful for showing important messages.
Multiple lines WILL be seperated by \\n.",
- function(args) { vimperator.echoerr(args); } ,
- null
- ],
- [
- ["exe[cute]"],
- ["exe[cute] {expr1} [ ... ]"],
- "Execute the string that results from the evaluation of {expr1} as an Ex command.",
- ":execute "echo test" would show a message with the text "test".
",
- execute,
- null
- ],
- [
- ["fo[rward]", "fw"],
- ["{count}fo[rward][!]"],
- "Go forward in the browser history",
- "Count is supported, :3forward goes forward 3 pages in the browser history.
"+
- "The special version :forward! goes to the end of the browser history.",
- function(args, special, count) { if(special) historyGoToEnd(); else stepInHistory(count > 0 ? count : 1); },
- null
- ],
- [
- ["ha[rdcopy]"],
- ["ha[rdcopy]"],
- "Print current document",
- "Open a GUI dialog where you can select the printer, number of copies, orientation, etc.",
- function() { getBrowser().contentWindow.print(); },
- null
- ],
- [
- ["h[elp]"],
- ["h[elp] {subject}"],
- "Open the help window",
- "You can jump to the specified {subject} with :help {subject}.
"+
- "Make sure you use the full vim notation when jumping to {subject}. This means:
"+
- "
:help :help for commands (: prefix):help 'complete' for settings (surrounded by ' and '):help o for mappings (no pre- or postfix):help he<Tab> will complete :help :help.",
- help,
- function(filter) { return get_help_completions(filter); }
- ],
- [
- ["hist[ory]", "hs"],
- ["hist[ory] {filter}"],
- "Show recently visited URLs",
- "Open the preview window at the bottom of the screen for all history items which match the filter string either in the title or URL."+
- "Close this window with :pclose or open entries with double click in the current tab or middle click in a new tab.",
- hsshow,
- function(filter) { return get_history_completions(filter); }
- ],
- [
- ["javas[cript]", "js"],
- ["javas[cript] {cmd}", "javascript <<{endpattern}\\n{script}\\n{endpattern}"], // \\n is changed to eval().:javascript alert('Hello world') would show a dialog box with the text \"Hello world\".:javascript <<EOF would read all the lines until a line starting with 'EOF' is found, and will eval() them.:javascript! will open the javascript console of Firefox.",
- function(args, special) {
- if (special) // open javascript console
- openURLsInNewTab("chrome://global/content/console.xul", true);
- else
- try {
- eval(args);
- } catch(e) {
- vimperator.echoerr(e.name + ": " + e.message);
- }
- },
- null
- ],
- [
- ["ma[rk]"],
- ["ma[rk] {arg}"],
- "Mark current location within the webpage",
- "Not implemented yet",
- set_location_mark,
- null
- ],
- [
- ["marks"],
- ["marks {arg}"],
- "Show all location marks of current webpage",
- "Not implemented yet",
- set_location_mark,
- null
- ],
- [
- ["o[pen]", "e[dit]"],
- ["o[pen] [url] [| url]"],
- "Open one or more URLs in the current tab",
- "Multiple URLs can be separated with the | character.:open ... with current location \"http://www.example.com/dir1/dir2/file.html\" will open \"http://www.example.com\":open ./foo.html with current location \"http://www.example.com/dir1/dir2/file.html\" will open \"http://www.example.com/dir1/dir2/foo.html\":open wikipedia linus torvalds "+
- "will open the wikipedia entry for linux torvalds).'defsearch' setting) "+
- "if the first word is no search engine (:open linus torvalds will open a google search for linux torvalds).:open www.osnews.com | www.slashdot.org will "+
- "open OSNews in the current, and Slashdot in a new background tab).:open [-T \"linux\"] torvalds<Tab> to complete bookmarks "+
- "with tag \"linux\" and which contain \"torvalds\". Note that -T support is only available for tab completion, not for the actual command.<Tab> are specified in the 'complete' option.:set!, but opens the dialog in a new window instead of a new tab. Use this, if you experience problems/crashes when using :set!",
- openPreferences,
- null
- ],
- [
- ["q[uit]"],
- ["q[uit]"],
- "Quit current tab or quit Vimperator if this was the last tab",
- "When quitting Vimperator, the session is not stored.",
- function (args) { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
- null
- ],
- [
- ["quita[ll]", "qa[ll]"],
- ["quita[ll]"],
- "Quit Vimperator",
- "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored.",
- function (args) { quit(false); },
- null
- ],
- [
- ["re[load]"],
- ["re[load][!]"],
- "Reload current page",
- "Forces reloading of the current page. If ! is given, skip the cache.",
- function(args, special) { reload(getBrowser().mCurrentTab, special); },
- null
- ],
- [
- ["reloada[ll]"],
- ["reloada[ll][!]"],
- "Reload all pages",
- "Forces reloading of all pages. If ! is given, skip the cache.",
- function(args, special) { reload_all(special); },
- null
- ],
- [
- ["res[tart]"],
- ["res[tart]"],
- "Force the browser to restart",
- "Useful when installing extenstions.",
- restart,
- null
- ],
- [
- ["sav[eas]"],
- ["sav[eas]"],
- "Save current web page to disk",
- "Open the original Firefox \"Save page as...\" dialog in a new tab.:set option and :set nooption.:set without an argument opens about:config in a new tab to change advanced Firefox options.:set! opens the GUI preference panel from Firefox in a new tab.:set option? or :set option shows the current value of the option.:set option& resets 'option' to the default value.:set option+=foo and :set option-=foo WILL add/remove foo from list options.:tab help tab opens the help in a new tab.",
- tab,
- null
- ],
- [
- ["tabn[ext]", "tn[ext]"],
- ["tabn[ext]"],
- "Switch to the next tab",
- "Cycles to the first tab, when the last is selected.",
- function(args, special, count) { vimperator.tabs.select("+1", true); },
- null
- ],
- [
- ["tabopen", "t[open]", "tabnew", "tabe[dit]"],
- ["tabopen [url] [| url]"],
- "Open one or more URLs in a new tab",
- "Like :open but open URLs in a new tab.:version!.",
- function (args, special) { if (special) openURLs("about:"); else vimperator.echo("Vimperator version: " + vimperator.ver); },
- null
- ],
- [
- ["wino[pen]", "w[open]", "wine[dit]"],
- ["wino[pen] [url] [| url]"],
- "Open an URL in a new window",
- "Not implemented yet.",
- function () { vimperator.echo("winopen not yet implemented"); },
- null
- ],
- [
- ["xa[ll]", "wqa[ll]", "wq"],
- ["wqa[ll]", "xa[ll]"],
- "Save the session and quit",
- "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.",
- function (args) { quit(true); },
- null
- ],
- [
- ["zo[om]"],
- ["zo[om] {value}"],
- "Set zoom value of the webpage",
- "{value} can be between 25 and 500%. If it is omitted, zoom is reset to 100%.",
- zoom_to,
- null
- ]
-];/*}}}*/
-
// var g_insert_mappings = [ /*{{{*/
// ["xxx", "todo"],
// [":3back goes back 3 pages in the browser history.:back! goes to the beginning of the browser history."
+ }
+ ));
+ addDefaultCommand(new Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
+ function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, special, 0); },
+ {
+ usage: ["{count}bd[elete][!]"],
+ short_help: "Delete current buffer (=tab)",
+ help: "Count WILL be supported in future releases, then :2bd removes two tabs and the one the right is selected.:bdelete! to select the tab to the left after removing the current tab."
+ }
+ ));
+ addDefaultCommand(new Command(["beep"],
+ function() { /*vimperator.*/beep(); },
+ {
+ usage: ["beep"],
+ short_help: "Play a system beep"
+ }
+ ));
+ addDefaultCommand(new Command(["bma[dd]"],
+ bmadd,
+ {
+ usage: ["bma[dd] [-tTk] [url]"],
+ short_help: "Add a bookmark",
+ help: "If you don't add a custom title, either the title of the webpage or the URL will be taken as the title.:bmadd to bookmark the currently loaded web page with a default title and without any tags.<Tab> key on a regular expression to complete the url which you want to delete.:pclose or open entries with double click in the current tab or middle click in a new tab.:execute "echo test" would show a message with the text "test".:3forward goes forward 3 pages in the browser history.:forward! goes to the end of the browser history."
+ }
+ ));
+ addDefaultCommand(new Command(["ha[rdcopy]"],
+ function() { getBrowser().contentWindow.print(); },
+ {
+ usage: ["ha[rdcopy]"],
+ short_help: "Print current document",
+ help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc."
+ }
+ ));
+ addDefaultCommand(new Command(["h[elp]"],
+ help,
+ {
+ usage: ["h[elp] {subject}"],
+ short_help: "Open the help window",
+ help: "You can jump to the specified {subject} with :help {subject}.:help :help for commands (: prefix):help 'complete' for settings (surrounded by ' and '):help o for mappings (no pre- or postfix):help he<Tab> will complete :help :help.",
+ completer: function(filter) { return get_help_completions(filter); }
+ }
+ ));
+ addDefaultCommand(new Command(["hist[ory]", "hs"],
+ hsshow,
+ {
+ usage: ["hist[ory] {filter}"],
+ short_help: "Show recently visited URLs",
+ help: "Open the preview window at the bottom of the screen for all history items which match the filter string either in the title or URL."+
+ "Close this window with :pclose or open entries with double click in the current tab or middle click in a new tab.",
+ completer: function(filter) { return get_history_completions(filter); }
+ }
+ ));
+ addDefaultCommand(new Command(["javas[cript]", "js"],
+ function(args, special)
+ {
+ if (special) // open javascript console
+ openURLsInNewTab("chrome://global/content/console.xul", true);
+ else
+ try {
+ eval(args);
+ } catch(e) {
+ vimperator.echoerr(e.name + ": " + e.message);
+ }
+ },
+ {
+ usage: ["javas[cript] {cmd}", "javascript <<{endpattern}\\n{script}\\n{endpattern}"], // \\n is changed to eval().:javascript alert('Hello world') would show a dialog box with the text \"Hello world\".:javascript <<EOF would read all the lines until a line starting with 'EOF' is found, and will eval() them.:javascript! will open the javascript console of Firefox."
+ }
+ ));
+ addDefaultCommand(new Command(["ma[rk]"],
+ set_location_mark,
+ {
+ usage: ["ma[rk] {arg}"],
+ short_help: "Mark current location within the webpage",
+ help: "Not implemented yet"
+ }
+ ));
+ addDefaultCommand(new Command(["marks"],
+ set_location_mark,
+ {
+ usage: ["marks {arg}"],
+ short_help: "Show all location marks of current webpage",
+ help: "Not implemented yet"
+ }
+ ));
+ addDefaultCommand(new Command(["o[pen]", "e[dit]"],
+ function(args, special)
+ {
+ if(args.length > 0)
+ openURLs(args);
+ else
+ {
+ if (special)
+ BrowserReloadSkipCache();
+ else
+ BrowserReload();
+ }
+ },
+ {
+ usage: ["o[pen] [url] [| url]"],
+ short_help: "Open one or more URLs in the current tab",
+ help: "Multiple URLs can be separated with the | character.:open ... with current location \"http://www.example.com/dir1/dir2/file.html\" will open \"http://www.example.com\":open ./foo.html with current location \"http://www.example.com/dir1/dir2/file.html\" will open \"http://www.example.com/dir1/dir2/foo.html\":open wikipedia linus torvalds "+
+ "will open the wikipedia entry for linux torvalds).'defsearch' setting) "+
+ "if the first word is no search engine (:open linus torvalds will open a google search for linux torvalds).:open www.osnews.com | www.slashdot.org will "+
+ "open OSNews in the current, and Slashdot in a new background tab).:open [-T \"linux\"] torvalds<Tab> to complete bookmarks "+
+ "with tag \"linux\" and which contain \"torvalds\". Note that -T support is only available for tab completion, not for the actual command.<Tab> are specified in the 'complete' option.:set!, but opens the dialog in a new window instead of a new tab. Use this, if you experience problems/crashes when using :set!"
+ }
+ ));
+ addDefaultCommand(new Command(["q[uit]"],
+ function (args) { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
+ {
+ usage: ["q[uit]"],
+ short_help: "Quit current tab or quit Vimperator if this was the last tab",
+ help: "When quitting Vimperator, the session is not stored."
+ }
+ ));
+ addDefaultCommand(new Command(["quita[ll]", "qa[ll]"],
+ function (args) { quit(false); },
+ {
+ usage: ["quita[ll]"],
+ short_help: "Quit Vimperator",
+ help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored."
+ }
+ ));
+ addDefaultCommand(new Command(["re[load]"],
+ function(args, special) { reload(getBrowser().mCurrentTab, special); },
+ {
+ usage: ["re[load][!]"],
+ short_help: "Reload current page",
+ help: "Forces reloading of the current page. If ! is given, skip the cache."
+ }
+ ));
+ addDefaultCommand(new Command(["reloada[ll]"],
+ function(args, special) { reload_all(special); },
+ {
+ usage: ["reloada[ll][!]"],
+ short_help: "Reload all pages",
+ help: "Forces reloading of all pages. If ! is given, skip the cache."
+ }
+ ));
+ addDefaultCommand(new Command(["res[tart]"],
+ restart,
+ {
+ usage: ["res[tart]"],
+ short_help: "Force the browser to restart",
+ help: "Useful when installing extenstions."
+ }
+ ));
+ addDefaultCommand(new Command(["sav[eas]"],
+ function() { goDoCommand('Browser:SavePage'); },
+ {
+ usage: ["sav[eas]"],
+ short_help: "Save current web page to disk",
+ help: "Open the original Firefox \"Save page as...\" dialog in a new tab.:set option and :set nooption.:set without an argument opens about:config in a new tab to change advanced Firefox options.:set! opens the GUI preference panel from Firefox in a new tab.:set option? or :set option shows the current value of the option.:set option& resets 'option' to the default value.:set option+=foo and :set option-=foo WILL add/remove foo from list options.:tab help tab opens the help in a new tab."
+ }
+ ));
+ addDefaultCommand(new Command(["tabn[ext]", "tn[ext]"],
+ function(args, special, count) { vimperator.tabs.select("+1", true); },
+ {
+ usage: ["tabn[ext]"],
+ short_help: "Switch to the next tab",
+ help: "Cycles to the first tab, when the last is selected."
+ }
+ ));
+ addDefaultCommand(new Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
+ function (args, special) { if (args.length > 0) openURLsInNewTab(args, !special); else openURLsInNewTab("about:blank", true); },
+ {
+ usage: ["tabopen [url] [| url]"],
+ short_help: "Open one or more URLs in a new tab",
+ help: "Like :open but open URLs in a new tab.:version!."
+ }
+ ));
+ addDefaultCommand(new Command(["wino[pen]", "w[open]", "wine[dit]"],
+ function () { vimperator.echo("winopen not yet implemented"); },
+ {
+ usage: ["wino[pen] [url] [| url]"],
+ short_help: "Open an URL in a new window",
+ help: "Not implemented yet."
+ }
+ ));
+ addDefaultCommand(new Command(["xa[ll]", "wqa[ll]", "wq"],
+ function (args) { quit(true); },
+ {
+ usage: ["wqa[ll]", "xa[ll]"],
+ short_help: "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."
+ }
+ ));
+ addDefaultCommand(new Command(["zo[om]"],
+ zoom_to,
+ {
+ usage: ["zo[om] {value}"],
+ short_help: "Set zoom value of the webpage",
+ help: "{value} can be between 25 and 500%. If it is omitted, zoom is reset to 100%."
+ }
+ ));
+//}}}
+}//}}}
function execute_command(count, cmd, special, args, modifiers) // {{{
{
@@ -650,22 +741,23 @@ function execute_command(count, cmd, special, args, modifiers) // {{{
if (!modifiers)
modifiers = {};
- var command = get_command(cmd);
+ var command = vimperator.commands.get(cmd);
if (command === null)
{
vimperator.echoerr("E492: Not an editor command: " + cmd);
vimperator.focusContent();
return;
}
-
- if (command[FUNCTION] === null)
+
+ // TODO: need to perform this test? -- djk
+ if (command.action === null)
{
- vimperator.echoerr("E666: Internal error: command[FUNCTION] === null");
+ vimperator.echoerr("E666: Internal error: command.action === null");
return;
}
// valid command, call it:
- command[FUNCTION].call(this, args, special, count, modifiers);
+ command.execute(args, special, count, modifiers);
} // }}}
@@ -852,7 +944,7 @@ function stringToURLs(str)
if (matches && matches[3] && matches[3].length >= 1)
text = matches[3];
- var search_url = vimperator.bookmarks.getSearchURL(text, alias);
+ var search_url = vimperator.bookmarks.getSearchURL(text, alias);
if (search_url && search_url.length >= 1)
{
urls[url] = search_url;
@@ -875,7 +967,7 @@ function stringToURLs(str)
return urls;
}
-/* returns true if the currently loaded URI is
+/* returns true if the currently loaded URI is
* a directory or false if it is a file
*/
function isDirectory(url)
@@ -914,10 +1006,10 @@ function focusNextFrame(count)
beep();
return;
}
-
+
var w = document.commandDispatcher.focusedWindow;
var next = 0;
-
+
// Find the next frame to focus
for (var i=0; iWhat is the meaning of life, the universe and everything?
' +
diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js
index a7fe73b2..b14b6862 100644
--- a/chrome/content/vimperator/mappings.js
+++ b/chrome/content/vimperator/mappings.js
@@ -91,7 +91,7 @@ function Mappings()//{{{
}
}
- var mappingsIterator = function(mode)
+ function mappingsIterator(mode)
{
var mappings;