From 5f944bc99c7cb25412d4f7a51b946b27a14ca77d Mon Sep 17 00:00:00 2001 From: R.T. Lechow Date: Tue, 4 Jan 2011 19:02:53 -0500 Subject: Commands for following 'previous' and 'next' links. --- commands.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 3b9203dc..7ee25520 100644 --- a/commands.js +++ b/commands.js @@ -118,6 +118,9 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('n', 'performFind'); mapKeyToCommand('N', 'performBackwardsFind'); + mapKeyToCommand('[[', 'goPrevious'); + mapKeyToCommand(']]', 'goNext'); + mapKeyToCommand('yy', 'copyCurrentUrl'); mapKeyToCommand('K', 'nextTab'); @@ -165,6 +168,9 @@ addCommand('enterFindMode', 'Enter find mode'); addCommand('performFind', 'Cycle forward to the next find match'); addCommand('performBackwardsFind', 'Cycle backward to the previous find match'); +addCommand('goPrevious', 'Follow the link labeled previous or <'); +addCommand('goNext', 'Follow the link labeled next or >'); + // Navigating your history: addCommand('goBack', 'Go back in history'); addCommand('goForward', 'Go forward in history'); @@ -192,6 +198,7 @@ var commandGroups = { "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp", "enterInsertMode", "focusInput", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activateLinkHintsModeWithQueue", + "goPrevious", "goNext", "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"], historyNavigation: ["goBack", "goForward"], -- cgit v1.2.3 From 41bdf1383ea5a019dd5afd1810b3069bbd715fdf Mon Sep 17 00:00:00 2001 From: Christian Stefanescu Date: Sat, 22 Jan 2011 13:11:05 +0100 Subject: Added "zoomReset" command which resets the zoom to the default level (value 100). The shortcut combination is z0. --- commands.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 3b9203dc..9c5b1562 100644 --- a/commands.js +++ b/commands.js @@ -107,6 +107,7 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('zi', 'zoomIn'); mapKeyToCommand('zo', 'zoomOut'); + mapKeyToCommand('z0', 'zoomReset'); mapKeyToCommand('gi', 'focusInput'); @@ -151,6 +152,7 @@ addCommand('reload', 'Reload the page'); addCommand('toggleViewSource', 'View page source'); addCommand('zoomIn', 'Zoom in'); addCommand('zoomOut', 'Zoom out'); +addCommand('zoomReset', 'Reset zoom to default value'); addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard'); addCommand('enterInsertMode', 'Enter insert mode'); @@ -189,7 +191,7 @@ var commandGroups = { ["scrollDown", "scrollUp", "scrollLeft", "scrollRight", "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", "scrollPageUp", "scrollFullPageUp", "scrollFullPageDown", - "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp", + "reload", "toggleViewSource", "zoomIn", "zoomOut", "zoomReset", "copyCurrentUrl", "goUp", "enterInsertMode", "focusInput", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activateLinkHintsModeWithQueue", "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"], -- cgit v1.2.3 From efb1af02cceda258da04a4266258f079bc019d3a Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 00:55:05 -0800 Subject: Changing quote style so it's not inconsistent within the same file --- commands.js | 194 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 97 insertions(+), 97 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 7f30df97..cc774bff 100644 --- a/commands.js +++ b/commands.js @@ -81,113 +81,113 @@ function parseCustomKeyMappings(customKeyMappings) { function clearKeyMappingsAndSetDefaults() { keyToCommandRegistry = {}; - mapKeyToCommand('?', 'showHelp'); - mapKeyToCommand('j', 'scrollDown'); - mapKeyToCommand('k', 'scrollUp'); - mapKeyToCommand('h', 'scrollLeft'); - mapKeyToCommand('l', 'scrollRight'); - mapKeyToCommand('gg', 'scrollToTop'); - mapKeyToCommand('G', 'scrollToBottom'); - mapKeyToCommand('zH', 'scrollToLeft'); - mapKeyToCommand('zL', 'scrollToRight'); - mapKeyToCommand('', 'scrollDown'); - mapKeyToCommand('', 'scrollUp'); - mapKeyToCommand('', 'scrollPageDown'); - mapKeyToCommand('', 'scrollPageUp'); - mapKeyToCommand('', 'scrollFullPageDown'); - mapKeyToCommand('', 'scrollFullPageUp'); - mapKeyToCommand('r', 'reload'); - mapKeyToCommand('gs', 'toggleViewSource'); - - mapKeyToCommand('i', 'enterInsertMode'); - - mapKeyToCommand('H', 'goBack'); - mapKeyToCommand('L', 'goForward'); - mapKeyToCommand('gu', 'goUp'); - - mapKeyToCommand('zi', 'zoomIn'); - mapKeyToCommand('zo', 'zoomOut'); - mapKeyToCommand('z0', 'zoomReset'); - - mapKeyToCommand('gi', 'focusInput'); - - mapKeyToCommand('f', 'activateLinkHintsMode'); - mapKeyToCommand('F', 'activateLinkHintsModeToOpenInNewTab'); - mapKeyToCommand('', 'activateLinkHintsModeWithQueue'); - - mapKeyToCommand('/', 'enterFindMode'); - mapKeyToCommand('n', 'performFind'); - mapKeyToCommand('N', 'performBackwardsFind'); - - mapKeyToCommand('[[', 'goPrevious'); - mapKeyToCommand(']]', 'goNext'); - - mapKeyToCommand('yy', 'copyCurrentUrl'); - - mapKeyToCommand('K', 'nextTab'); - mapKeyToCommand('J', 'previousTab'); - mapKeyToCommand('gt', 'nextTab'); - mapKeyToCommand('gT', 'previousTab'); - - mapKeyToCommand('t', 'createTab'); - mapKeyToCommand('d', 'removeTab'); - mapKeyToCommand('u', 'restoreTab'); - - mapKeyToCommand('gf', 'nextFrame'); + mapKeyToCommand("?", "showHelp"); + mapKeyToCommand("j", "scrollDown"); + mapKeyToCommand("k", "scrollUp"); + mapKeyToCommand("h", "scrollLeft"); + mapKeyToCommand("l", "scrollRight"); + mapKeyToCommand("gg", "scrollToTop"); + mapKeyToCommand("G", "scrollToBottom"); + mapKeyToCommand("zH", "scrollToLeft"); + mapKeyToCommand("zL", "scrollToRight"); + mapKeyToCommand("", "scrollDown"); + mapKeyToCommand("", "scrollUp"); + mapKeyToCommand("", "scrollPageDown"); + mapKeyToCommand("", "scrollPageUp"); + mapKeyToCommand("", "scrollFullPageDown"); + mapKeyToCommand("", "scrollFullPageUp"); + mapKeyToCommand("r", "reload"); + mapKeyToCommand("gs", "toggleViewSource"); + + mapKeyToCommand("i", "enterInsertMode"); + + mapKeyToCommand("H", "goBack"); + mapKeyToCommand("L", "goForward"); + mapKeyToCommand("gu", "goUp"); + + mapKeyToCommand("zi", "zoomIn"); + mapKeyToCommand("zo", "zoomOut"); + mapKeyToCommand("z0", "zoomReset"); + + mapKeyToCommand("gi", "focusInput"); + + mapKeyToCommand("f", "activateLinkHintsMode"); + mapKeyToCommand("F", "activateLinkHintsModeToOpenInNewTab"); + mapKeyToCommand("", "activateLinkHintsModeWithQueue"); + + mapKeyToCommand("/", "enterFindMode"); + mapKeyToCommand("n", "performFind"); + mapKeyToCommand("N", "performBackwardsFind"); + + mapKeyToCommand("[[", "goPrevious"); + mapKeyToCommand("]]", "goNext"); + + mapKeyToCommand("yy", "copyCurrentUrl"); + + mapKeyToCommand("K", "nextTab"); + mapKeyToCommand("J", "previousTab"); + mapKeyToCommand("gt", "nextTab"); + mapKeyToCommand("gT", "previousTab"); + + mapKeyToCommand("t", "createTab"); + mapKeyToCommand("d", "removeTab"); + mapKeyToCommand("u", "restoreTab"); + + mapKeyToCommand("gf", "nextFrame"); } // Navigating the current page: -addCommand('showHelp', 'Show help', true); -addCommand('scrollDown', 'Scroll down'); -addCommand('scrollUp', 'Scroll up'); -addCommand('scrollLeft', 'Scroll left'); -addCommand('scrollRight', 'Scroll right'); -addCommand('scrollToTop', 'Scroll to the top of the page'); -addCommand('scrollToBottom', 'Scroll to the bottom of the page'); -addCommand('scrollToLeft', 'Scroll to the left of the page'); -addCommand('scrollToRight', 'Scroll to the right of the page'); -addCommand('scrollPageDown', 'Scroll a page down'); -addCommand('scrollPageUp', 'Scroll a page up'); -addCommand('scrollFullPageDown', 'Scroll a full page down'); -addCommand('scrollFullPageUp', 'Scroll a full page up'); - -addCommand('reload', 'Reload the page'); -addCommand('toggleViewSource', 'View page source'); -addCommand('zoomIn', 'Zoom in'); -addCommand('zoomOut', 'Zoom out'); -addCommand('zoomReset', 'Reset zoom to default value'); -addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard'); - -addCommand('enterInsertMode', 'Enter insert mode'); - -addCommand('focusInput', 'Focus the first (or n-th) text box on the page', false, true); - -addCommand('activateLinkHintsMode', 'Enter link hints mode to open links in current tab'); -addCommand('activateLinkHintsModeToOpenInNewTab', 'Enter link hints mode to open links in new tab'); -addCommand('activateLinkHintsModeWithQueue', 'Enter link hints mode to open multiple links in a new tab'); - -addCommand('enterFindMode', 'Enter find mode'); -addCommand('performFind', 'Cycle forward to the next find match'); -addCommand('performBackwardsFind', 'Cycle backward to the previous find match'); - -addCommand('goPrevious', 'Follow the link labeled previous or <'); -addCommand('goNext', 'Follow the link labeled next or >'); +addCommand("showHelp", "Show help", true); +addCommand("scrollDown", "Scroll down"); +addCommand("scrollUp", "Scroll up"); +addCommand("scrollLeft", "Scroll left"); +addCommand("scrollRight", "Scroll right"); +addCommand("scrollToTop", "Scroll to the top of the page"); +addCommand("scrollToBottom", "Scroll to the bottom of the page"); +addCommand("scrollToLeft", "Scroll to the left of the page"); +addCommand("scrollToRight", "Scroll to the right of the page"); +addCommand("scrollPageDown", "Scroll a page down"); +addCommand("scrollPageUp", "Scroll a page up"); +addCommand("scrollFullPageDown", "Scroll a full page down"); +addCommand("scrollFullPageUp", "Scroll a full page up"); + +addCommand("reload", "Reload the page"); +addCommand("toggleViewSource", "View page source"); +addCommand("zoomIn", "Zoom in"); +addCommand("zoomOut", "Zoom out"); +addCommand("zoomReset", "Reset zoom to default value"); +addCommand("copyCurrentUrl", "Copy the current URL to the clipboard"); + +addCommand("enterInsertMode", "Enter insert mode"); + +addCommand("focusInput", "Focus the first (or n-th) text box on the page", false, true); + +addCommand("activateLinkHintsMode", "Enter link hints mode to open links in current tab"); +addCommand("activateLinkHintsModeToOpenInNewTab", "Enter link hints mode to open links in new tab"); +addCommand("activateLinkHintsModeWithQueue", "Enter link hints mode to open multiple links in a new tab"); + +addCommand("enterFindMode", "Enter find mode"); +addCommand("performFind", "Cycle forward to the next find match"); +addCommand("performBackwardsFind", "Cycle backward to the previous find match"); + +addCommand("goPrevious", "Follow the link labeled previous or <"); +addCommand("goNext", "Follow the link labeled next or >"); // Navigating your history: -addCommand('goBack', 'Go back in history'); -addCommand('goForward', 'Go forward in history'); +addCommand("goBack", "Go back in history"); +addCommand("goForward", "Go forward in history"); // Navigating the URL hierarchy -addCommand('goUp', 'Go up the URL hierarchy', false, true); +addCommand("goUp", "Go up the URL hierarchy", false, true); // Manipulating tabs: -addCommand('nextTab', 'Go one tab right', true); -addCommand('previousTab', 'Go one tab left', true); -addCommand('createTab', 'Create new tab', true); -addCommand('removeTab', 'Close current tab', true); -addCommand('restoreTab', "Restore closed tab", true); +addCommand("nextTab", "Go one tab right", true); +addCommand("previousTab", "Go one tab left", true); +addCommand("createTab", "Create new tab", true); +addCommand("removeTab", "Close current tab", true); +addCommand("restoreTab", "Restore closed tab", true); -addCommand('nextFrame', "Cycle forward to the next frame on the page", true); +addCommand("nextFrame", "Cycle forward to the next frame on the page", true); // An ordered listing of all available commands, grouped by type. This is the order they will -- cgit v1.2.3 From c282f69eb0390d72667d8ec70b41fb27d6b79f84 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 01:00:47 -0800 Subject: Remove some boilerplate code when restoring default mappings --- commands.js | 111 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 53 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index cc774bff..8a16e969 100644 --- a/commands.js +++ b/commands.js @@ -81,59 +81,64 @@ function parseCustomKeyMappings(customKeyMappings) { function clearKeyMappingsAndSetDefaults() { keyToCommandRegistry = {}; - mapKeyToCommand("?", "showHelp"); - mapKeyToCommand("j", "scrollDown"); - mapKeyToCommand("k", "scrollUp"); - mapKeyToCommand("h", "scrollLeft"); - mapKeyToCommand("l", "scrollRight"); - mapKeyToCommand("gg", "scrollToTop"); - mapKeyToCommand("G", "scrollToBottom"); - mapKeyToCommand("zH", "scrollToLeft"); - mapKeyToCommand("zL", "scrollToRight"); - mapKeyToCommand("", "scrollDown"); - mapKeyToCommand("", "scrollUp"); - mapKeyToCommand("", "scrollPageDown"); - mapKeyToCommand("", "scrollPageUp"); - mapKeyToCommand("", "scrollFullPageDown"); - mapKeyToCommand("", "scrollFullPageUp"); - mapKeyToCommand("r", "reload"); - mapKeyToCommand("gs", "toggleViewSource"); - - mapKeyToCommand("i", "enterInsertMode"); - - mapKeyToCommand("H", "goBack"); - mapKeyToCommand("L", "goForward"); - mapKeyToCommand("gu", "goUp"); - - mapKeyToCommand("zi", "zoomIn"); - mapKeyToCommand("zo", "zoomOut"); - mapKeyToCommand("z0", "zoomReset"); - - mapKeyToCommand("gi", "focusInput"); - - mapKeyToCommand("f", "activateLinkHintsMode"); - mapKeyToCommand("F", "activateLinkHintsModeToOpenInNewTab"); - mapKeyToCommand("", "activateLinkHintsModeWithQueue"); - - mapKeyToCommand("/", "enterFindMode"); - mapKeyToCommand("n", "performFind"); - mapKeyToCommand("N", "performBackwardsFind"); - - mapKeyToCommand("[[", "goPrevious"); - mapKeyToCommand("]]", "goNext"); - - mapKeyToCommand("yy", "copyCurrentUrl"); - - mapKeyToCommand("K", "nextTab"); - mapKeyToCommand("J", "previousTab"); - mapKeyToCommand("gt", "nextTab"); - mapKeyToCommand("gT", "previousTab"); - - mapKeyToCommand("t", "createTab"); - mapKeyToCommand("d", "removeTab"); - mapKeyToCommand("u", "restoreTab"); - - mapKeyToCommand("gf", "nextFrame"); + var defaultKeyMappings = { + "?": "showHelp", + "j": "scrollDown", + "k": "scrollUp", + "h": "scrollLeft", + "l": "scrollRight", + "gg": "scrollToTop", + "G": "scrollToBottom", + "zH": "scrollToLeft", + "zL": "scrollToRight", + "": "scrollDown", + "": "scrollUp", + "": "scrollPageDown", + "": "scrollPageUp", + "": "scrollFullPageDown", + "": "scrollFullPageUp", + "r": "reload", + "gs": "toggleViewSource", + + "i": "enterInsertMode", + + "H": "goBack", + "L": "goForward", + "gu": "goUp", + + "zi": "zoomIn", + "zo": "zoomOut", + "z0": "zoomReset", + + "gi": "focusInput", + + "f": "activateLinkHintsMode", + "F": "activateLinkHintsModeToOpenInNewTab", + "": "activateLinkHintsModeWithQueue", + + "/": "enterFindMode", + "n": "performFind", + "N": "performBackwardsFind", + + "[[": "goPrevious", + "]]": "goNext", + + "yy": "copyCurrentUrl", + + "K": "nextTab", + "J": "previousTab", + "gt": "nextTab", + "gT": "previousTab", + + "t": "createTab", + "d": "removeTab", + "u": "restoreTab", + + "gf": "nextFrame" + }; + + for (var key in defaultKeyMappings) + mapKeyToCommand(key, defaultKeyMappings[key]); } // Navigating the current page: -- cgit v1.2.3 From 1315254f6b75e6dfc4169b73b51537967416e580 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 01:20:15 -0800 Subject: Add some cleanup to the mapping from command name => command description & options --- commands.js | 131 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 59 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 8a16e969..ac1e1a44 100644 --- a/commands.js +++ b/commands.js @@ -1,22 +1,28 @@ var availableCommands = {}; var keyToCommandRegistry = {}; -function addCommand(command, description, isBackgroundCommand, passCountToFunction) { - if (availableCommands[command]) - { +/* + * Registers a command, making it available to be optionally bound to a key. + * options: + * - background: whether this command needs to be run against the background page. + * - passCountToFunction: true if this command should have any digits which were typed prior to the + * command passed to it. This is used to implement e.g. "closing of 3 tabs". + */ +function addCommand(command, description, options) { + if (availableCommands[command]) { console.log(command, "is already defined! Check commands.js for duplicates."); return; } + options = options || {}; availableCommands[command] = { description: description, - isBackgroundCommand: isBackgroundCommand, - passCountToFunction: passCountToFunction + isBackgroundCommand: options.background, + passCountToFunction: options.passCountToFunction }; } function mapKeyToCommand(key, command) { - if (!availableCommands[command]) - { + if (!availableCommands[command]) { console.log(command, "doesn't exist!"); return; } @@ -141,58 +147,65 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand(key, defaultKeyMappings[key]); } -// Navigating the current page: -addCommand("showHelp", "Show help", true); -addCommand("scrollDown", "Scroll down"); -addCommand("scrollUp", "Scroll up"); -addCommand("scrollLeft", "Scroll left"); -addCommand("scrollRight", "Scroll right"); -addCommand("scrollToTop", "Scroll to the top of the page"); -addCommand("scrollToBottom", "Scroll to the bottom of the page"); -addCommand("scrollToLeft", "Scroll to the left of the page"); -addCommand("scrollToRight", "Scroll to the right of the page"); -addCommand("scrollPageDown", "Scroll a page down"); -addCommand("scrollPageUp", "Scroll a page up"); -addCommand("scrollFullPageDown", "Scroll a full page down"); -addCommand("scrollFullPageUp", "Scroll a full page up"); - -addCommand("reload", "Reload the page"); -addCommand("toggleViewSource", "View page source"); -addCommand("zoomIn", "Zoom in"); -addCommand("zoomOut", "Zoom out"); -addCommand("zoomReset", "Reset zoom to default value"); -addCommand("copyCurrentUrl", "Copy the current URL to the clipboard"); - -addCommand("enterInsertMode", "Enter insert mode"); - -addCommand("focusInput", "Focus the first (or n-th) text box on the page", false, true); - -addCommand("activateLinkHintsMode", "Enter link hints mode to open links in current tab"); -addCommand("activateLinkHintsModeToOpenInNewTab", "Enter link hints mode to open links in new tab"); -addCommand("activateLinkHintsModeWithQueue", "Enter link hints mode to open multiple links in a new tab"); - -addCommand("enterFindMode", "Enter find mode"); -addCommand("performFind", "Cycle forward to the next find match"); -addCommand("performBackwardsFind", "Cycle backward to the previous find match"); - -addCommand("goPrevious", "Follow the link labeled previous or <"); -addCommand("goNext", "Follow the link labeled next or >"); - -// Navigating your history: -addCommand("goBack", "Go back in history"); -addCommand("goForward", "Go forward in history"); - -// Navigating the URL hierarchy -addCommand("goUp", "Go up the URL hierarchy", false, true); - -// Manipulating tabs: -addCommand("nextTab", "Go one tab right", true); -addCommand("previousTab", "Go one tab left", true); -addCommand("createTab", "Create new tab", true); -addCommand("removeTab", "Close current tab", true); -addCommand("restoreTab", "Restore closed tab", true); +// This is a mapping of: commandIdentifier => [description, options]. +var commandDescriptions = { + // Navigating the current page: + showHelp: ["Show help", { background: true }], + scrollDown: ["Scroll down"], + scrollUp: ["Scroll up"], + scrollLeft: ["Scroll left"], + scrollRight: ["Scroll right"], + scrollToTop: ["Scroll to the top of the page"], + scrollToBottom: ["Scroll to the bottom of the page"], + scrollToLeft: ["Scroll to the left of the page"], + + scrollToRight: ["Scroll to the right of the page"], + scrollPageDown: ["Scroll a page down"], + scrollPageUp: ["Scroll a page up"], + scrollFullPageDown: ["Scroll a full page down"], + scrollFullPageUp: ["Scroll a full page up"], + + reload: ["Reload the page"], + toggleViewSource: ["View page source"], + zoomIn: ["Zoom in"], + zoomOut: ["Zoom out"], + zoomReset: ["Reset zoom to default value"], + copyCurrentUrl: ["Copy the current URL to the clipboard"], + + enterInsertMode: ["Enter insert mode"], + + focusInput: ["Focus the first (or n-th) text box on the page", { passCountToFunction: true }], + + activateLinkHintsMode: ["Enter link hints mode to open links in current tab"], + activateLinkHintsModeToOpenInNewTab: ["Enter link hints mode to open links in new tab"], + activateLinkHintsModeWithQueue: ["Enter link hints mode to open multiple links in a new tab"], + + enterFindMode: ["Enter find mode"], + performFind: ["Cycle forward to the next find match"], + performBackwardsFind: ["Cycle backward to the previous find match"], + + goPrevious: ["Follow the link labeled previous or <"], + goNext: ["Follow the link labeled next or >"], + + // Navigating your history: + goBack: ["Go back in history"], + goForward: ["Go forward in history"], + + // Navigating the URL hierarchy + goUp: ["Go up the URL hierarchy", { passCountToFunction: true }], + + // Manipulating tabs: + nextTab: ["Go one tab right", { background: true }], + previousTab: ["Go one tab left", { background: true }], + createTab: ["Create new tab", { background: true }], + removeTab: ["Close current tab", { background: true }], + restoreTab: ["Restore closed tab", { background: true }], + + nextFrame: ["Cycle forward to the next frame on the page", { background: true }] +}; -addCommand("nextFrame", "Cycle forward to the next frame on the page", true); +for (var command in commandDescriptions) + addCommand(command, commandDescriptions[command][0], commandDescriptions[command][1]); // An ordered listing of all available commands, grouped by type. This is the order they will @@ -213,4 +226,4 @@ var commandGroups = { ["nextTab", "previousTab", "createTab", "removeTab", "restoreTab"], misc: ["showHelp"] -}; +}; \ No newline at end of file -- cgit v1.2.3 From ae73ad02e936f66bb894fca5da13a631bcd14d31 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 02:11:58 -0800 Subject: Split the help dialog into common commands and advanced commands. This closes #284 --- commands.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index ac1e1a44..d7066bd1 100644 --- a/commands.js +++ b/commands.js @@ -149,7 +149,7 @@ function clearKeyMappingsAndSetDefaults() { // This is a mapping of: commandIdentifier => [description, options]. var commandDescriptions = { - // Navigating the current page: + // Navigating the current page showHelp: ["Show help", { background: true }], scrollDown: ["Scroll down"], scrollUp: ["Scroll up"], @@ -187,14 +187,14 @@ var commandDescriptions = { goPrevious: ["Follow the link labeled previous or <"], goNext: ["Follow the link labeled next or >"], - // Navigating your history: + // Navigating your history goBack: ["Go back in history"], goForward: ["Go forward in history"], // Navigating the URL hierarchy goUp: ["Go up the URL hierarchy", { passCountToFunction: true }], - // Manipulating tabs: + // Manipulating tabs nextTab: ["Go one tab right", { background: true }], previousTab: ["Go one tab left", { background: true }], createTab: ["Create new tab", { background: true }], @@ -226,4 +226,12 @@ var commandGroups = { ["nextTab", "previousTab", "createTab", "removeTab", "restoreTab"], misc: ["showHelp"] -}; \ No newline at end of file +}; + +// Rarely used commands are not shown by default in the help dialog or in the README. The goal is to present +// a focused, high-signal set of commands to the new and casual user. Only those truly hungry for more power +// from Vimium will uncover these gems. +var advancedCommands = [ + "scrollToLeft", "scrollToRight", + "zoomReset", "goUp", "focusInput", "activateLinkHintsModeWithQueue", + "goPrevious", "goNext"]; \ No newline at end of file -- cgit v1.2.3 From 83fee9f86c90b06df78465264850e91e6a94e9b5 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 02:15:26 -0800 Subject: Tighten up the layout of the help dialog --- commands.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index d7066bd1..66263905 100644 --- a/commands.js +++ b/commands.js @@ -176,9 +176,9 @@ var commandDescriptions = { focusInput: ["Focus the first (or n-th) text box on the page", { passCountToFunction: true }], - activateLinkHintsMode: ["Enter link hints mode to open links in current tab"], - activateLinkHintsModeToOpenInNewTab: ["Enter link hints mode to open links in new tab"], - activateLinkHintsModeWithQueue: ["Enter link hints mode to open multiple links in a new tab"], + activateLinkHintsMode: ["Open a link in the current tab"], + activateLinkHintsModeToOpenInNewTab: ["Open a link in a new tab"], + activateLinkHintsModeWithQueue: ["Open multiple links in a new tab"], enterFindMode: ["Enter find mode"], performFind: ["Cycle forward to the next find match"], @@ -218,8 +218,8 @@ var commandGroups = { "reload", "toggleViewSource", "zoomIn", "zoomOut", "zoomReset", "copyCurrentUrl", "goUp", "enterInsertMode", "focusInput", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activateLinkHintsModeWithQueue", - "goPrevious", "goNext", - "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"], + "goPrevious", "goNext", "nextFrame"], + findCommands: ["enterFindMode", "performFind", "performBackwardsFind"], historyNavigation: ["goBack", "goForward"], tabManipulation: -- cgit v1.2.3 From e7706ab6e1328018769a841b53c6ac179bfd4a44 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 02:20:37 -0800 Subject: Move the advanced commands in the readme into a separate section --- commands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index 66263905..f2b19467 100644 --- a/commands.js +++ b/commands.js @@ -157,9 +157,9 @@ var commandDescriptions = { scrollRight: ["Scroll right"], scrollToTop: ["Scroll to the top of the page"], scrollToBottom: ["Scroll to the bottom of the page"], - scrollToLeft: ["Scroll to the left of the page"], + scrollToLeft: ["Scroll all the way to the left"], - scrollToRight: ["Scroll to the right of the page"], + scrollToRight: ["Scroll all the way to the right"], scrollPageDown: ["Scroll a page down"], scrollPageUp: ["Scroll a page up"], scrollFullPageDown: ["Scroll a full page down"], -- cgit v1.2.3 From 35d58590b0e09e88c92ca3d49b5ba3b1ff622665 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 30 Jan 2011 18:04:45 -0800 Subject: Make "d" and "u" scroll up and down a page instead of closing and restoring tabs. This implements #274. The motivation behind this change is that scrolling a page is far more common than closing a tab, and so those actions should be on a hotkey which doesn't require a modifier. Once you get used to scrolling without hitting ctrl, you won't be able to go back. For existing users, this change also adds a custom mapping for them in their preferences to preserve the old behavior as they upgrade from 1.21 to 1.22. --- commands.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'commands.js') diff --git a/commands.js b/commands.js index f2b19467..de70a0a9 100644 --- a/commands.js +++ b/commands.js @@ -99,6 +99,12 @@ function clearKeyMappingsAndSetDefaults() { "zL": "scrollToRight", "": "scrollDown", "": "scrollUp", + + // scrollPageDown and scrollPageUp are mapped to two keys because they are very common actions so we + // want them to be mapped without a modifier key, but we also want to be faithful to Vim convention which + // has them on ctrl+D and ctrl+U. + "d": "scrollPageDown", + "u": "scrollPageUp", "": "scrollPageDown", "": "scrollPageUp", "": "scrollFullPageDown", @@ -137,8 +143,8 @@ function clearKeyMappingsAndSetDefaults() { "gT": "previousTab", "t": "createTab", - "d": "removeTab", - "u": "restoreTab", + "x": "removeTab", + "X": "restoreTab", "gf": "nextFrame" }; -- cgit v1.2.3