From 4906a5f3907c256588db7f33315104a2029f6069 Mon Sep 17 00:00:00 2001 From: Jin Liu Date: Tue, 23 Aug 2016 18:33:58 +0800 Subject: [PATCH] fish_config: fix keybinding parser bugs 1. \r shown as r 2. putty-specific Home/End 3. backspace 4. show unparsable sequence as "unknown-control-sequence" --- share/tools/web_config/webconfig.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index ffd41aba7..2f33fe2db 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -351,8 +351,10 @@ class BindingParser: # \[1\; is start of control sequence if c == '1': - self.get_char();c = self.get_char() - if c == ";": + b = self.get_char(); c = self.get_char() + if b == '\\' and c == '~': + result += "Home" + elif c == ";": c = self.get_char() # 3 is Alt @@ -360,6 +362,12 @@ class BindingParser: result += "ALT - " c = self.get_char() + # \[4\~ is End + if c == '4': + b = self.get_char(); c = self.get_char() + if b == '\\' and c == '~': + result += "End" + # 5 is Ctrl if c == '5': result += "CTRL - " @@ -430,14 +438,21 @@ class BindingParser: result += 'Tab' elif c == 'b': result += 'Backspace' + elif c.isalpha(): + result += '\\' + c else: result += c + elif c == '\x7f': + result += 'Backspace' else: result += c if ctrl: readable_command += 'CTRL - ' if alt: readable_command += 'ALT - ' + + if result == '': + return 'unknown-control-sequence' return readable_command + result