From 32dc2bf3bf5c28ff44fff89d2436a76bb7bba925 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 15 Oct 2016 12:01:15 +0100 Subject: enterNormalMode; new command - implementation Here's the problem... Many sites define their own keyboard shortcuts, for example Google Play Music defines `gh` for "go home". On such sites, it's natural to set up pass keys for `g` and `h`. But that makes any Vimium key bindings which begin with `g` inaccessible. Here, we add a new command `enterNormalMode` which installs a new normal-mode instance (without any pass keys). This executes a single normal-mode command then exits. Example: map \ enterNormalMode map | enterNormalMode count=999999 Assuming `g` and `o` are pass keys: - `gh` or `o` - use the page's binding - `\gg` - scroll to top - `2\ggo` - scroll to the top and open the Vomnibar - `\go` - open the Vomnibar - `\o` - use the page's bindings - `\\\\\\o` - use the page's bindings (new normal-mode instances displace previous ones) This required some changes to the scroller. Previously, we only ever had one normal-mode instance, and could arrange statically that the scroller's key listeners were above normal-mode's key listeners in the handler stack. Here, we fix this by adding and removing the scroller's listeners dynamically, so they're always at the top of the handler stack. --- content_scripts/mode_insert.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'content_scripts/mode_insert.coffee') diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index 4cb0a39e..d5d98297 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -17,7 +17,6 @@ class InsertMode extends Mode return @suppressEvent return @passEventToPage unless event.type == 'keydown' and KeyboardUtils.isEscape event - DomUtils.suppressKeyupAfterEscape handlerStack target = event.srcElement if target and DomUtils.isFocusable target # Remove the focus, so the user can't just get back into insert mode by typing in the same input box. @@ -26,7 +25,7 @@ class InsertMode extends Mode # An editable element in a shadow DOM is focused; blur it. @insertModeLock.blur() @exit event, event.srcElement - @suppressEvent + DomUtils.suppressKeyupAfterEscape handlerStack defaults = name: "insert" -- cgit v1.2.3