From 7fd15be0719dcefbbfa105bf4adf0efa520b9807 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Nov 2016 12:36:37 +0530 Subject: [PATCH] Send the correct escape code for backspace --- kitty/keys.py | 2 +- kitty/terminfo.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/kitty/keys.py b/kitty/keys.py index d17176930..b66b09ae8 100644 --- a/kitty/keys.py +++ b/kitty/keys.py @@ -24,7 +24,7 @@ del f key_map[defines.GLFW_KEY_ESCAPE] = b'\033' key_map[defines.GLFW_KEY_ENTER] = b'\r' -key_map[defines.GLFW_KEY_BACKSPACE] = b'\x08' +key_map[defines.GLFW_KEY_BACKSPACE] = key_as_bytes('kbs') key_map[defines.GLFW_KEY_TAB] = b'\t' SHIFTED_KEYS = { diff --git a/kitty/terminfo.py b/kitty/terminfo.py index 5589e0e79..18bb80ad6 100644 --- a/kitty/terminfo.py +++ b/kitty/terminfo.py @@ -2,6 +2,7 @@ # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2016, Kovid Goyal +import re from binascii import unhexlify, hexlify names = 'xterm-kitty', 'KovIdTTY' @@ -360,9 +361,15 @@ def generate_terminfo(): return ',\n\t'.join(ans) + ',\n' +octal_escape = re.compile(r'\\([0-7]{3})') +escape_escape = re.compile(r'\\[eE]') + + def key_as_bytes(name): ans = string_capabilities[name] - return ans.replace(r'\E', '\033').encode('ascii') + ans = octal_escape.sub(lambda m: chr(int(m.group(1), 8)), ans) + ans = escape_escape.sub('\033', ans) + return ans.encode('ascii') def get_capabilities(query_string):