aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/commands.coffee3
-rw-r--r--content_scripts/mode_visual.coffee9
-rw-r--r--content_scripts/vimium_frontend.coffee3
3 files changed, 12 insertions, 3 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index 585ef572..407fb067 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -111,6 +111,7 @@ Commands =
"goUp",
"goToRoot",
"enterInsertMode",
+ "enterVisualMode",
"focusInput",
"LinkHints.activateMode",
"LinkHints.activateModeToOpenInNewTab",
@@ -195,6 +196,7 @@ defaultKeyMappings =
"gs": "toggleViewSource"
"i": "enterInsertMode"
+ "v": "enterVisualMode"
"H": "goBack"
"L": "goForward"
@@ -283,6 +285,7 @@ commandDescriptions =
openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true, repeatLimit: 20 }]
enterInsertMode: ["Enter insert mode", { noRepeat: true }]
+ enterVisualMode: ["Enter visual mode", { noRepeat: true }]
focusInput: ["Focus the first text box on the page. Cycle between them using tab",
{ passCountToFunction: true }]
diff --git a/content_scripts/mode_visual.coffee b/content_scripts/mode_visual.coffee
index 8c5f8d51..f88e20fe 100644
--- a/content_scripts/mode_visual.coffee
+++ b/content_scripts/mode_visual.coffee
@@ -1,7 +1,4 @@
-# Use new VisualMode() to enter visual mode.
-# Use @exit() to leave visual mode.
-
class VisualMode extends Mode
constructor: ->
super
@@ -9,6 +6,10 @@ class VisualMode extends Mode
badge: "V"
keydown: (event) =>
+ if KeyboardUtils.isEscape event
+ @exit()
+ return Mode.suppressEvent
+
return Mode.suppressEvent
keypress: (event) =>
@@ -17,5 +18,7 @@ class VisualMode extends Mode
keyup: (event) =>
return Mode.suppressEvent
+ Mode.updateBadge()
+
root = exports ? window
root.VisualMode = VisualMode
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index e20dafc4..e0ce03d5 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -340,6 +340,9 @@ extend window,
enterInsertMode: ->
insertMode?.activate()
+ enterVisualMode: =>
+ new VisualMode()
+
focusInput: (count) ->
# Focus the first input element on the page, and create overlays to highlight all the input elements, with
# the currently-focused element highlighted specially. Tabbing will shift focus to the next input element.