From fdda1dd3a0f2621b72d5ba393b1a0b9c96c18da1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 19 Jun 2014 11:51:25 +0200 Subject: [PATCH] Forward unbound non-alphanumeric keys by default. We do this so we benefit from some default WebKit keybindings users would expect. For example, we'd need to bind Ctrl+X/C/V by default without this. We also remove the custom-bound scrolling keybindings as they're redundant now. The forward-unbound-keys setting now isn't a bool anymore, instead it can be set to all/auto/none. --- qutebrowser/config/configdata.py | 12 ++---------- qutebrowser/config/conftypes.py | 10 ++++++++++ qutebrowser/keyinput/basekeyparser.py | 4 ++-- qutebrowser/keyinput/modeman.py | 16 ++++++++++------ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 1dbaed099..ea649055e 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -376,8 +376,8 @@ DATA = OrderedDict([ "is focused after page load."), ('forward-unbound-keys', - SettingValue(types.Bool(), 'false'), - "Whether to forward unbound keys to the website in normal mode."), + SettingValue(types.ForwardUnboundKeys(), 'auto'), + "Whether to forward unbound keys to the webview in normal mode."), ('spatial-navigation', SettingValue(types.Bool(), 'false'), @@ -678,14 +678,6 @@ DATA = OrderedDict([ ('', 'tab-focus 8'), ('', 'tab-focus 9'), ('', 'back'), - ('', 'scroll -50 0'), - ('', 'scroll 0 50'), - ('', 'scroll 0 -50'), - ('', 'scroll 50 0'), - ('', 'scroll-page 0 -1'), - ('', 'scroll-page 0 1'), - ('', 'scroll-page 0 -1'), - ('', 'scroll-page 0 1'), ('', 'home'), ('', 'stop'), ('', 'print'), diff --git a/qutebrowser/config/conftypes.py b/qutebrowser/config/conftypes.py index b93f0c723..7c8f57ad7 100644 --- a/qutebrowser/config/conftypes.py +++ b/qutebrowser/config/conftypes.py @@ -916,3 +916,13 @@ class ConfirmQuit(String): ('multiple-tabs', "Show a confirmation if " "multiple tabs are opened."), ('never', "Never show a confirmation.")) + + +class ForwardUnboundKeys(String): + + """Whether to forward unbound keys.""" + + valid_values = ValidValues(('all', "Forward all unbound keys."), + ('auto', "Forward unbound non-alphanumeric " + "keys."), + ('none', "Don't forward any keys.")) diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 8b2b80b4b..e3bc2be92 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -184,8 +184,8 @@ class BaseKeyParser(QObject): self._keystring = '' return - if txt not in (string.ascii_letters + string.digits + - string.punctuation): + if (not txt) or txt not in (string.ascii_letters + string.digits + + string.punctuation): logger.debug("Ignoring, no text char") return False diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index e18861d6b..24d8a790a 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -127,9 +127,13 @@ class ModeManager(QObject): logger.debug("calling handler {}".format(handler.__qualname__)) handled = handler(event) if handler is not None else False + is_non_alnum = event.modifiers() or not event.text().strip() + if handled: filter_this = True - elif self.mode in self.passthrough or self._forward_unbound_keys: + elif (self.mode in self.passthrough or + self._forward_unbound_keys == 'all' or + (self._forward_unbound_keys == 'auto' and is_non_alnum)): filter_this = False else: filter_this = True @@ -137,11 +141,11 @@ class ModeManager(QObject): if not filter_this: self._releaseevents_to_pass.append(event) - logger.debug("handled: {}, forward-unbound-keys: {}, passthrough: {} " - "--> filter: {}".format(handled, - self._forward_unbound_keys, - self.mode in self.passthrough, - filter_this)) + logger.debug("handled: {}, forward-unbound-keys: {}, passthrough: {}, " + "is_non_alnum: {} --> filter: {}".format( + handled, self._forward_unbound_keys, + self.mode in self.passthrough, is_non_alnum, + filter_this)) return filter_this def _eventFilter_keyrelease(self, event):