From baccd7c5cef14480e21e41519e20ee19fa238655 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 3 Jan 2015 13:20:04 +0000 Subject: Modes; Fix various mode changes. --- content_scripts/mode_passkeys.coffee | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'content_scripts/mode_passkeys.coffee') diff --git a/content_scripts/mode_passkeys.coffee b/content_scripts/mode_passkeys.coffee index c754e967..4c4d7d41 100644 --- a/content_scripts/mode_passkeys.coffee +++ b/content_scripts/mode_passkeys.coffee @@ -3,19 +3,8 @@ class PassKeysMode extends Mode keyQueue: "" passKeys: "" - # Decide whether this keyChar should be passed to the underlying page. Keystrokes are *never* considered - # passKeys if the keyQueue is not empty. So, for example, if 't' is a passKey, then 'gt' and '99t' will - # neverthless be handled by vimium. - isPassKey: (keyChar) -> - not @keyQueue and 0 <= @passKeys.indexOf(keyChar) - - handlePassKeyEvent: (event) -> - for keyChar in [KeyboardUtils.getKeyChar(event), String.fromCharCode(event.charCode)] - return @stopBubblingAndTrue if keyChar and @isPassKey keyChar - @continueBubbling - - # This is called to set the pass-keys configuration and state with various types of request from various - # sources, so we handle several cases. + # This is called to set the passKeys configuration and state with various types of request from various + # sources, so we handle several cases here. # TODO(smblott) Rationalize this. configure: (request) -> if request.isEnabledForUrl? @@ -27,14 +16,21 @@ class PassKeysMode extends Mode if request.keyQueue? @keyQueue = request.keyQueue + # Decide whether this event should be passed to the underlying page. Keystrokes are *never* considered + # passKeys if the keyQueue is not empty. So, for example, if 't' is a passKey, then 'gt' and '99t' will + # neverthless be handled by vimium. + handlePassKeyEvent: (event) -> + for keyChar in [KeyboardUtils.getKeyChar(event), String.fromCharCode(event.charCode)] + return @stopBubblingAndTrue if keyChar and not @keyQueue and 0 <= @passKeys.indexOf(keyChar) + @continueBubbling + constructor: -> super name: "passkeys" keydown: (event) => @handlePassKeyEvent event keypress: (event) => @handlePassKeyEvent event - keyup: => @continueBubbling - updateBadgeForMode: (badge) -> + chooseBadge: (badge) -> @badge = if @passKeys and not @keyQueue then "P" else "" super badge -- cgit v1.2.3