aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode_key_handler.coffee
AgeCommit message (Collapse)Author
2017-10-29Remove unused codemrmr1993
2017-10-29Let handlerStack call consumeKeyup rather than calling it explicitlymrmr1993
2017-10-25FF: Share |root| global proxy, re-add the globals to window on DOMLoadmrmr1993
This is a workaround for Firefox bug 1408996.
2017-04-18Use event.code to detect/suppress keyup events.Stephen Blott
This avoids the possibility of leaking keyup events if the keys a released in a different order from that in which they were pressed. Also, replace suppressKeyupAfterEscape with this same mechanism. This fixes a bug (in master/1.59) whereby we leak the keyup event for `i` when entering insert mode. TODO: - `/`, `<Escape>` leaks a keyup event - `i` leaks a keyup event
2017-04-18Continue bubbling unmapped events.Stephen Blott
2017-04-18Do not reset key state for modifiers.Stephen Blott
2017-04-18Rework tests for all key handling on keydown.Stephen Blott
2017-04-18Move keyboard utils to keydown and migrate normal/visual modes.Stephen Blott
2017-03-22Remove and refactor mapKeyRegistery.Stephen Blott
1. Remove the use of mapKeyRegistery from the mode handler. 2. Refactor use of mapKeyRegistery keyboard utils. This is preparatory to refactoring all of the keyboard handling.
2016-10-15enterNormalMode; new command - implementationStephen Blott
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 - `\g<Escape>o` - open the Vomnibar - `\<Escape>o` - use the page's bindings - `\\\\\\<Escape>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.
2016-10-10Rename 'translate' to 'mapkey'.Stephen Blott
2016-10-09Extend key translation to include Escape.Stephen Blott
Here, these map to escape: translate x <c-[> translate <c-c> <c-[>
2016-10-09Add translate command for key mappings.Stephen Blott
Under *Custom key mappings* (on the options page), this implements: translate x y Whenever the users types `x` in normal mode or in visual mode, the `x` is replaced by `y`. For example: map รง l (which apparently would be helpful on Brazilian keyboards). Issues: - Do we want yet another hack like this? This would be documented only on the wiki. - If we allowed `translate <c-c> <c-[>` (and extended `isEscape()` to use the translation), then we'd get the `exitMode` command for free (#2253). - Alternatively, instead of adding a new "command" called `translate`, we could overload the existing `map` command. Since these are single-key mappings, there's no ambiguity. (Although, I guess there's a risk some user has junk in their key mappings and would be taken by surprise). Inspired by isssue posted by @vhoyer (#2305). Fixes #2305.
2016-10-02Tweak logging.Stephen Blott
2016-09-24Fix key handling for 3-key mappings.Stephen Blott
This only affects key mappings of three keys or longer. Consider: map goa something map gob something Previously, we launched the vomnibar (`o`) on the after `go`, making these mappings unusable. This commit fixes that: `go` no longer launches the Vomnibar, but waits instead to see what the next key is.
2016-04-16Rework UI component focus handling.Stephen Blott
The code to handle the focus for UI components has been tweaked and adapted over time, and has become quite complicated (and brittle). This reworks it from scratch, and co-locates similar code which does related things. Fixes #2099.
2016-03-31Use @suppressEvent instead of false.Stephen Blott
2016-03-30Tweak 21da3fcafbb29540788037dbcdbdce79ad14e650.Stephen Blott
2016-03-30Rename handlerStack constants.Stephen Blott
Problems: - The meanings of some of the Mode/handlerStack constant names is far from obvious. - The same thing is named different things in different places. This changes various constant names such that: - the names used in the handler stack and in the modes are the same. - ditto vis-a-vis DomUtils. Also, break out the core of the handler stacks' `bubbleEvent` method into a switch statements. This makes it more obvious that the cases are mutually exclusive.
2016-03-29Fix typo in debugging code.Stephen Blott
2016-03-27Fix handler return for escape.Stephen Blott
We've consumed the event here, so we should suppress it.
2016-03-27Escape closes help dialog.Stephen Blott
With the help dialog in an iframe, Escape no longer closes it if that iframe loses the focus. This fixes that. See point 2 of #2045. This is not a perfect solution: it only works if the focus ends up in the frame from which the help dialog was launched. However, that is the the common case and, in particular, it is the case which arises on the options page -- which is a particularly important use case.
2016-03-17Logging; consistent and concise normal-mode logging.Stephen Blott
2016-03-06Fix count handling (again).Stephen Blott
`7gj` should be `1j`. Also, with: map ab SOMETHING `7aab` should be `1ab`. Replacement for 7774beb6643c0d905f9caba4345453790af948ad.
2016-03-06Revert "Count prefix applies only to leading mapping."Stephen Blott
This reverts commit 7774beb6643c0d905f9caba4345453790af948ad. Reverting this. It can be done better (and capture some other incorrect cases).
2016-03-06Normal mode tests.Stephen Blott
With #2022, we can now implement normal-mode key-handling tests. Writing these tests uncovered the bug behind 7774beb6643c0d905f9caba4345453790af948ad.
2016-03-06Count prefix applies only to leading mapping.Stephen Blott
E.g. `7gj` should be `1j`; currently it's `7j`.
2016-03-05Key bindings; reset on passKeys change.Stephen Blott
Normal mode updates the pass keys every time the frame changes (so, also every time we change tab). Here, we reset the key state too. Resetting the key state makes sense when, for example, the user has changed the pass keys. However, it also changes a status quo/master behaviour: - `g`, change-tab-with-mouse, change-back, `g` -- previously this scrolled to top; now it does not.
2016-03-05Key bindings; do not reset on passKeys change.Stephen Blott
This reinstates the legacy behaviour in the following case: - `g` - change tab - change back to the original tab - `g` - ..... which scrolls to top. It is not obvious that this is the best behaviour, but it is the legacy behaviour, and it certainly isn't unreasonable.
2016-03-05Key bindings; miscellaneous...Stephen Blott
- remove unused "event" parameter - move methods around to put like with like - simplify some expressions - one better method name
2016-03-05Key bindings; simplify pass-key logic.Stephen Blott
2016-03-05Key bindings; and yet more tiny tweaks.Stephen Blott
2016-03-05Key bindings; more small tweaks.Stephen Blott
2016-03-05Key bindings; small tweaks...Stephen Blott
- simplify pass key condition - don't keep key-parsing Regexp in memory - we should reset the key state when the pass keys change
2016-03-05Key bindings; and yet more tweaks.Stephen Blott
2016-03-05Key bindings; tweaks.Stephen Blott
2016-03-05Key bindings; refactor passKeys.Stephen Blott
Previously, the key-handling logic (keyQueue, etc) was and the backend whereas passKeys were handled in the content scripts - so they were a long way apart. Now that they're in the same place, it makes more sense to integrate passKey handling into the regular key handling, because they depend upon the same data structures.
2016-03-05Key bindings; tweaks.Stephen Blott
2016-03-05Key bindings; and yet more minor tweaks.Stephen Blott
2016-03-05Key bindings; yet more minor tweaks.Stephen Blott
2016-03-05Key bindings; fix tests...Stephen Blott
... and fix two bugs: - not suppressing keyup event after keyChar matched in keydown. - we cannot check the passKeys keyChar in keyup because the key state has changed; so we track what the next keyup response should be.
2016-03-05Key bindings; minor tweaks.Stephen Blott
2016-03-05Key bindings; more tweaks and fixes.Stephen Blott
Miscellaneous fixes and tweaks, including: - Reinstate key logging. - Fix count handling in line with expected behaviour in #2024. - Remove `noCount` option; we don't need it. - Simplify logic in various places. Fixes #2024.
2016-03-05Key bindings; tweaks and fixes.Stephen Blott
2016-03-05Key bindings; fix passkeys.Stephen Blott
2016-03-05Key bindings; initial partially-functioning version.Stephen Blott
2016-03-05Key bindings; initial "generic" class.Stephen Blott
This implements a generic front-end class for key handling (a la normal mode). Also: - supports count prefixes (or not) - supports multi-key mappings (longer than two) Also included is a very poor-man's demo. See the bottom of mode_key_handler.coffee for some hard-wired key bindings. IMPORTANT: This does not actually work as Vimium. It's just a demo.