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"
This commit is contained in:
Jin Liu 2016-08-23 18:33:58 +08:00
parent f76e620be8
commit 4906a5f390

View file

@ -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