Skip to content

Commit

Permalink
Modernizing the results from PR qutebrowser#3683
Browse files Browse the repository at this point in the history
  • Loading branch information
brightonanc committed Jun 11, 2023
1 parent b9ce011 commit cf3aac4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
8 changes: 4 additions & 4 deletions qutebrowser/keyinput/basekeyparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,16 @@ def execute(self, cmdstr: str, count: int = None) -> None:
"""
raise NotImplementedError

def _set_partial_timeout(self):
def _set_partial_timeout(self) -> None:
"""Set a timeout to clear a partial keystring."""
timeout = config.val.input.partial_timeout
if timeout != 0:
self._partial_timer.setInterval(timeout)
self._partial_timer.timeout.connect(self.clear_partial_match)
self._partial_timer.timeout.connect(self._clear_partial_match)
self._partial_timer.start()

@pyqtSlot()
def clear_partial_match(self):
def _clear_partial_match(self) -> None:
"""Clear a partial keystring after a timeout."""
self._debug_log("Clearing partial keystring {}".format(
self._sequence))
Expand All @@ -394,7 +394,7 @@ def clear_keystring(self) -> None:
self.keystring_updated.emit('')
self._partial_timer.stop()
try:
self._partial_timer.timeout.disconnect(self.clear_partial_match)
self._partial_timer.timeout.disconnect(self._clear_partial_match)
except TypeError:
# no connections
pass
33 changes: 6 additions & 27 deletions qutebrowser/keyinput/modeparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def execute(self, cmdstr: str, count: int = None) -> None:

class NormalKeyParser(CommandKeyParser):

"""KeyParser for normal mode with added STARTCHARS detection and more."""
"""KeyParser for normal mode with added STARTCHARS detection and more.
Attributes:
_partial_timer: Timer to clear partial keypresses.
"""

_sequence: keyutils.KeySequence

Expand Down Expand Up @@ -226,19 +230,7 @@ def clear_keystring(self):
self._orig_sequence = keyutils.KeySequence()


class PromptKeyParser(CommandKeyParser):

"""KeyParser for yes/no prompts."""

def __init__(self, win_id, parent=None):
super().__init__(win_id, parent, supports_count=False)
self._read_config('yesno')

def __repr__(self):
return utils.get_repr(self)


class HintKeyParser(CommandKeyParser):
class HintKeyParser(basekeyparser.BaseKeyParser):

"""KeyChainParser for hints.
Expand Down Expand Up @@ -347,19 +339,6 @@ def execute(self, cmdstr: str, count: int = None) -> None:
assert count is None
self._hintmanager.handle_partial_key(cmdstr)

@pyqtSlot()
def clear_partial_match(self):
"""Override to avoid clearing filter text after a timeout."""
if self._last_press != LastPress.filtertext:
super().clear_partial_match()

@pyqtSlot(str)
def on_keystring_updated(self, keystr):
"""Update hintmanager when the keystring was updated."""
hintmanager = objreg.get('hintmanager', scope='tab',
window=self._win_id, tab='current')
hintmanager.handle_partial_key(keystr)


class RegisterKeyParser(CommandKeyParser):

Expand Down

0 comments on commit cf3aac4

Please sign in to comment.