diff options
| -rw-r--r-- | background_scripts/commands.coffee | 27 | ||||
| -rw-r--r-- | content_scripts/mode_key_handler.coffee | 2 | ||||
| -rw-r--r-- | pages/help_dialog.coffee | 4 | 
3 files changed, 16 insertions, 17 deletions
| diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 50e5d624..46869451 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -1,13 +1,13 @@  Commands = -  init: (customKeyMappings) -> +  init: () ->      for own command, description of commandDescriptions        @addCommand(command, description[0], description[1]) -    @loadKeyMappings customKeyMappings +    @loadKeyMappings Settings.get "keyMappings"      Settings.postUpdateHooks["keyMappings"] = @loadKeyMappings.bind this -  loadKeyMappings: (value) -> +  loadKeyMappings: (customKeyMappings) ->      @clearKeyMappingsAndSetDefaults() -    @parseCustomKeyMappings value +    @parseCustomKeyMappings customKeyMappings      @generateKeyStateMapping()    availableCommands: {} @@ -107,19 +107,18 @@ Commands =    namedKeyRegex: /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/    generateKeyStateMapping: -> -    keyMapping = {} +    keyStateMapping = {}      for own keys, registryEntry of @keyToCommandRegistry -      currentMapping = keyMapping +      currentMapping = keyStateMapping        while 0 < keys.length -        [key, rest] = if 0 == keys.search @namedKeyRegex then [RegExp.$1, RegExp.$2] else [keys[0], keys[1..]] -        if 0 < rest.length -          # Do not overwrite existing command bindings, they take priority. -          break if (currentMapping[key] ?= {}).command -          currentMapping = currentMapping[key] +        [key, keys] = if 0 == keys.search @namedKeyRegex then [RegExp.$1, RegExp.$2] else [keys[0], keys[1..]] +        if currentMapping[key]?.command +          break # Do not overwrite existing command bindings, they take priority. +        else if 0 < keys.length +          currentMapping = (currentMapping[key] ?= {})          else            currentMapping[key] = registryEntry -        keys = rest -    chrome.storage.local.set normalModeKeyStateMapping: keyMapping +    chrome.storage.local.set normalModeKeyStateMapping: keyStateMapping    # An ordered listing of all available commands, grouped by type. This is the order they will    # be shown in the help page. @@ -397,7 +396,7 @@ commandDescriptions =    "Marks.activateCreateMode": ["Create a new mark", { noRepeat: true }]    "Marks.activateGotoMode": ["Go to a mark", { noRepeat: true }] -Commands.init Settings.get "keyMappings" +Commands.init()  root = exports ? window  root.Commands = Commands diff --git a/content_scripts/mode_key_handler.coffee b/content_scripts/mode_key_handler.coffee index 265ceed1..97966644 100644 --- a/content_scripts/mode_key_handler.coffee +++ b/content_scripts/mode_key_handler.coffee @@ -93,7 +93,7 @@ class KeyHandlerMode extends Mode    # This tests whether keyChar would be the very first character of a command mapping.    isFirstKeyChar: (keyChar) -> -    keyChar and @countPrefix == 0 and (@mappingForKeyChar(keyChar) == @keyMapping or @isCountKey keyChar) +    @countPrefix == 0 and (@mappingForKeyChar(keyChar) == @keyMapping or @isCountKey keyChar)  root = exports ? window  root.KeyHandlerMode = KeyHandlerMode diff --git a/pages/help_dialog.coffee b/pages/help_dialog.coffee index db085e2d..4e6d1946 100644 --- a/pages/help_dialog.coffee +++ b/pages/help_dialog.coffee @@ -48,9 +48,9 @@ HelpDialog =            chrome.runtime.sendMessage handler: "copyToClipboard", data: commandName            HUD.showForDuration("Yanked #{commandName}.", 2000) -    @exitOnEscape = new Mode exitOnEscape: true +    @exitOnEscape = new Mode name: "help-page-escape", exitOnEscape: true      @exitOnEscape.onExit (event) => -      HelpDialog.hide() if event?.type == "keydown" and KeyboardUtils.isEscape event +      HelpDialog.hide() if event?.type == "keydown"    hide: ->      @exitOnEscape.exit() | 
