summaryrefslogtreecommitdiff
path: root/qutebrowser/keyinput/basekeyparser.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-09-12 11:53:36 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-09-12 16:32:56 +0200
commit74cbb5add0a4647555933ffd66e79d4c5c0ae3f8 (patch)
treef8109fb1c5dbd73c40161c445b5d25aa81b94681 /qutebrowser/keyinput/basekeyparser.py
parentf8689774a0f6f6b844853c0658849573c4d668b8 (diff)
downloadqutebrowser-74cbb5add0a4647555933ffd66e79d4c5c0ae3f8.tar.gz
qutebrowser-74cbb5add0a4647555933ffd66e79d4c5c0ae3f8.zip
Make KeyInfo hashable
This way, we can store the real KeyInfo objects in BindingTrie instead of having to use .to_int().
Diffstat (limited to 'qutebrowser/keyinput/basekeyparser.py')
-rw-r--r--qutebrowser/keyinput/basekeyparser.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py
index 730bafb4a..1cbb71fe0 100644
--- a/qutebrowser/keyinput/basekeyparser.py
+++ b/qutebrowser/keyinput/basekeyparser.py
@@ -46,15 +46,14 @@ class BindingTrie(collections.abc.MutableMapping):
method added.
Attributes:
- child: A map. Keys of this map can be get from the KeyInfo.to_int
- method.
+ child: A mapping from KeyInfo to children BindingTries.
command: Command associated with this trie node.
"""
__slots__ = 'child', 'command'
def __init__(self):
- self.child = {} # type: MutableMapping[int, BindingTrie]
+ self.child = {} # type: MutableMapping[keyutils.KeyInfo, BindingTrie]
self.command = None # type: Optional[str]
def __getitem__(self, sequence: keyutils.KeySequence):
@@ -67,10 +66,9 @@ class BindingTrie(collections.abc.MutableMapping):
self, sequence: keyutils.KeySequence, command: str):
node = self
for key in sequence:
- key_int = key.to_int()
- if key_int not in node.child:
- node.child[key_int] = BindingTrie()
- node = node.child[key_int]
+ if key not in node.child:
+ node.child[key] = BindingTrie()
+ node = node.child[key]
node.command = command
@@ -100,7 +98,7 @@ class BindingTrie(collections.abc.MutableMapping):
node = self
for key in sequence:
try:
- node = node.child[key.to_int()]
+ node = node.child[key]
except KeyError:
return QKeySequence.NoMatch, None