From 71569b7201925274f3a97dd24e8e735f50bc9a53 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 19 May 2011 16:08:04 +0200 Subject: ranger/gui/ui: Fixed issues with ALT key was treated equal to x internally, which is clearly wrong. As a result, the mapping will override previous mappings. This was fixed by translating to x with being a special token for the keyparser. I hope this doesn't cause any trouble. Also, ALT+letter keys were fixed when using xterm-compatibility mode. (Option xterm_alt_key = True) --- ranger/ext/keybinding_parser.py | 5 +++-- 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: -- cgit 1.4.1-2-gfad0