diff options
| author | ilya | 2010-09-10 22:20:21 -0700 |
|---|---|---|
| committer | ilya | 2010-09-10 22:31:46 -0700 |
| commit | 31ddc715c9cae4502e2e0b18aeea11ce9198bc47 (patch) | |
| tree | 40f266be0c305d0a3e4dc057bfd227b002b845c3 /commands.js | |
| parent | 827d7032b6ef7fc1e4f638f8c69b060d895e2c52 (diff) | |
| download | vimium-31ddc715c9cae4502e2e0b18aeea11ce9198bc47.tar.bz2 | |
Make 'gi' compatible with repetition, i.e. 5gi will focus the fifth input box on the page.
Diffstat (limited to 'commands.js')
| -rw-r--r-- | commands.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/commands.js b/commands.js index fa24dee8..a9fa0aba 100644 --- a/commands.js +++ b/commands.js @@ -1,14 +1,17 @@ var availableCommands = {}; var keyToCommandRegistry = {}; -function addCommand(command, description, isBackgroundCommand) { +function addCommand(command, description, isBackgroundCommand, passCountToFunction) { if (availableCommands[command]) { console.log(command, "is already defined! Check commands.js for duplicates."); return; } - availableCommands[command] = { description: description, isBackgroundCommand: isBackgroundCommand }; + availableCommands[command] = { description: description, + isBackgroundCommand: isBackgroundCommand, + passCountToFunction: passCountToFunction + }; } function mapKeyToCommand(key, command) { @@ -18,7 +21,10 @@ function mapKeyToCommand(key, command) { return; } - keyToCommandRegistry[key] = { command: command, isBackgroundCommand: availableCommands[command].isBackgroundCommand }; + keyToCommandRegistry[key] = { command: command, + isBackgroundCommand: availableCommands[command].isBackgroundCommand, + passCountToFunction: availableCommands[command].passCountToFunction + }; } function unmapKey(key) { delete keyToCommandRegistry[key]; } @@ -102,7 +108,7 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('zi', 'zoomIn'); mapKeyToCommand('zo', 'zoomOut'); - mapKeyToCommand('gi', 'focusFirstInput'); + mapKeyToCommand('gi', 'focusInput'); mapKeyToCommand('f', 'activateLinkHintsMode'); mapKeyToCommand('F', 'activateLinkHintsModeToOpenInNewTab'); @@ -146,7 +152,7 @@ addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard'); addCommand('enterInsertMode', 'Enter insert mode'); -addCommand('focusFirstInput', 'Focus the first text box on the page'); +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'); @@ -178,7 +184,7 @@ var commandGroups = { "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", "scrollPageUp", "scrollFullPageDown", "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp", - "enterInsertMode", "focusFirstInput", + "enterInsertMode", "focusInput", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "enterFindMode", "performFind", "performBackwardsFind"], historyNavigation: |
