aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode.coffee
AgeCommit message (Collapse)Author
2018-08-13Cache keydown events while launching link hints.Stephen Blott
Launching link hints can sometimes be slow. For filtered hints, the user already knows what to type - but must nevertheless wait until the hints have been calculated and rendered. Here, we cache intervening keydown events, and replay them once hints-mode proper is launched. This should make improve usability (in the case of filtered hints). Fixes #3050.
2017-10-29Let handlerStack call consumeKeyup rather than calling it explicitlymrmr1993
2017-10-29Suppress all keyup events automatically if we consume the keydownmrmr1993
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-24Make Mode::exit idempotentmrmr1993
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-02-08Stop using non-standard event.srcElement; switch to event.targetmrmr1993
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-04-17Do not init() the HUD until it's needed.Stephen Blott
This avoids initializing around 15 (almost all unused) HUDs on sites like GMail and Google inbox. Because the HUD is small, there is not noticable flicker.
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-30Add test for SuppressAllKeyboardEvents.Stephen Blott
Which: - uncovered a typo in 39adee9090fc5aadfd5dd681f91b80025084858a. Also: - make Mode.debug a class variable, which is more helpful while trying to debug. Specifically, you can turn debugging on or off from within the tests, for example.
2016-03-30Fix link-hints race condition.Stephen Blott
Because there is a small amount of time between link-hints mode being requested and it being activated, it was possible to launch other Vimium commands (e.g. the Vomnibar) after requesting link-hints mode, and before link-hints mode starts. This prevents that.
2016-03-21Simplify singleton handling.Stephen Blott
While working on the visual-mode code, it became apparent that our current "singleton" implementation is unnecessarily complicated. This simplifies it. The keys are now required to be strings. (Previously, they could be any object; which meant we needed to gove objects an identity. All of which was complicated.)
2016-03-05Key bindings; refactor passKeys distribution.Stephen Blott
It makes more sense to pass the passKeys directly to normalMode. So, do so, and remove the trackState mode option - which isn't otherwise being used.
2016-03-05Key bindings; tweaks.Stephen Blott
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-04Do not use standalone @.Stephen Blott
The styles guide says not to use standalone `@`. So this changes the occurrences I could find (with sed) to `this`. Occurrences within files with major outstanding PRs are omitted.
2016-03-03Remove methods which aren't used.Stephen Blott
2016-01-31Pass arguments to modes' onExit handlers.Stephen Blott
2015-10-04Make mode.exit() idempotent.Stephen Blott
We've been calling hintMode.exit() twice: once explicitly, and once as a side effect of the simulated click event. Since there are so many code paths through link hints, it seems better to simply explicitly make mode.exit() idempotent for all modes. Which is what this commit does.
2015-10-04Make comment/explanation match implementation.Stephen Blott
2015-10-04Suppress trailing key events (after link hints).Stephen Blott
This ensures that -- on leaving link hints mode -- we consume any trailing keyup events (and don't let the underlying page see them). Additional notes: - There are other places where we seem to be leaking keyup events. - A separate bug... It looks like we're calling `exit()` on link-hints mode twice.
2015-06-07Exit link-hint mode on click or scroll.Stephen Blott
Exit on click because, if the user is clicking stuff, then they're probably no longer interested in selecting links. Exit on scroll because, if the user is scrolling, then the link hints can all go out of the viewport.
2015-06-05Fix event suppression for Marks keyboard events.Stephen Blott
2015-06-03Modes, better comments.Stephen Blott
2015-06-03Also set previous position for before global mark movement.Stephen Blott
2015-06-03Re-implement Marks, incl `` binding.Stephen Blott
2015-06-03Fix tests for #1713...Stephen Blott
... which is weird, because the tests are passing here. Let's see what Travis makes of this.
2015-06-03Refactor to avoid having to cover all keyboard event cases.Stephen Blott
It's pretty common that we want to suppress all keyboard events, so let's support that in modes.coffee, thereby simplifying handlers elsewhere.
2015-04-28Activate grab-back-focus only if enabled.Stephen Blott
This turned out to be trickier than expected. It turns out there's a period after document.body is defined but before the DOM is ready when we can't use the HUD (but previously thought we could, ie. HUD.isReady returned true).
2015-04-18Mode indicator: more fix for link hints.Stephen Blott
2015-04-18Mode indicator: initial move to HUD.Stephen Blott
2015-04-18Mode indicator: strip all references to badges.Stephen Blott
2015-03-09Pass keyup events after entering link-hint mode.Stephen Blott
The page (or another extension) sees keydown events (such as shift) before entering link-hint mode. So we need to also pass the corresponding keyup events. Fixes #1522.
2015-02-16Deactivate global insert mode on focus.Stephen Blott
Rationale. There are really two insert modes: the one we activate with "i" and the one that's activated when a focusable element receives the focus. This makes that distinction clearer. And, in particular, it means that, when the latter type of insert mode is active, we *know* that gloabl insert mode is *not* active.
2015-02-13Add callback to runtime message.Stephen Blott
The lack of a callback here was causing errors when loading (at least) the options page.
2015-02-09Merge branch 'visual-and-edit-modes'Stephen Blott
Conflicts: background_scripts/main.coffee content_scripts/vimium_frontend.coffee lib/keyboard_utils.coffee
2015-02-09Visual/edit modes: disable mode debugging for merge to master.Stephen Blott
2015-01-30Visual/edit modes: another minor code review.Stephen Blott
2015-01-29Visual/edit modes: really fix restore of insert-mode sub mode.Stephen Blott
2015-01-28Visual/edit modes: yet more minor changes.Stephen Blott
- Use a has for singletons (as it was previously), but with a distinct identity generated by Utils.getIdentity. - Fix counts not be using in a number of places.
2015-01-28Visual/edit modes: minor changes...Stephen Blott
- Minor refactoring. - Better selection of entity for "daw" an friends. - dd uses count, and works for empty lines. - Count for daw, etc. - Fix bug whereby selection cleared when changing tabs.
2015-01-27Visual/edit modes: minor changes.Stephen Blott
- Minor changes. - Deactivate modes on inputs from focusInput().
2015-01-27Visual/edit modes: self code review.Stephen Blott
2015-01-26Visual/edit modes: fix problem resuming insert mode.Stephen Blott
2015-01-25Visual/edit modes: better mode changes on blur/focus.Stephen Blott
2015-01-21Edit mode: initial framework.Stephen Blott
2015-01-20Rework DOM tests.Stephen Blott
- Set up modes such that they can be re-initialised. - Move initialisation of BadgeMode to general initialisation function. - Add reset() method for handlerStack. - Consistently use initializeModeState() in all tests' setup(). - Refactor focusInput tests. - Add some more tests. - Simplify some other tests. Note: Clean-up of the inputFocus overlay now happens when the exit() method is called in Mode.reset(). This eliminates most needs to artificially bubble a keyboard event to clear the overlay.
2015-01-18Modes; disable debugging output by default.Stephen Blott