From 34b1fb0f4e2ce1696c17e703d0bc43463355d6ba Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 27 Feb 2016 14:20:12 +0000 Subject: Key bindings; initial partially-functioning version. --- content_scripts/vimium_frontend.coffee | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index bce5f632..b46175fb 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -101,19 +101,35 @@ handlerStack.push # Only exported for tests. window.initializeModes = -> - class NormalMode extends Mode + class NormalMode extends KeyHandlerMode constructor: -> super name: "normal" indicator: false # There is no mode indicator in normal mode. - keydown: (event) => onKeydown.call @, event - keypress: (event) => onKeypress.call @, event - keyup: (event) => onKeyup.call @, event + commandHandler: @commandHandler.bind this + keyMapping: {} + + chrome.storage.local.get "normalModeKeyStateMapping", (items) => + @setKeyMapping items.normalModeKeyStateMapping + + chrome.storage.onChanged.addListener (changes, area) => + if area == "local" and changes.normalModeKeyStateMapping?.newValue + @setKeyMapping changes.normalModeKeyStateMapping.newValue + + commandHandler: (registryEntry, count) -> + # TODO: Special handling of Vomnibar. + if registryEntry.isBackgroundCommand + true # Not yet implemnted. + else + count = 1 if registryEntry.noRepeat + if registryEntry.passCountToFunction + Utils.invokeCommandString registryEntry.command, [count] + else + Utils.invokeCommandString registryEntry.command for i in [0...count] # Install the permanent modes. The permanently-installed insert mode tracks focus/blur events, and # activates/deactivates itself accordingly. - # new NormalMode - new KeyHandlerMode commandHandler: demoCommandHandler, keyMapping: demoKeyMapping, indicator: "Demo mode." + new NormalMode new PassKeysMode new InsertMode permanent: true Scroller.init() -- cgit v1.2.3