diff options
| author | Stephen Blott | 2014-10-22 07:03:18 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2014-10-22 07:03:18 +0100 | 
| commit | e98f3f678237c1841d9626f17e560b6cb8327dc8 (patch) | |
| tree | 648a55af31c9daff4a2d2416d63f4325dfd12cc3 /content_scripts | |
| parent | a2e7ed7cda8b691486dad582c900307944ec8863 (diff) | |
| parent | 50ea5ac670e736cebcb9bc1300401fe7aa3835fd (diff) | |
| download | vimium-e98f3f678237c1841d9626f17e560b6cb8327dc8.tar.bz2 | |
Merge pull request #1154 from smblott-github/passkeys-structured
Structured exclusion rules internally, and on the popup and options pages.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 15 | 
1 files changed, 7 insertions, 8 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 137b9d1a..6db0d830 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -15,6 +15,8 @@ isShowingHelpDialog = false  keyPort = null  # Users can disable Vimium on URL patterns via the settings page.  The following two variables  # (isEnabledForUrl and passKeys) control Vimium's enabled/disabled behaviour. +# "passKeys" are keys which would normally be handled by Vimium, but are disabled on this tab, and therefore +# are passed through to the underlying page.  isEnabledForUrl = true  passKeys = null  keyQueue = null @@ -130,6 +132,7 @@ initializePreDomReady = ->      # These requests are delivered to the options page, but there are no handlers there.      return if request.handler == "registerFrame" or request.handler == "frameFocused"      sendResponse requestHandlers[request.name](request, sender) +    # Ensure the sendResponse callback is freed.      false  # Wrapper to install event listeners.  Syntactic sugar. @@ -141,9 +144,9 @@ installListener = (event, callback) -> document.addEventListener(event, callback  # listeners, is error prone.  It's more difficult to keep track of the state.  #  installedListeners = false -initializeWhenEnabled = (newPassKeys=undefined) -> +initializeWhenEnabled = (newPassKeys) ->    isEnabledForUrl = true -  passKeys = passKeys if typeof(newPassKeys) != 'undefined' +  passKeys = newPassKeys    if (!installedListeners)      installListener "keydown", (event) -> if isEnabledForUrl then onKeydown(event) else true      installListener "keypress", (event) -> if isEnabledForUrl then onKeypress(event) else true @@ -328,14 +331,11 @@ extend window,        false -# Should this keyChar be passed to the underlying page? +# 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. -# TODO: This currently only works for unmodified keys (so not for '<c-a>', or the like).  It's not clear if -# this is a problem or not.  I don't recall coming across a web page with modifier key bindings.  Such -# bindings might be too likely to conflict with browsers' native bindings.  isPassKey = ( keyChar ) -> -  !keyQueue and passKeys and 0 <= passKeys.indexOf keyChar +  return !keyQueue and passKeys and 0 <= passKeys.indexOf(keyChar)  handledKeydownEvents = [] @@ -365,7 +365,6 @@ onKeypress = (event) ->          handleKeyCharForFindMode(keyChar)          DomUtils.suppressEvent(event)        else if (!isInsertMode() && !findMode) -        # Is this keyChar is to be passed to the underlying page?          if (isPassKey keyChar)            return undefined          if (currentCompletionKeys.indexOf(keyChar) != -1)  | 
