From 762b17344a1d12aa58c5df2f3eef452175dc0166 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 3 Jan 2015 16:30:32 +0000 Subject: Modes; visual-mode template. Visual mode command has been create: bound to `v`, of course. The template is in mode_visual.coffee. It shouldn't really be necessary to make changes outside of there. Let me know if you have any issues. --- content_scripts/mode_visual.coffee | 9 ++++++--- content_scripts/vimium_frontend.coffee | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'content_scripts') 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. -- cgit v1.2.3