aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-12-21 05:09:42 +0000
committerGitHub2016-12-21 05:09:42 +0000
commit320f433afb53cc774b175dab0f6a1ad7a47d60f9 (patch)
tree2bb28d6c6afc7ceeb7f463c6aff23d201b43587b /content_scripts/vimium_frontend.coffee
parentcaa63d6642141d2fe4cd6941ec1e84dd2d3e8225 (diff)
parentedfb7ba3ca148f7b00bd683d1979330f395f2e7e (diff)
downloadvimium-320f433afb53cc774b175dab0f6a1ad7a47d60f9.tar.bz2
Merge pull request #2311 from smblott-github/enterNormalMode
New command option to enter normal mode
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee27
1 files changed, 19 insertions, 8 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 21826944..6447092b 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -111,11 +111,13 @@ handlerStack.push
class NormalMode extends KeyHandlerMode
constructor: (options = {}) ->
- super extend options,
+ defaults =
name: "normal"
- indicator: false # There is no mode indicator in normal mode.
+ indicator: false # There is normally no mode indicator in normal mode.
commandHandler: @commandHandler.bind this
+ super extend defaults, options
+
chrome.storage.local.get "normalModeKeyStateMapping", (items) =>
@setKeyMapping items.normalModeKeyStateMapping
@@ -123,10 +125,6 @@ class NormalMode extends KeyHandlerMode
if area == "local" and changes.normalModeKeyStateMapping?.newValue
@setKeyMapping changes.normalModeKeyStateMapping.newValue
- # Initialize components which normal mode depends upon.
- Scroller.init()
- FindModeHistory.init()
-
commandHandler: ({command: registryEntry, count}) ->
count *= registryEntry.options.count ? 1
count = 1 if registryEntry.noRepeat
@@ -150,6 +148,9 @@ installModes = ->
# Install the permanent modes. The permanently-installed insert mode tracks focus/blur events, and
# activates/deactivates itself accordingly.
normalMode = new NormalMode
+ # Initialize components upon which normal mode depends.
+ Scroller.init()
+ FindModeHistory.init()
new InsertMode permanent: true
new GrabBackFocus if isEnabledForUrl
normalMode # Return the normalMode object (for the tests).
@@ -383,8 +384,18 @@ extend window,
enterVisualLineMode: ->
new VisualLineMode userLaunchedMode: true
- passNextKey: (count) ->
- new PassNextKeyMode count
+ passNextKey: (count, options) ->
+ if options.registryEntry.options.normal
+ enterNormalMode count
+ else
+ new PassNextKeyMode count
+
+ enterNormalMode: (count) ->
+ new NormalMode
+ indicator: "Normal mode (pass keys disabled)"
+ exitOnEscape: true
+ singleton: "enterNormalMode"
+ count: count
focusInput: do ->
# Track the most recently focused input element.