diff options
| author | Stephen Blott | 2016-02-20 12:08:58 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-02-20 12:08:58 +0000 |
| commit | 2debf3e07ecc41e8d0c3c186f4d8ae39641426f4 (patch) | |
| tree | 834b61e967fc74ea2e43c7e1fbc51341f9542a43 | |
| parent | 5dc1a741a897400e64d68b8248c0557970d04a61 (diff) | |
| parent | c818edb5e0e1a1edbcccfb2b978bf2e535de9fb4 (diff) | |
| download | vimium-2debf3e07ecc41e8d0c3c186f4d8ae39641426f4.tar.bz2 | |
Merge remote-tracking branch 'upstream/master'
| -rw-r--r-- | background_scripts/commands.coffee | 19 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 13 |
3 files changed, 20 insertions, 14 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 80ca0f96..d251c7ed 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -52,11 +52,11 @@ Commands = tokens = line.replace(/\s+$/, "").split /\s+/ switch tokens[0] when "map" - [ _, key, command, options... ] = tokens + [ _, key, command, optionList... ] = tokens if command? and @availableCommands[command] key = @normalizeKey key logMessage? "Mapping #{key} to #{command}" - @mapKeyToCommand { key, command, options } + @mapKeyToCommand { key, command, options: @parseCommandOptions command, optionList } when "unmap" if tokens.length == 2 @@ -74,6 +74,21 @@ Commands = Settings.set "passNextKeyKeys", (key for own key of @keyToCommandRegistry when @keyToCommandRegistry[key].command == "passNextKey" and 1 < key.length) + # Command options follow command mappings, and are of one of two forms: + # key=value - a value + # key - a flag + parseCommandOptions: (command, optionList) -> + options = {} + for option in optionList + parse = option.split "=", 2 + options[parse[0]] = if parse.length == 1 then true else parse[1] + + # We parse any `count` option immediately (to avoid having to parse it repeatedly later). + unless @availableCommands[command].noRepeat + options.count = try Math.max 1, parseInt options.count + + options + clearKeyMappingsAndSetDefaults: -> @keyToCommandRegistry = {} @mapKeyToCommand { key, command } for own key, command of defaultKeyMappings diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index c824db88..0e043159 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -534,6 +534,8 @@ checkKeyQueue = (keysToCheck, tabId, frameId) -> """ if runCommand + # Account for any command-option "count". + count *= registryEntry.options.count ? 1 if not registryEntry.isBackgroundCommand chrome.tabs.sendMessage tabId, name: "executePageCommand" diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 6c08ce92..55a46777 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -10,18 +10,7 @@ Vomnibar = options = {} searchEngines = Settings.get("searchEngines") ? "" SearchEngines.refreshAndUse searchEngines, (engines) -> - for option in registryEntry.options - [ key, value ] = option.split "=" - switch key - when "keyword" - if value? and engines[value]? - options.keyword = value - else - console.log "Vimium configuration error: no such custom search engine: #{option}." - else - console.log "Vimium configuration error: unused flag: #{option}." - - callback? options + callback? registryEntry.options # sourceFrameId here (and below) is the ID of the frame from which this request originates, which may be different # from the current frame. |
