Improve key parsing with simple keys containing </>
This commit is contained in:
parent
1ba61bbcbe
commit
5d581d42f5
@ -149,6 +149,7 @@ def _parse_keystring(keystr):
|
||||
special = False
|
||||
for c in keystr:
|
||||
if c == '>':
|
||||
assert special
|
||||
yield normalize_keystr(key)
|
||||
key = ''
|
||||
special = False
|
||||
@ -158,6 +159,10 @@ def _parse_keystring(keystr):
|
||||
key += c
|
||||
else:
|
||||
yield 'Shift+' + c if c.isupper() else c
|
||||
if special:
|
||||
yield '<'
|
||||
for c in key:
|
||||
yield 'Shift+' + c if c.isupper() else c
|
||||
|
||||
|
||||
def normalize_keystr(keystr):
|
||||
@ -389,6 +394,7 @@ class KeySequence:
|
||||
@classmethod
|
||||
def parse(cls, keystr):
|
||||
"""Parse a keystring like <Ctrl-x> or xyz and return a KeySequence."""
|
||||
# FIXME: test stuff like <a, a>
|
||||
new = cls()
|
||||
strings = list(_parse_keystring(keystr))
|
||||
for sub in utils.chunk(strings, cls._MAX_LEN):
|
||||
@ -396,8 +402,7 @@ class KeySequence:
|
||||
new._sequences.append(sequence)
|
||||
|
||||
if keystr:
|
||||
# FIXME fails with "<ctrl-x"
|
||||
assert len(new) > 0
|
||||
assert len(new) > 0, keystr
|
||||
|
||||
new._validate(keystr)
|
||||
return new
|
||||
|
Loading…
Reference in New Issue
Block a user