diff options
| -rw-r--r-- | README.md | 18 | ||||
| -rw-r--r-- | background_scripts/commands.coffee | 1 | ||||
| -rw-r--r-- | lib/keyboard_utils.coffee | 51 | ||||
| -rw-r--r-- | manifest.json | 2 |
4 files changed, 44 insertions, 28 deletions
@@ -74,6 +74,7 @@ Manipulating tabs: K, gt go one tab right g0 go to the first tab g$ go to the last tab + ^ visit the previously-visited tab t create tab yt duplicate current tab x close current tab @@ -155,18 +156,19 @@ Please see [CONTRIBUTING.md](https://github.com/philc/vimium/blob/master/CONTRIB Release Notes ------------- -Next version (not yet released) + +1.55 (2016-05-26) - New commands: - `visitPreviousTab` - visit the previous tab (by recency) with `^`, or the tab before that with `2^`. - - `passNextKey` - pass the next key to the page; for example, with `map - <c-]> passNextKey`, you can close Facebook's messenger popups with `<c-]><Esc>`. + - `passNextKey` - pass the next key to the page. For example, using `map <c-]> passNextKey`, you can close + Facebook's messenger popups with `<c-]><Esc>`. - Link hints: - Now work across all frames in the tab. - Now select frames and scrollable elements. - - Now accept a count prefix; `3F` opens three new background tabs, `999F` opens many tabs. - - For filtered link hints, a new option requires you to press `Enter` to activate a link; this - prevents unintentionally triggering Vimium commands with trailing keystrokes. + - Now accept a count prefix; `3F` opens three new background tabs, `999F` opens many tabs. + - For filtered link hints, a new option on the settings page requires you to press `Enter` to activate a + link; this prevents unintentionally triggering Vimium commands with trailing keystrokes. - Miscellaneous: - `gg` now accepts a `count` prefix. - `W` now accepts a count prefix; `3W` moves three tabs to a new window. @@ -176,8 +178,8 @@ Next version (not yet released) - `c-y` and `c-e` now scroll in visual mode. - The Vimium help dialog has been re-styled. - Bug fixes: - - `<c-a-[>` is not longer treated as escape. - - Fix icon display and memory leak due to regression in recent Chrome versions (49+). + - `<c-a-[>` is no longer treated as escape. + - Fix icon display and memory leak due to a regression in recent Chrome versions (49+). - For web-devs only: - When disabled on a tab, Vimium no longer pollutes the dev console with network requests. diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 0905daee..c334cf9d 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -43,7 +43,6 @@ Commands = key.replace(/<[acm]-/ig, (match) -> match.toLowerCase()) .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, (match, optionalPrefix, keyName) -> "<" + (if optionalPrefix then optionalPrefix else "") + keyName.toLowerCase() + ">") - .replace /<space>/ig, " " parseCustomKeyMappings: (customKeyMappings) -> for line in customKeyMappings.split "\n" diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index 10b5f46e..364ab949 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -4,7 +4,7 @@ KeyboardUtils = f12: 123, tab: 9, downArrow: 40, upArrow: 38 } keyNames: - { 37: "left", 38: "up", 39: "right", 40: "down" } + { 37: "left", 38: "up", 39: "right", 40: "down", 32: "space" } # This is a mapping of the incorrect keyIdentifiers generated by Webkit on Windows during keydown events to # the correct identifiers, which are correctly generated on Mac. We require this mapping to properly handle @@ -30,7 +30,27 @@ KeyboardUtils = else @platform = "Windows" + # We are migrating from using event.keyIdentifier to using event.key. For some period of time, we must + # support both. This wrapper can be removed once Chrome 52 is considered too old to support. getKeyChar: (event) -> + if event.key? + @getKeyCharUsingKey event + else + @getKeyCharUsingKeyIdentifier event + + getKeyCharUsingKey: (event) -> + if event.keyCode of @keyNames + @keyNames[event.keyCode] + else if event.key.length == 1 + event.key + else if event.key.length == 2 and "F1" <= event.key <= "F9" + event.key.toLowerCase() # F1 to F9. + else if event.key.length == 3 and "F10" <= event.key <= "F12" + event.key.toLowerCase() # F10 to F12. + else + "" + + getKeyCharUsingKeyIdentifier: (event) -> # Not a letter if (event.keyIdentifier.slice(0, 2) != "U+") return @keyNames[event.keyCode] if (@keyNames[event.keyCode]) @@ -76,23 +96,18 @@ KeyboardUtils = String.fromCharCode event.charCode when "keydown" - # handle special keys, and normal input keys with modifiers being pressed. don't handle shiftKey alone (to - # avoid / being interpreted as ? - if (((event.metaKey || event.ctrlKey || event.altKey) && event.keyCode > 31) || ( - # TODO(philc): some events don't have a keyidentifier. How is that possible? - event.keyIdentifier && event.keyIdentifier.slice(0, 2) != "U+")) - keyChar = @getKeyChar event - # Again, ignore just modifiers. Maybe this should replace the keyCode>31 condition. - if 0 < keyChar.length - modifiers = [] - - keyChar = keyChar.toUpperCase() if event.shiftKey - modifiers.push "m" if event.metaKey - modifiers.push "c" if event.ctrlKey - modifiers.push "a" if event.altKey - - keyChar = [modifiers..., keyChar].join "-" - if 1 < keyChar.length then "<#{keyChar}>" else keyChar + # Handle special keys and normal input keys with modifiers being pressed. + keyChar = @getKeyChar event + if 1 < keyChar.length or (keyChar.length == 1 and (event.metaKey or event.ctrlKey or event.altKey)) + modifiers = [] + + keyChar = keyChar.toUpperCase() if event.shiftKey + modifiers.push "m" if event.metaKey + modifiers.push "c" if event.ctrlKey + modifiers.push "a" if event.altKey + + keyChar = [modifiers..., keyChar].join "-" + if 1 < keyChar.length then "<#{keyChar}>" else keyChar KeyboardUtils.init() diff --git a/manifest.json b/manifest.json index f5847562..36ed0cff 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Vimium", - "version": "1.54", + "version": "1.55", "description": "The Hacker's Browser. Vimium provides keyboard shortcuts for navigation and control in the spirit of Vim.", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", |
