From 9aa37febbedf3232d050c83b724a98994882310e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 Feb 2018 10:33:18 +0100 Subject: [PATCH] Make hints work --- qutebrowser/keyinput/basekeyparser.py | 3 ++- qutebrowser/keyinput/modeparsers.py | 32 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 774decd6e..5830171b8 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -61,6 +61,7 @@ class BaseKeyParser(QObject): _sequence: The currently entered key sequence _modename: The name of the input mode associated with this keyparser. _supports_count: Whether count is supported + # FIXME is this still needed? _supports_chains: Whether keychains are supported Signals: @@ -138,7 +139,7 @@ class BaseKeyParser(QObject): # self._debug_log("Ignoring, no text char") # return QKeySequence.NoMatch - if txt.isdigit(): + if txt.isdigit() and self._supports_count: assert len(txt) == 1, txt self._count += txt return None diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 37fde6a14..d22b27d22 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -213,8 +213,9 @@ class HintKeyParser(keyparser.CommandKeyParser): True if the match has been handled, False otherwise. """ # FIXME rewrite this - match = super().handle(e) + match = self._handle_key(e) if match == QKeySequence.PartialMatch: + # FIXME do we need to check self._sequence here? self.keystring_updated.emit(str(self._sequence)) self._last_press = LastPress.keystring return True @@ -229,17 +230,20 @@ class HintKeyParser(keyparser.CommandKeyParser): else: raise ValueError("Got invalid match type {}!".format(match)) - def execute(self, cmdstr, keytype, count=None): - """Handle a completed keychain.""" - if not isinstance(keytype, self.Type): - raise TypeError("Type {} is no Type member!".format(keytype)) - if keytype == self.Type.chain: - hintmanager = objreg.get('hintmanager', scope='tab', - window=self._win_id, tab='current') - hintmanager.handle_partial_key(cmdstr) - else: - # execute as command - super().execute(cmdstr, keytype, count) + return match != QKeySequence.NoMatch + + # FIXME why is this needed? + # def execute(self, cmdstr, keytype, count=None): + # """Handle a completed keychain.""" + # if not isinstance(keytype, self.Type): + # raise TypeError("Type {} is no Type member!".format(keytype)) + # if keytype == self.Type.chain: + # hintmanager = objreg.get('hintmanager', scope='tab', + # window=self._win_id, tab='current') + # hintmanager.handle_partial_key(cmdstr) + # else: + # # execute as command + # super().execute(cmdstr, keytype, count) def update_bindings(self, strings, preserve_filter=False): """Update bindings when the hint strings changed. @@ -249,7 +253,9 @@ class HintKeyParser(keyparser.CommandKeyParser): preserve_filter: Whether to keep the current value of `self._filtertext`. """ - self.bindings = {keyutils.KeySequence(s): s for s in strings} + self._read_config() + self.bindings.update({keyutils.KeySequence(s): + 'follow-hint ' + s for s in strings}) if not preserve_filter: self._filtertext = ''