diff options
author | hut <hut@lavabit.com> | 2011-10-11 18:01:42 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-10-11 18:01:42 +0200 |
commit | 0ba7fec7d93d802d140d464baaa3db63044bf6b2 (patch) | |
tree | e3a720d1ceab8a2e117e3c4fb1acfab80f8e220b | |
parent | 02b078eeb5ff1987552c68e61e4b14644e0cc0ae (diff) | |
download | ranger-0ba7fec7d93d802d140d464baaa3db63044bf6b2.tar.gz |
ext.keybinding_parser: Prettier key_to_string()
-rw-r--r-- | ranger/core/main.py | 4 | ||||
-rw-r--r-- | ranger/ext/keybinding_parser.py | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py index bb920e71..c87a4660 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -79,9 +79,9 @@ def main(): load_settings(fm, arg.clean) if arg.list_unused_keys: - from ranger.ext.keybinding_parser import special_keys + from ranger.ext.keybinding_parser import (special_keys, + reversed_special_keys) maps = fm.env.keymaps['browser'] - reversed_special_keys = dict((v,k) for k,v in special_keys.items()) for key in sorted(special_keys.values(), key=lambda x: str(x)): if key not in maps: print("<%s>" % reversed_special_keys[key]) diff --git a/ranger/ext/keybinding_parser.py b/ranger/ext/keybinding_parser.py index 90402fe3..702cd90e 100644 --- a/ranger/ext/keybinding_parser.py +++ b/ranger/ext/keybinding_parser.py @@ -49,6 +49,7 @@ special_keys = { very_special_keys = { 'any': ANYKEY, + 'alt': ALT_KEY, 'bg': PASSIVE_ACTION, 'allow_quantifiers': QUANT_KEY, } @@ -66,6 +67,8 @@ for n in range(64): special_keys['f' + str(n)] = curses.KEY_F0 + n special_keys.update(very_special_keys) +del very_special_keys +reverse_special_keys = dict((v, k) for k, v in special_keys.items()) def parse_keybinding(obj): @@ -127,7 +130,11 @@ def construct_keybinding(iterable): def key_to_string(key): - return chr(key) if key in range(32, 127) else '?' + if key in range(33, 127): + return chr(key) + if key in reverse_special_keys: + return "<%s>" % reverse_special_keys[key] + return "<%s>" % str(key) def _unbind_traverse(pointer, keys, pos=0): |