Coverage for qutebrowser/keyinput/basekeyparser.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # # qutebrowser is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # qutebrowser is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Parser for vim-like key sequences and shortcuts.
Not intended to be instantiated directly. Subclasses have to override execute() to do whatever they want to.
Class Attributes: Match: types of a match between a binding and the keystring. partial: No keychain matched yet, but it's still possible in the future. definitive: Keychain matches exactly. none: No more matches possible.
Types: type of a key binding. chain: execute() was called via a chain-like key binding special: execute() was called via a special key binding
do_log: Whether to log keypresses or not. passthrough: Whether unbound keys should be passed through with this handler.
Attributes: bindings: Bound key bindings special_bindings: Bound special bindings (<Foo>). _win_id: The window ID this keyparser is associated with. _warn_on_keychains: Whether a warning should be logged when binding keychains in a section which does not support them. _keystring: The currently entered key sequence _modename: The name of the input mode associated with this keyparser. _supports_count: Whether count is supported _supports_chains: Whether keychains are supported
Signals: keystring_updated: Emitted when the keystring is updated. arg: New keystring. request_leave: Emitted to request leaving a mode. arg 0: Mode to leave. arg 1: Reason for leaving. arg 2: Ignore the request if we're not in that mode """
supports_chains=False):
def __repr__(self): return utils.get_repr(self, supports_count=self._supports_count, supports_chains=self._supports_chains)
"""Log a message to the debug log if logging is active.
Args: message: The message to log. """
"""Handle a new keypress with special keys (<Foo>).
Return True if the keypress has been handled, and False if not.
Args: e: the KeyPressEvent from Qt.
Return: True if event has been handled, False otherwise. """
"""Get count and command from the current keystring.
Args: keystring: The key string to split.
Return: A (count, command) tuple. """ keystring).groups() else:
"""Handle a new keypress with a single key (no modifiers).
Separate the keypress into count/command, then check if it matches any possible command, and either run the command, ignore it, or display an error.
Args: e: the KeyPressEvent from Qt.
Return: A self.Match member. """
else:
self._keystring)) self._keystring, txt)) self._keystring)) else: raise utils.Unreachable("Invalid match value {!r}".format(match))
"""Try to match a given keystring with any bound keychain.
Args: cmd_input: The command string to find.
Return: A tuple (matchtype, binding). matchtype: Match.definitive, Match.partial or Match.none. binding: - None with Match.partial/Match.none. - The found binding with Match.definitive. """ # Only a count, no command yet, but we handled it # A (cmd_input, binding) tuple (k, v of bindings) or None. # Check definitive match # Check partial match # We already matched that one else:
"""Handle a new keypress and call the respective handlers.
Args: e: the KeyPressEvent from Qt
Return: True if the event was handled, False otherwise. """
# don't emit twice if the keystring was cleared in self.clear_keystring
def _on_config_changed(self):
"""Read the configuration.
Config format: key = command, e.g.: <Ctrl+Q> = quit
Args: modename: Name of the mode to use. """ "None defined so far!") else:
"""Parse the keys and their command and store them in the object.""" "keychains are not supported there." .format(key, modename))
"""Handle a completed keychain.
Args: cmdstr: The command to execute as a string. keytype: Type.chain or Type.special count: The count if given. """ raise NotImplementedError
"""Clear the currently entered key sequence.""" self._keystring)) |