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. --- background_scripts/commands.coffee | 3 +++ 1 file changed, 3 insertions(+) (limited to 'background_scripts') diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index d12b704d..1fb9317d 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -166,6 +166,7 @@ Commands = "enterVisualMode", "enterVisualLineMode", "passNextKey", + "enterNormalMode", "focusInput", "LinkHints.activateMode", "LinkHints.activateModeToOpenInNewTab", @@ -238,6 +239,7 @@ Commands = "closeOtherTabs", "enterVisualLineMode", "toggleViewSource", + "enterNormalMode", "passNextKey"] defaultKeyMappings = @@ -354,6 +356,7 @@ commandDescriptions = passNextKey: ["Pass the next key to Chrome"] enterVisualMode: ["Enter visual mode", { noRepeat: true }] enterVisualLineMode: ["Enter visual line mode", { noRepeat: true }] + enterNormalMode: ["Handle following key sequence in normal mode"] focusInput: ["Focus the first text input on the page"] -- cgit v1.2.3