aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-10-10 13:55:47 +0100
committerGitHub2016-10-10 13:55:47 +0100
commit1eb6bfdcad6d7091911e395083afe1148b2a4c76 (patch)
tree0dc625f101fbd7d2e49b73c71f067fda628d97f4 /background_scripts
parenta3c4b530f24ee8bc1f9a1219cf35fb87a1aa0402 (diff)
parent0346b2d971ffab26a8d37946aca1c550b316e317 (diff)
downloadvimium-1eb6bfdcad6d7091911e395083afe1148b2a4c76.tar.bz2
Merge pull request #2306 from smblott-github/add-key-translation
Add "mapkey" command for key mappings.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/commands.coffee8
1 files changed, 8 insertions, 0 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 7a4526c2..d12b704d 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -9,6 +9,7 @@ Commands =
@clearKeyMappingsAndSetDefaults()
@parseCustomKeyMappings customKeyMappings
@generateKeyStateMapping()
+ chrome.storage.local.set mapKeyRegistry: @mapKeyRegistry
availableCommands: {}
keyToCommandRegistry: {}
@@ -84,6 +85,12 @@ Commands =
when "unmapAll"
@keyToCommandRegistry = {}
+ when "mapkey"
+ if tokens.length == 3
+ fromChar = @parseKeySequence tokens[1]
+ toChar = @parseKeySequence tokens[2]
+ @mapKeyRegistry[fromChar[0]] = toChar[0] if fromChar.length == toChar.length == 1
+
# Push the key mapping for passNextKey into Settings so that it's available in the front end for insert
# mode. We exclude single-key mappings (that is, printable keys) because when users press printable keys
# in insert mode they expect the character to be input, not to be droppped into some special Vimium
@@ -109,6 +116,7 @@ Commands =
clearKeyMappingsAndSetDefaults: ->
@keyToCommandRegistry = {}
+ @mapKeyRegistry = {}
for own key, command of defaultKeyMappings
keySequence = @parseKeySequence key
key = keySequence.join ""