summaryrefslogtreecommitdiff
path: root/qutebrowser/keyinput/keyutils.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-09-11 16:03:39 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-09-11 16:03:39 +0200
commitc6fac2157d9833db01b88dc1dfb03f7b4c1517e4 (patch)
tree8750ea850660256f3fb52d5003cae3c529d25f83 /qutebrowser/keyinput/keyutils.py
parentb4858c7e79e506f0cb0a078a38a8fb11a842d2b3 (diff)
parente720df22c4dff59aca2938da7968ea6f14c79f2c (diff)
downloadqutebrowser-c6fac2157d9833db01b88dc1dfb03f7b4c1517e4.tar.gz
qutebrowser-c6fac2157d9833db01b88dc1dfb03f7b4c1517e4.zip
Merge remote-tracking branch 'origin/pr/4691'
Diffstat (limited to 'qutebrowser/keyinput/keyutils.py')
-rw-r--r--qutebrowser/keyinput/keyutils.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index 55a7b4afe..97159706f 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -163,14 +163,19 @@ def _is_printable(key):
return key <= 0xff and key not in [Qt.Key_Space, 0x0]
-def _is_surrogate(key):
- """Check if a codepoint is a UTF-16 surrogate.
+def is_special_hint_mode(key, modifiers):
+ """Check whether this key should clear the keychain in hint mode.
- UTF-16 surrogates are a reserved range of Unicode from 0xd800
- to 0xd8ff, used to encode Unicode codepoints above the BMP
- (Base Multilingual Plane).
+ When we press "s<Escape>", we don't want <Escape> to be handled as part of
+ a key chain in hint mode.
"""
- return 0xd800 <= key <= 0xdfff
+ _assert_plain_key(key)
+ _assert_plain_modifier(modifiers)
+ if is_modifier_key(key):
+ return False
+ return not (_is_printable(key) and
+ modifiers in [Qt.ShiftModifier, Qt.NoModifier,
+ Qt.KeypadModifier])
def is_special(key, modifiers):
@@ -178,8 +183,7 @@ def is_special(key, modifiers):
_assert_plain_key(key)
_assert_plain_modifier(modifiers)
return not (_is_printable(key) and
- modifiers in [Qt.ShiftModifier, Qt.NoModifier,
- Qt.KeypadModifier])
+ modifiers in [Qt.ShiftModifier, Qt.NoModifier])
def is_modifier_key(key):
@@ -192,6 +196,16 @@ def is_modifier_key(key):
return key in _MODIFIER_MAP
+def _is_surrogate(key):
+ """Check if a codepoint is a UTF-16 surrogate.
+
+ UTF-16 surrogates are a reserved range of Unicode from 0xd800
+ to 0xd8ff, used to encode Unicode codepoints above the BMP
+ (Base Multilingual Plane).
+ """
+ return 0xd800 <= key <= 0xdfff
+
+
def _remap_unicode(key, text):
"""Work around QtKeyEvent's bad values for high codepoints.
@@ -380,8 +394,7 @@ class KeyInfo:
key_string = key_string.lower()
# "special" binding
- assert (is_special(self.key, self.modifiers) or
- self.modifiers == Qt.KeypadModifier)
+ assert is_special(self.key, self.modifiers)
modifier_string = _modifiers_to_string(modifiers)
return '<{}{}>'.format(modifier_string, key_string)