aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/commands.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-02-28 09:44:55 +0000
committerStephen Blott2016-03-05 05:38:30 +0000
commit1ae95161b021fc9a64e139485b0dac047a874c0e (patch)
treefc1e8d38d172e636569037a70dd3e9977af7b950 /background_scripts/commands.coffee
parent5d918f75715cc2c595a77f1e9dc8fe545fabb663 (diff)
downloadvimium-1ae95161b021fc9a64e139485b0dac047a874c0e.tar.bz2
Key bindings; simplify Commands initialization.
Diffstat (limited to 'background_scripts/commands.coffee')
-rw-r--r--background_scripts/commands.coffee17
1 files changed, 9 insertions, 8 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 9348e3c5..de03136e 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -1,7 +1,14 @@
Commands =
- init: ->
+ init: (customKeyMappings) ->
for own command, description of commandDescriptions
@addCommand(command, description[0], description[1])
+ @loadKeyMappings customKeyMappings
+ Settings.postUpdateHooks["keyMappings"] = @loadKeyMappings.bind this
+
+ loadKeyMappings: (value) ->
+ @clearKeyMappingsAndSetDefaults()
+ @parseCustomKeyMappings value
+ @generateKeyStateStructure()
availableCommands: {}
keyToCommandRegistry: {}
@@ -391,13 +398,7 @@ commandDescriptions =
"Marks.activateCreateMode": ["Create a new mark", { noRepeat: true }]
"Marks.activateGotoMode": ["Go to a mark", { noRepeat: true }]
-Commands.init()
-
-# Register postUpdateHook for keyMappings setting.
-Settings.postUpdateHooks["keyMappings"] = (value) ->
- Commands.clearKeyMappingsAndSetDefaults()
- Commands.parseCustomKeyMappings value
- Commands.generateKeyStateStructure()
+Commands.init Settings.get "keyMappings"
root = exports ? window
root.Commands = Commands