1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-23 10:55:46 +01:00

finish converting the mappings to the new Map() format

This commit is contained in:
Doug Kearns
2007-05-28 16:49:16 +00:00
parent 7f3f8f861b
commit e834bc7dd7

View File

@@ -22,10 +22,10 @@ function Map(mode, cmd, action, extra_info)
if (extra_info.help) if (extra_info.help)
this.help = extra_info.help; this.help = extra_info.help;
if (extra_info.short) if (extra_info.short_help)
this.short = extra_info.short; this.short_help = extra_info.short_help;
this.execute: function() { this.execute = function() {
this.cmd.call(this); this.cmd.call(this);
} }
} }
@@ -35,12 +35,12 @@ function Mappings()
this.main = []; this.main = [];
this.user = []; this.user = [];
this.flags = { this.flags = {
MOTION: 1 << 1; MOTION: 1 << 1,
COUNT: 1 << 2; COUNT: 1 << 2,
ARGUMENT: 1 << 3; ARGUMENT: 1 << 3
}; };
this.add: function(map) this.add = function(map)
{ {
if (!map) return; if (!map) return;
if (!this.user[map.mode]) if (!this.user[map.mode])
@@ -50,7 +50,7 @@ function Mappings()
return this; return this;
} }
this.remove: function(map) this.remove = function(map)
{ {
var index; var index;
@@ -61,7 +61,7 @@ function Mappings()
return this; return this;
} }
this.get: function(mode, cmd) this.get = function(mode, cmd)
{ {
if (!mode || !cmd) return; if (!mode || !cmd) return;
var map = getFrom(mode, cmd, this.user); var map = getFrom(mode, cmd, this.user);
@@ -89,416 +89,419 @@ function Mappings()
for (var i = 0; i < stack_length; i++) for (var i = 0; i < stack_length; i++)
{ {
for (var j = 0; j < substack[i].cmd.length; j++) for (var j = 0; j < substack[i].cmd.length; j++)
if (substack[i].cmd[j] == cmd) if (substack[i].cmd[j] == cmd)
return substack[i]; return substack[i];
} }
} }
/* Default mappings /* Default mappings
* Normal mode * Normal mode
* */ * */
addDefaults(new Map(vimperator.mode.NORMAL, ["]f"], focusNextFrame, {short: "Focus next frame", help: addDefaults(new Map(vimperator.mode.NORMAL, ["]f"], focusNextFrame,
"Flashes the next frame in order with a red color, to quickly show where keyboard focus is.<br/>"+ {
"This may not work correctly for frames with lots of CSS code." short_help: "Focus next frame",
})); help: "Flashes the next frame in order with a red color, to quickly show where keyboard focus is.<br/>" +
addDefaults(new Map(vimperator.mode.NORMAL, ["b"], function (args) { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); }, { "This may not work correctly for frames with lots of CSS code."
short: "Open a prompt to switch buffers", help: }
"Typing the corresponding number opens switches to this buffer." ));
})); addDefaults(new Map(vimperator.mode.NORMAL, ["b"], function (args) { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); },
addDefaults(new Map(vimperator.mode.NORMAL, ["B"], toggleBufferList, {short: "Toggle buffer list", help: {
"Toggles the display of the buffer list which shows all opened tabs." short_help: "Open a prompt to switch buffers",
})); help: "Typing the corresponding number opens switches to this buffer."
addDefaults(new Map(vimperator.mode.NORMAL, ["d"], function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); }, { }
short: "Delete current buffer (=tab)", flags: this.flags.COUNT, help: ));
"Count WILL be supported in future releases, then <code class=\"mapping\">2d</code> removes two tabs and the one the right is selected." addDefaults(new Map(vimperator.mode.NORMAL, ["B"], toggleBufferList,
})); {
addDefaults(new Map(vimperator.mode.NORMAL, ["D"], function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); }, { short_help: "Toggle buffer list",
short: "Delete current buffer (=tab)", flags: this.flags.COUNT, help: help: "Toggles the display of the buffer list which shows all opened tabs."
"Count WILL be supported in future releases, then <code class=\"mapping\">2d</code> removes two tabs and the one the right is selected." }
})); ));
addDefaults(new Map(vimperator.mode.NORMAL, ["gh"], BrowserHome, {short: "Go home", help: addDefaults(new Map(vimperator.mode.NORMAL, ["d"], function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
"Opens the homepage in the current tab." {
})); short_help: "Delete current buffer (=tab)",
addDefaults(new Map(vimperator.mode.NORMAL, ["gH"], BrowserHome, {short: "Go home in a new tab", help: help: "Count WILL be supported in future releases, then <code class=\"mapping\">2d</code> removes two tabs and the one the right is selected.",
"Opens the homepage in a new tab." flags: this.flags.COUNT
})); }
addDefaults(new Map(vimperator.mode.NORMAL, ["gP"], function(count) { openURLsInNewTab(readFromClipboard(), false); }, { ));
short: "Open (put) an URL based on the current clipboard contents in a new buffer", addDefaults(new Map(vimperator.mode.NORMAL, ["D"], function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); },
help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"setting\">'activate'</code> setting." {
})); short_help: "Delete current buffer (=tab)",
addDefaults(new Map(vimperator.mode.NORMAL, ["gt", "<C-n>", "<C-Tab>"], help: "Count WILL be supported in future releases, then <code class=\"mapping\">2d</code> removes two tabs and the one the right is selected.",
function(count) { vimperator.tabs.select(count > 0 ? count -1: "+1", count > 0 ? false : true); }, { flags: this.flags.COUNT
short: "Go to the next tab", flags: this.flags.COUNT, }
help: "Cycles to the first tab, when the last is selected.<br/>Count is supported, <code class=\"mapping\">3gt</code> goes to the third tab." ));
})); addDefaults(new Map(vimperator.mode.NORMAL, ["gh"], BrowserHome,
addDefaults(new Map(vimperator.mode.NORMAL, ["gT", "<C-p>", "<C-S-Tab>"], {
function(count) { vimperator.tabs.select(count > 0 ? count -1: "-1", count > 0 ? false : true); }, { short_help: "Go home",
short: "Go to the previous tab", flags: this.flags.COUNT, help: "Opens the homepage in the current tab."
help: "Cycles to the last tab, when the first is selected.<br/>Count is supported, <code class=\"mapping\">3gT</code> goes to the third tab." }
})); ));
addDefaults(new Map(vimperator.mode.NORMAL, ["m"], set_location_mark, {short: "Set mark at the cursor position", usage: "m{a-zA-Z}", addDefaults(new Map(vimperator.mode.NORMAL, ["gH"], BrowserHome,
help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers", flags: this.flags.ARGUMENT {
})); short_help: "Go home in a new tab",
addDefaults(new Map(vimperator.mode.NORMAL, ["o"], function(count) { vimperator.commandline.open(":", "open ", vimperator.modes.EX) }, { help: "Opens the homepage in a new tab."
short: "Open one or more URLs in the current tab", }
help: "See <code class=\"command\">:open</code> for more details." ));
})); addDefaults(new Map(vimperator.mode.NORMAL, ["gP"], function(count) { openURLsInNewTab(readFromClipboard(), false); },
addDefaults(new Map(vimperator.mode.NORMAL, ["O"], {
function(count) { vimperator.commandline.open(":", "open " + getCurrentLocation(), vimperator.modes.EX); }, { short_help: "Open (put) an URL based on the current clipboard contents in a new buffer",
short: "Open one ore more URLs in the current tab, based on current location", help: "Works like <code class=\"mapping\">P</code>, but inverts the <code class=\"setting\">'activate'</code> setting."
help: "Works like <code class=\"mapping\">o</code>, but preselects current URL in the <code class=\"command\">:open</code> query." }
})); ));
addDefaults(new Map(vimperator.mode.NORMAL, ["p", "<MiddleMouse>"], addDefaults(new Map(vimperator.mode.NORMAL, ["gt", "<C-n>", "<C-Tab>"], function(count) { vimperator.tabs.select(count > 0 ? count -1: "+1", count > 0 ? false : true); },
function(count) { openURLs(readFromClipboard()); }, { {
short: "Open (put) an URL based on the current clipboard contents in the current buffer", short_help: "Go to the next tab",
help: "You can also just select some non-URL text, and search for it with the default search engine or keyword (specified by the <code class=\"setting\">'defsearch'</code> setting) with <code class=\"mapping\">p</code>." help: "Cycles to the first tab, when the last is selected.<br/>Count is supported, <code class=\"mapping\">3gt</code> goes to the third tab.",
})); flags: this.flags.COUNT
addDefaults(new Map(vimperator.mode.NORMAL, ["P"], }
function(count) { openURLsInNewTab(readFromClipboard(), true); }, { ));
short: "Open (put) an URL based on the current clipboard contents in a new buffer", addDefaults(new Map(vimperator.mode.NORMAL, ["gT", "<C-p>", "<C-S-Tab>"], function(count) { vimperator.tabs.select(count > 0 ? count -1: "-1", count > 0 ? false : true); },
help: "Works like <code class=\"mapping\">p</code>, but opens a new tab.<br/>" + {
"Whether the new buffer is activated, depends on the <code class=\"setting\">'activate'</code> setting." short_help: "Go to the previous tab",
})); help: "Cycles to the last tab, when the first is selected.<br/>Count is supported, <code class=\"mapping\">3gT</code> goes to the third tab.",
addDefaults(new Map(vimperator.mode.NORMAL, ["r"], function(count) { reload(getBrowser().mCurrentTab, false); }, { flags: this.flags.COUNT
short: "Reload", help: "Forces reloading of the current page." }
})); ));
addDefaults(new Map(vimperator.mode.NORMAL, ["R"], function(count) { reload(getBrowser().mCurrentTab, true); }, { addDefaults(new Map(vimperator.mode.NORMAL, ["m"], set_location_mark,
short: "Reload while skipping the cache", help: "Forces reloading of the current page skipping the cache." {
})); short_help: "Set mark at the cursor position", usage: "m{a-zA-Z}",
addDefaults(new Map(vimperator.mode.NORMAL, ["t"], function(count) { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); }, { help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers",
short: "Open one or more URLs in a new tab", flags: this.flags.ARGUMENT
help: "Like <code class=\"mapping\">o</code> but open URLs in a new tab.<br/>"+ }
"See <code class=\"command\">:tabopen</code> for more details." ));
})); addDefaults(new Map(vimperator.mode.NORMAL, ["o"], function(count) { vimperator.commandline.open(":", "open ", vimperator.modes.EX); },
addDefaults(new Map(vimperator.mode.NORMAL, ["T"], {
function(count) { vimperator.commandline.open(":", "tabopen " + getCurrentLocation(), vimperator.modes.EX); }, { short_help: "Open one or more URLs in the current tab",
short: "Open one ore more URLs in a new tab, based on current location", help: "See <code class=\"command\">:open</code> for more details."
help: "Works like <code class=\"mapping\">t</code>, but preselects current URL in the <code class=\"command\">:tabopen</code> query.", }
})); ));
addDefaults(new Map(vimperator.mode.NORMAL, ["O"], function(count) { vimperator.commandline.open(":", "open " + getCurrentLocation(), vimperator.modes.EX); },
var normal_maps = [ {
[ short_help: "Open one ore more URLs in the current tab, based on current location",
["u"], help: "Works like <code class=\"mapping\">o</code>, but preselects current URL in the <code class=\"command\">:open</code> query."
["{count}u"], }
"Undo closing of a tab", ));
"If a count is given, don't close the last but the n'th last tab.", addDefaults(new Map(vimperator.mode.NORMAL, ["p", "<MiddleMouse>"], function(count) { openURLs(readFromClipboard()); },
function(count) { execute_command(count, 'undo', false, ''); }, {
this.flags.COUNT short_help: "Open (put) an URL based on the current clipboard contents in the current buffer",
], help: "You can also just select some non-URL text, and search for it with the default search engine or keyword (specified by the <code class=\"setting\">'defsearch'</code> setting) with <code class=\"mapping\">p</code>."
[ }
["y"], ));
["y"], addDefaults(new Map(vimperator.mode.NORMAL, ["P"], function(count) { openURLsInNewTab(readFromClipboard(), true); },
"Yank current location to the clipboard", {
"Under UNIX the location is also put into the selection, which can be pasted with the middle mouse button.", short_help: "Open (put) an URL based on the current clipboard contents in a new buffer",
yankCurrentLocation help: "Works like <code class=\"mapping\">p</code>, but opens a new tab.<br/>" +
], "Whether the new buffer is activated, depends on the <code class=\"setting\">'activate'</code> setting."
[ }
["Y"], ));
["Y"], addDefaults(new Map(vimperator.mode.NORMAL, ["r"], function(count) { reload(getBrowser().mCurrentTab, false); },
"Copy selected text", {
"The currently selected text is copied to the system clipboard.", short_help: "Reload",
yankCurrentSelection, help: "Forces reloading of the current page."
null }
], ));
[ addDefaults(new Map(vimperator.mode.NORMAL, ["R"], function(count) { reload(getBrowser().mCurrentTab, true); },
["zi", "+"], {
["zi", "+"], short_help: "Reload while skipping the cache",
"Zoom in current web page by 25%", help: "Forces reloading of the current page skipping the cache."
"Currently no count supported.", }
function(count) { zoom_in(1); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["t"], function(count) { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); },
[ {
["zI"], short_help: "Open one or more URLs in a new tab",
["zI"], help: "Like <code class=\"mapping\">o</code> but open URLs in a new tab.<br/>" +
"Zoom in current web page by 100%", "See <code class=\"command\">:tabopen</code> for more details."
"Currently no count supported.", }
function(count) { zoom_in(4); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["T"], function(count) { vimperator.commandline.open(":", "tabopen " + getCurrentLocation(), vimperator.modes.EX); },
[ {
["zo", "-"], short_help: "Open one ore more URLs in a new tab, based on current location",
["zo", "-"], help: "Works like <code class=\"mapping\">t</code>, but preselects current URL in the <code class=\"command\">:tabopen</code> query."
"Zoom out current web page by 25%", }
"Currently no count supported.", ));
function(count) { zoom_in(-1); } addDefaults(new Map(vimperator.mode.NORMAL, ["u"], function(count) { execute_command(count, 'undo', false, ''); },
], {
[ short_help: "Undo closing of a tab",
["zO"], help: "If a count is given, don't close the last but the n'th last tab.",
["zO"], flags: this.flags.COUNT
"Zoom out current web page by 100%", }
"Currently no count supported.", ));
function(count) { zoom_in(-4); } addDefaults(new Map(vimperator.mode.NORMAL, ["y"], yankCurrentLocation,
], {
[ short_help: "Yank current location to the clipboard",
["zz"], help: "Under UNIX the location is also put into the selection, which can be pasted with the middle mouse button."
["{count}zz"], }
"Set zoom value of the webpage", ));
"Zoom value can be between 25 and 500%. If it is omitted, zoom is reset to 100%.", addDefaults(new Map(vimperator.mode.NORMAL, ["Y"], yankCurrentSelection,
zoom_to, {
this.flags.COUNT short_help: "Copy selected text",
], help: "The currently selected text is copied to the system clipboard."
[ }
["ZQ"], ));
["ZQ"], addDefaults(new Map(vimperator.mode.NORMAL, ["zi", "+"], function(count) { zoom_in(1); },
"Quit and don't save the session", {
"Works like <code class=\"command\">:qall</code>.", short_help: "Zoom in current web page by 25%",
function(count) { quit(false); } help: "Currently no count supported."
], }
[ ));
["ZZ"], addDefaults(new Map(vimperator.mode.NORMAL, ["zI"], function(count) { zoom_in(4); },
["ZZ"], {
"Quit and save the session", short_help: "Zoom in current web page by 100%",
"Quit Vimperator, no matter how many tabs/windows are open. The session is stored.<br/>" + help: "Currently no count supported."
"Works like <code class=\"command\">:xall</code>.", }
function(count) { quit(true); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["zo", "-"], function(count) { zoom_in(-1); },
{
short_help: "Zoom out current web page by 25%",
help: "Currently no count supported."
}
));
addDefaults(new Map(vimperator.mode.NORMAL, ["zO"], function(count) { zoom_in(-4); },
{
short_help: "Zoom out current web page by 100%",
help: "Currently no count supported."
}
));
addDefaults(new Map(vimperator.mode.NORMAL, ["zz"], zoom_to,
{
short_help: "Set zoom value of the webpage",
help: "Zoom value can be between 25 and 500%. If it is omitted, zoom is reset to 100%.",
flags: this.flags.COUNT
}
));
addDefaults(new Map(vimperator.mode.NORMAL, ["ZQ"], function(count) { quit(false); },
{
short_help: "Quit and don't save the session",
help: "Works like <code class=\"command\">:qall</code>."
}
));
addDefaults(new Map(vimperator.mode.NORMAL, ["ZZ"], function(count) { quit(true); },
{
short_help: "Quit and save the session",
help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.<br/>" + "Works like <code class=\"command\">:xall</code>."
}
));
/* scrolling commands */ /* scrolling commands */
[ addDefaults(new Map(vimperator.mode.NORMAL, ["0", "^"], function(count) { scrollBufferAbsolute(0, -1); },
["0", "^"], {
["0", "^"], short_help: "Scroll to the absolute left of the document",
"Scroll to the absolute left of the document", help: "Unlike in vim, <code class=\"mapping\">0</code> and <code class=\"mapping\">^</code> work exactly the same way."
"Unlike in vim, <code class=\"mapping\">0</code> and <code class=\"mapping\">^</code> work exactly the same way.", }
function(count) { scrollBufferAbsolute(0, -1); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["$"], function(count) { scrollBufferAbsolute(100, -1); },
[ {
["$"], short_help: "Scroll to the absolute right of the document",
["$"], help: null
"Scroll to the absolute right of the document", }
null, ));
function(count) { scrollBufferAbsolute(100, -1); } addDefaults(new Map(vimperator.mode.NORMAL, ["gg", "<Home>"], function(count) { scrollBufferAbsolute(-1, count > 0 ? count : 0); },
], {
[ short_help: "Goto the top of the document",
["gg", "<Home>"], help: "Count is supported, <code class=\"mapping\">35gg</code> vertically goes to 35% of the document.",
["{count}gg", "{count}<Home>"], flags: this.flags.COUNT
"Goto the top of the document", }
"Count is supported, <code class=\"mapping\">35gg</code> vertically goes to 35% of the document.", ));
function(count) { scrollBufferAbsolute(-1, count > 0 ? count : 0); }, addDefaults(new Map(vimperator.mode.NORMAL, ["G", "<End>"], function(count) { scrollBufferAbsolute(-1, count >= 0 ? count : 100); },
this.flags.COUNT {
], short_help: "Goto the end of the document",
[ help: "Count is supported, <code class=\"mapping\">35G</code> vertically goes to 35% of the document.",
["G", "<End>"], flags: this.flags.COUNT
["{count}G", "{count}<End>"], }
"Goto the end of the document", ));
"Count is supported, <code class=\"mapping\">35G</code> vertically goes to 35% of the document.", addDefaults(new Map(vimperator.mode.NORMAL, ["h", "<Left>"], function(count) { scrollBufferRelative(-1, 0); },
function(count) { scrollBufferAbsolute(-1, count >= 0 ? count : 100); }, {
this.flags.COUNT short_help: "Scroll document to the left",
], help: "Count is supported: <code class=\"mapping\">10h</code> will move 10 times as much to the left.<br/>" +
[ "If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).",
["h", "<Left>"], flags: this.flags.COUNT
["{count}h", "{count}<Left>"], }
"Scroll document to the left", ));
"Count is supported: <code class=\"mapping\">10h</code> will move 10 times as much to the left.<br/>"+ addDefaults(new Map(vimperator.mode.NORMAL, ["j", "<Down>", "<C-e>"], function(count) { scrollBufferRelative(0, 1); },
"If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).", {
function(count) { scrollBufferRelative(-1, 0); }, short_help: "Scroll document down",
this.flags.COUNT help: "Count is supported: <code class=\"mapping\">10j</code> will move 10 times as much down.<br/>" +
], "If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).",
[ flags: this.flags.COUNT
["j", "<Down>", "<C-e>"], }
["{count}j", "{count}<Down>", "{count}<C-e>"], ));
"Scroll document down", addDefaults(new Map(vimperator.mode.NORMAL, ["k", "<Up>", "<C-y>"], function(count) { scrollBufferRelative(0, -1); },
"Count is supported: <code class=\"mapping\">10j</code> will move 10 times as much down.<br/>"+ {
"If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).", short_help: "Scroll document up",
function(count) { scrollBufferRelative(0, 1); }, help: "Count is supported: <code class=\"mapping\">10k</code> will move 10 times as much up.<br/>" +
this.flags.COUNT "If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).",
], flags: this.flags.COUNT
[ }
["k", "<Up>", "<C-y>"], ));
["{count}k", "{count}<Up>", "{count}<C-y>"], addDefaults(new Map(vimperator.mode.NORMAL, ["l", "<Right>"], function(count) { scrollBufferRelative(1, 0); },
"Scroll document up", {
"Count is supported: <code class=\"mapping\">10k</code> will move 10 times as much up.<br/>"+ short_help: "Scroll document to the right",
"If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).", help: "Count is supported: <code class=\"mapping\">10l</code> will move 10 times as much to the right.<br/>" +
function(count) { scrollBufferRelative(0, -1); }, "If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).",
this.flags.COUNT flags: this.flags.COUNT
], }
[ ));
["l", "<Right>"], addDefaults(new Map(vimperator.mode.NORMAL, ["<C-b>", "<C-u>", "<PageUp>", "<S-Space>"], function(count) { goDoCommand('cmd_scrollPageUp'); },
["{count}l", "{count}<Right>"], {
"Scroll document to the right", short_help: "Scroll up a full page of the current document",
"Count is supported: <code class=\"mapping\">10l</code> will move 10 times as much to the right.<br/>"+ help: "No count support for now."
"If the document cannot scroll more, a beep is emmited (unless <code class=\"setting\">'beep'</code> is turned off).", }
function(count) { scrollBufferRelative(1, 0); }, ));
this.flags.COUNT addDefaults(new Map(vimperator.mode.NORMAL, ["<C-f>", "<C-d>", "<PageDown>", "<Space>"], function(count) { goDoCommand('cmd_scrollPageDown'); },
], {
[ short_help: "Scroll down a full page of the current document",
["<C-b>", "<C-u>", "<PageUp>", "<S-Space>"], help: "No count support for now,"
["<C-b>"], }
"Scroll up a full page of the current document", ));
"No count support for now.",
function(count) { goDoCommand('cmd_scrollPageUp'); }
],
[
["<C-f>", "<C-d>", "<PageDown>", "<Space>"],
["<C-f>"],
"Scroll down a full page of the current document",
"No count support for now,",
function(count) { goDoCommand('cmd_scrollPageDown'); }
],
/* history manipulation and jumplist */ /* history manipulation and jumplist */
[ addDefaults(new Map(vimperator.mode.NORMAL, ["<C-o>"], function(count) { stepInHistory(count > 0 ? -1 * count : -1); },
["<C-o>"], {
["{count}<C-o>"], short_help: "Go to an older position in the jump list",
"Go to an older position in the jump list", help: "The jump list is just the browser history for now",
"The jump list is just the browser history for now", flags: this.flags.COUNT
function(count) { stepInHistory(count > 0 ? -1 * count : -1); }, }
this.flags.COUNT ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["<C-i>"], function(count) { stepInHistory(count > 0 ? count : 1); },
[ {
["<C-i>"], short_help: "Go to a newer position in the jump list",
["{count}<C-i>"], help: "The jump list is just the browser history for now",
"Go to a newer position in the jump list", flags: this.flags.COUNT
"The jump list is just the browser history for now", }
function(count) { stepInHistory(count > 0 ? count : 1); }, ));
this.flags.COUNT addDefaults(new Map(vimperator.mode.NORMAL, ["H", "<A-Left>", "<M-Left>"], function(count) { stepInHistory(count > 0 ? -1 * count : -1); },
], {
[ short_help: "Go back in the browser history",
["H", "<A-Left>", "<M-Left>"], help: "Count is supported, <code class=\"mapping\">3H</code> goes back 3 steps.",
["{count}H", "{count}<A-Left>", "{count}<M-Left>"], flags: this.flags.COUNT
"Go back in the browser history", }
"Count is supported, <code class=\"mapping\">3H</code> goes back 3 steps.", ));
function(count) { stepInHistory(count > 0 ? -1 * count : -1); }, addDefaults(new Map(vimperator.mode.NORMAL, ["L", "<A-Right>", "<M-Right>"], function(count) { stepInHistory(count > 0 ? count : 1); },
this.flags.COUNT {
], short_help: "Go forward in the browser history",
[ help: "Count is supported, <code class=\"mapping\">3L</code> goes forward 3 steps.",
["L", "<A-Right>", "<M-Right>"], flags: this.flags.COUNT
["{count}L", "{count}<A-Right>", "{count}<M-Right>"], }
"Go forward in the browser history", ));
"Count is supported, <code class=\"mapping\">3L</code> goes forward 3 steps.", addDefaults(new Map(vimperator.mode.NORMAL, ["gu", "<BS>"], goUp,
function(count) { stepInHistory(count > 0 ? count : 1); }, {
this.flags.COUNT short_help: "Go to parent directory",
], help: "Count is supported, <code class=\"mapping\">2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>.",
[ flags: this.flags.COUNT
["gu", "<BS>"], }
["{count}gu", "{count}<BS>"], ));
"Go to parent directory", addDefaults(new Map(vimperator.mode.NORMAL, ["gU", "<C-BS>"], function(count) { openURLs("..."); },
"Count is supported, <code class=\"mapping\">2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>.", {
goUp, short_help: "Go to the root of the website",
this.flags.COUNT help: "<code class=\"mapping\">gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>" +
], "When browsing a local directory, it goes to the root document."
[ }
["gU", "<C-BS>"], ));
["gU", "<C-BS>"],
"Go to the root of the website",
"<code class=\"mapping\">gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>"+
"When browsing a local directory, it goes to the root document.",
function(count) { openURLs("..."); }
],
/* hint managment */ /* hint managment */
[ addDefaults(new Map(vimperator.mode.NORMAL, ["f"], function(count) { hah.enableHahMode(vimperator.modes.QUICK_HINT); },
["f"], {
["f"], short_help: "Start QuickHint mode",
"Start QuickHint mode", help: "In QuickHint mode, every hintable item (according to the <code class=\"setting\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
"In QuickHint mode, every hintable item (according to the <code class=\"setting\">'hinttags'</code> XPath query) is assigned a label.<br/>"+ "If you then press the keys for a label, it is followed as soon as it can be uniquely identified and this mode is stopped. Or press <code class=\"mapping\">&lt;Esc&gt;</code> to stop this mode.<br/>" +
"If you then press the keys for a label, it is followed as soon as it can be uniquely identified and this mode is stopped. Or press <code class=\"mapping\">&lt;Esc&gt;</code> to stop this mode.<br/>"+ "If you write the hint in ALLCAPS, the hint is followed in a background tab."
"If you write the hint in ALLCAPS, the hint is followed in a background tab.", }
function(count) { hah.enableHahMode(vimperator.modes.QUICK_HINT); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["F"], function(count) { hah.enableHahMode(vimperator.modes.ALWAYS_HINT); },
[ {
["F"], short_help: "Start AlwaysHint mode",
["F"], help: "In AlwaysHint mode, every hintable item (according to the <code class=\"setting\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
"Start AlwaysHint mode", "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 <code class=\"mapping\">&lt;Esc&gt;</code> to stop this mode.<br/>" +
"In AlwaysHint mode, every hintable item (according to the <code class=\"setting\">'hinttags'</code> XPath query) is assigned a label.<br/>"+ "This hint mode is especially useful for browsing large sites like Forums as hints are automatically regenerated when switching to a new document.<br/>" +
"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 <code class=\"mapping\">&lt;Esc&gt;</code> to stop this mode.<br/>"+ "Also, most <code class=\"mapping\">Ctrl</code>-prefixed short_helpcut keys are available in this mode for navigation."
"This hint mode is especially useful for browsing large sites like Forums as hints are automatically regenerated when switching to a new document.<br/>"+ }
"Also, most <code class=\"mapping\">Ctrl</code>-prefixed shortcut keys are available in this mode for navigation.", ));
function(count) { hah.enableHahMode(vimperator.modes.ALWAYS_HINT); } addDefaults(new Map(vimperator.mode.NORMAL, [";"], function(count) { hah.enableHahMode(vimperator.modes.EXTENDED_HINT); },
], {
[ short_help: "Start ExtendedHint mode",
[";"], help: "ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.<br/>" +
[";"], "E.g., if you want to yank the location of hint <code>AB</code>, press <code class=\"mapping\">;</code> to start this hint mode.<br/>" +
"Start ExtendedHint mode", "Then press <code>AB</code> to select the hint. Now press <code class=\"mapping\">y</code> to yank its location.<br/>" +
"ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.<br/>"+ "Actions for selected hints in ExtendedHint mode are:<br/>" +
"E.g., if you want to yank the location of hint <code>AB</code>, press <code class=\"mapping\">;</code> to start this hint mode.<br/>"+ "<ul><li><code class=\"mapping\">y</code> to yank its location</li>" +
"Then press <code>AB</code> to select the hint. Now press <code class=\"mapping\">y</code> to yank its location.<br/>"+ " <li><code class=\"mapping\">Y</code> to yank its text description</li>" +
"Actions for selected hints in ExtendedHint mode are:<br/>"+ " <li><code class=\"mapping\">o</code> to open its location in the current tab</li>" +
"<ul><li><code class=\"mapping\">y</code> to yank its location</li>"+ " <li><code class=\"mapping\">t</code> to open its location in a new tab</li>" +
" <li><code class=\"mapping\">Y</code> to yank its text description</li>"+ " <li><code class=\"mapping\">O</code> to open its location in an <code class=\"command\">:open</code> query (not implemented yet)</li>" +
" <li><code class=\"mapping\">o</code> to open its location in the current tab</li>"+ " <li><code class=\"mapping\">T</code> to open its location in an <code class=\"command\">:tabopen</code> query (not implemented yet)</li>" +
" <li><code class=\"mapping\">t</code> to open its location in a new tab</li>"+ " <li><code class=\"mapping\">s</code> to save its destination (not implemented yet)</li>" +
" <li><code class=\"mapping\">O</code> to open its location in an <code class=\"command\">:open</code> query (not implemented yet)</li>"+ " <li><code class=\"mapping\">&lt;C-w&gt;</code> to open its destination in a new window</li>" +
" <li><code class=\"mapping\">T</code> to open its location in an <code class=\"command\">:tabopen</code> query (not implemented yet)</li>"+ "</ul>" +
" <li><code class=\"mapping\">s</code> to save its destination (not implemented yet)</li>"+ "Multiple hints can be seperated by commas where it makes sense. <code class=\"mapping\">;ab,ac,adt</code> opens <code>AB</code>, <code>AC</code> and <code>AD</code> in a new tab.<br/>" +
" <li><code class=\"mapping\">&lt;C-w&gt;</code> to open its destination in a new window</li>"+ "Hintable elements for this mode can be set in the <code class=\"setting\">'extendedhinttags'</code> XPath string."
"</ul>"+ }
"Multiple hints can be seperated by commas where it makes sense. <code class=\"mapping\">;ab,ac,adt</code> opens <code>AB</code>, <code>AC</code> and <code>AD</code> in a new tab.<br/>"+ ));
"Hintable elements for this mode can be set in the <code class=\"setting\">'extendedhinttags'</code> XPath string.",
function(count) { hah.enableHahMode(vimperator.modes.EXTENDED_HINT); }
],
/* search managment */ /* search managment */
[ addDefaults(new Map(vimperator.mode.NORMAL, ["g/"], function(count) { vimperator.search.openSearchDialog(); },
["g/"], {
["g/"], short_help: "Search forward for a pattern",
"Search forward for a pattern", help: ""
"", }
function(count) { vimperator.search.openSearchDialog(); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, ["n"], function(count) { vimperator.search.findNext(); },
[ {
["n"], short_help: "Find next",
["n"], help: "Repeat the last \"/\" 1 time (until count is supported)."
"Find next", }
"Repeat the last \"/\" 1 time (until count is supported).", ));
function(count) { vimperator.search.findNext(); } addDefaults(new Map(vimperator.mode.NORMAL, ["N"], function(count) { vimperator.search.findPrevious(); },
], {
[ short_help: "Find previous",
["N"], help: "Repeat the last \"/\" 1 time (until count is supported) in the opposite direction."
["N"], }
"Find previous", ));
"Repeat the last \"/\" 1 time (until count is supported) in the opposite direction.",
function(count) { vimperator.search.findPrevious(); }
],
/* vimperator managment */ /* vimperator managment */
[ addDefaults(new Map(vimperator.mode.NORMAL, ["<F1>"], function(count) { help(null); },
["<F1>"], {
["<F1>"], short_help: "Open help window",
"Open help window", help: "The default section is shown, if you need help for a specific topic, try <code class=\"command\">:help &lt;F1&gt;</code> (jumping to a specific section not implemented yet)."
"The default section is shown, if you need help for a specific topic, try <code class=\"command\">:help &lt;F1&gt;</code> (jumping to a specific section not implemented yet).", }
function(count) { help(null); } ));
], addDefaults(new Map(vimperator.mode.NORMAL, [":"], function(count) { vimperator.commandline.open(":", "", vimperator.modes.EX); },
[ {
[":"], short_help: "Start command line mode",
[":"], help: "In command line mode, you can perform extended commands, which may require arguments."
"Start command line mode", }
"In command line mode, you can perform extended commands, which may require arguments.", ));
function(count) { vimperator.commandline.open(":", "", vimperator.modes.EX); } addDefaults(new Map(vimperator.mode.NORMAL, ["I"], function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS);},
], {
[ short_help: "Disable vimperator keys",
["I"], help: "Starts an 'ignorekeys' mode, where all keys except <code class=\"mapping\">&lt;Esc&gt;</code> are passed to the next event handler.<br/>" +
["I"], "This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore.<br/>" +
"Disable vimperator keys", "To exit this mode, press <code class=\"mapping\">&lt;Esc&gt;</code>. If you also need to pass <code class=\"mapping\">&lt;Esc&gt;</code>" +
"Starts an 'ignorekeys' mode, where all keys except <code class=\"mapping\">&lt;Esc&gt;</code> are passed to the next event handler.<br/>"+ "in this mode to the webpage, prepend it with <code class=\"mapping\">&lt;C-v&gt;</code>."
"This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore.<br/>" + }
"To exit this mode, press <code class=\"mapping\">&lt;Esc&gt;</code>. If you also need to pass <code class=\"mapping\">&lt;Esc&gt;</code>"+ ));
"in this mode to the webpage, prepend it with <code class=\"mapping\">&lt;C-v&gt;</code>.", // if you ever add/remove keys here, also check them in the onVimperatorKeypress() function
function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS);} addDefaults(new Map(vimperator.mode.NORMAL, ["<C-v>"], function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); },
], {
[ short_help: "Escape next key",
["<C-v>"], // if you ever add/remove keys here, also check them in the onVimperatorKeypress() function help: "If you need to pass a certain key to a javascript form field or another extension prefix the key with <code class=\"mapping\">&lt;C-v&gt;</code>.<br/>" +
["<C-v>"], "Also works to unshadow Firefox short_helpcuts like <code class=\"mapping\">&lt;C-o&gt;</code> which are otherwise hidden in Vimperator.<br/>" +
"Escape next key", "When in 'ignorekeys' mode (activated by <code class=\"mapping\">&lt;I&gt;</code>), <code class=\"mapping\">&lt;C-v&gt;</code> will pass the next key to Vimperator instead of the webpage."
"If you need to pass a certain key to a javascript form field or another extension prefix the key with <code class=\"mapping\">&lt;C-v&gt;</code>.<br/>"+ }
"Also works to unshadow Firefox shortcuts like <code class=\"mapping\">&lt;C-o&gt;</code> which are otherwise hidden in Vimperator.<br/>"+ ));
"When in 'ignorekeys' mode (activated by <code class=\"mapping\">&lt;I&gt;</code>), <code class=\"mapping\">&lt;C-v&gt;</code> will pass the next key to Vimperator instead of the webpage.", addDefaults(new Map(vimperator.mode.NORMAL, ["<C-c>"], BrowserStop,
function(count) { vimperator.addMode(null, vimperator.modes.ESCAPE_ONE_KEY); } {
], short_help: "Stop loading",
[ help: "Stops loading the current webpage."
["<C-c>"], }
["<C-c>"], ));
"Stop loading", // if you ever add/remove keys here, also check them in the onVimperatorKeypress()
"Stops loading the current webpage.", addDefaults(new Map(vimperator.mode.NORMAL, ["<Esc>", "<C-[>"], onEscape,
BrowserStop {
], short_help: "Cancel any operation",
[ help: "Exits any command line or hint mode and returns to browser mode.<br/>"
["<Esc>", "<C-[>"], // if you ever add/remove keys here, also check them in the onVimperatorKeypress() function }
["<Esc>", "<C-[>"], ));
"Cancel any operation",
"Exits any command line or hint mode and returns to browser mode.<br/>"+
"Also focuses the web page, in case a form field has focus and eats our key presses.",
onEscape
]
];
var hint_maps = [ var hint_maps = [
/* hint action keys */ /* hint action keys */
["o", "hah.openHints(false, false);", true, false], ["o", "hah.openHints(false, false);", true, false],