diff options
| author | Stephen Blott | 2017-10-14 13:03:31 +0100 | 
|---|---|---|
| committer | GitHub | 2017-10-14 13:03:31 +0100 | 
| commit | aec5681729861120954688f00be1b7fa6a89568d (patch) | |
| tree | 46359c70004eec34a3063276ed0ebd3e1c1d5d09 | |
| parent | ac9eba9b89c3c29d155a159c57acde3d28fd03ce (diff) | |
| parent | 66b11f98f480bbd83cb2cf720e219d0df8203f80 (diff) | |
| download | vimium-aec5681729861120954688f00be1b7fa6a89568d.tar.bz2 | |
Merge pull request #2723 from smblott-github/allow-map-vim-like-escape
Allow <c-[> to be mapped as a regular command.
| -rw-r--r-- | background_scripts/commands.coffee | 3 | ||||
| -rw-r--r-- | lib/keyboard_utils.coffee | 10 | 
2 files changed, 10 insertions, 3 deletions
| diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index cda036e6..7e171d31 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -113,6 +113,9 @@ Commands =            # We don't need these properties in the content scripts.            delete currentMapping[key][prop] for prop in ["keySequence", "description"]      chrome.storage.local.set normalModeKeyStateMapping: keyStateMapping +    # Inform `KeyboardUtils.isEscape()` whether `<c-[>` should be interpreted as `Escape` (which it is by +    # default). +    chrome.storage.local.set useVimLikeEscape: "<c-[>" not of keyStateMapping    # Build the "helpPageData" data structure which the help page needs and place it in Chrome storage.    prepareHelpPageData: -> diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index e14e8b3e..1a1ea797 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -60,9 +60,13 @@ KeyboardUtils =        keyChar = mapKeyRegistry[keyChar] ? keyChar        keyChar -  isEscape: (event) -> -    # <c-[> is mapped to Escape in Vim by default. -    event.key == "Escape" || @getKeyCharString(event) == "<c-[>" +  isEscape: do -> +    useVimLikeEscape = true +    Utils.monitorChromeStorage "useVimLikeEscape", (value) -> useVimLikeEscape = value + +    (event) -> +      # <c-[> is mapped to Escape in Vim by default. +      event.key == "Escape" or (useVimLikeEscape and @getKeyCharString(event) == "<c-[>")    isBackspace: (event) ->      event.key in ["Backspace", "Delete"] | 
