diff options
-rw-r--r-- | ranger/ext/keybinding_parser.py | 5 | ||||
-rw-r--r-- | ranger/gui/ui.py | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/ranger/ext/keybinding_parser.py b/ranger/ext/keybinding_parser.py index 93119bce..bfd1b6d4 100644 --- a/ranger/ext/keybinding_parser.py +++ b/ranger/ext/keybinding_parser.py @@ -67,6 +67,7 @@ def parse_keybinding(obj): DIRKEY = 9001 ANYKEY = 9002 PASSIVE_ACTION = 9003 +ALT_KEY = 9004 very_special_keys = { 'dir': DIRKEY, @@ -98,10 +99,10 @@ special_keys = { } for key, val in tuple(special_keys.items()): - special_keys['a-' + key] = (27, val) + special_keys['a-' + key] = (ALT_KEY, val) for char in ascii_lowercase + '0123456789': - special_keys['a-' + char] = (27, ord(char)) + special_keys['a-' + char] = (ALT_KEY, ord(char)) for char in ascii_lowercase: special_keys['c-' + char] = ord(char) - 96 diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index a2babed8..cc2871af 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -22,6 +22,7 @@ from .displayable import DisplayableContainer from ranger.gui.curses_shortcuts import ascii_only from ranger.container.keymap import CommandArgs from .mouse_event import MouseEvent +from ranger.ext.keybinding_parser import ALT_KEY TERMINALS_WITH_TITLE = ("xterm", "xterm-256color", "rxvt", "rxvt-256color", "rxvt-unicode", "aterm", "Eterm", @@ -183,9 +184,14 @@ class UI(DisplayableContainer): keys.append(getkey) if len(keys) == 1: keys.append(-1) + elif keys[0] == 27: + keys[0] = ALT_KEY if self.settings.xterm_alt_key: if len(keys) == 2 and keys[1] in range(127, 256): - keys = [27, keys[1] - 128] + if keys[0] == 195: + keys = [ALT_KEY, keys[1] - 64] + elif keys[0] == 194: + keys = [ALT_KEY, keys[1] - 128] self.handle_keys(*keys) self.set_load_mode(previous_load_mode) if self.settings.flushinput and not self.console.visible: |