Fix binding of special keys with lower-case mods.

This commit is contained in:
Florian Bruhin 2015-04-13 22:08:57 +02:00
parent 982733e1f4
commit a6e3199616
2 changed files with 9 additions and 6 deletions

View File

@ -362,17 +362,18 @@ def normalize_keystr(keystr):
Return:
The normalized keystring.
"""
keystr = keystr.lower()
replacements = (
('Control', 'Ctrl'),
('Windows', 'Meta'),
('Mod1', 'Alt'),
('Mod4', 'Meta'),
('control', 'ctrl'),
('windows', 'meta'),
('mod1', 'alt'),
('mod4', 'meta'),
)
for (orig, repl) in replacements:
keystr = keystr.replace(orig, repl)
for mod in ('Ctrl', 'Meta', 'Alt', 'Shift'):
for mod in ('ctrl', 'meta', 'alt', 'shift'):
keystr = keystr.replace(mod + '-', mod + '+')
return keystr.lower()
return keystr
class FakeIOStream(io.TextIOBase):

View File

@ -337,6 +337,8 @@ class TestNormalize:
('Mod4+x', 'meta+x'),
('Control--', 'ctrl+-'),
('Windows++', 'meta++'),
('ctrl-x', 'ctrl+x'),
('control+x', 'ctrl+x')
)
@pytest.mark.parametrize('orig, repl', STRINGS)