aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-02-27 14:20:12 +0000
committerStephen Blott2016-03-05 05:37:40 +0000
commit34b1fb0f4e2ce1696c17e703d0bc43463355d6ba (patch)
tree0bf5797129ae1f212154b56aff86be0830073a29 /content_scripts/vimium_frontend.coffee
parent7c5fb2c312b9140c2dd091f792535ae8f592ecdb (diff)
downloadvimium-34b1fb0f4e2ce1696c17e703d0bc43463355d6ba.tar.bz2
Key bindings; initial partially-functioning version.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee28
1 files changed, 22 insertions, 6 deletions
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()