diff --git a/kitty/keys.py b/kitty/keys.py index f34402389..d17176930 100644 --- a/kitty/keys.py +++ b/kitty/keys.py @@ -27,6 +27,14 @@ key_map[defines.GLFW_KEY_ENTER] = b'\r' key_map[defines.GLFW_KEY_BACKSPACE] = b'\x08' key_map[defines.GLFW_KEY_TAB] = b'\t' +SHIFTED_KEYS = { + defines.GLFW_KEY_TAB: key_as_bytes('kcbt'), + defines.GLFW_KEY_HOME: key_as_bytes('kHOM'), + defines.GLFW_KEY_END: key_as_bytes('kEND'), + defines.GLFW_KEY_LEFT: key_as_bytes('kLFT'), + defines.GLFW_KEY_RIGHT: key_as_bytes('kRIT'), +} + control_codes = {k: 1 + i for i, k in enumerate(range(defines.GLFW_KEY_A, defines.GLFW_KEY_RIGHT_BRACKET))} alt_codes = {k: (0x1b, k) for i, k in enumerate(range(defines.GLFW_KEY_A, defines.GLFW_KEY_RIGHT_BRACKET))} @@ -43,8 +51,7 @@ def interpret_key_event(key, scancode, mods): x = key_map.get(key) if x is not None: if mods == defines.GLFW_MOD_SHIFT: - if key == defines.GLFW_KEY_TAB: - x = b'\x1b[Z' + x = SHIFTED_KEYS.get(key, x) data.extend(x) return bytes(data) diff --git a/kitty/terminfo.py b/kitty/terminfo.py index 21579f3fc..7db6da729 100644 --- a/kitty/terminfo.py +++ b/kitty/terminfo.py @@ -222,6 +222,18 @@ string_capabilities = { # Select alternate charset 'smacs': r'\E(0', 'rmacs': r'\E(B', + # Shifted keys + 'kRIT': r'\E[1;2C', + 'kLFT': r'\E[1;2D', + 'kEND': r'\E[1;2F', + 'kHOM': r'\E[1;2H', + # Special keys + 'khlp': r'', + 'kund': r'', + 'ka1': r'', + 'ka3': r'', + 'kc1': r'', + 'kc3': r'', } termcap_aliases.update({ @@ -317,7 +329,16 @@ termcap_aliases.update({ 'ZR': 'ritm', 'as': 'smacs', 'ae': 'rmacs', - + '#2': 'kHOM', + '#4': 'kLFT', + '*7': 'kEND', + '%i': 'kRIT', + '%1': 'khlp', + '&8': 'kund', + 'K1': 'ka1', + 'K3': 'ka3', + 'K4': 'kc1', + 'K5': 'kc3', }) queryable_capabilities = numeric_capabilities.copy() diff --git a/terminfo/kitty.terminfo b/terminfo/kitty.terminfo index bc915958e..63432bd0e 100644 --- a/terminfo/kitty.terminfo +++ b/terminfo/kitty.terminfo @@ -1,17 +1,17 @@ xterm-kitty|KovIdTTY, - xenl, msgr, + mir, npc, - am, + xenl, km, ccc, - mir, mc5i, - lines#24, - pairs#32767, - it#8, - cols#80, + am, colors#256, + it#8, + pairs#32767, + lines#24, + cols#80, acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, bold=\E[1m, @@ -50,6 +50,10 @@ xterm-kitty|KovIdTTY, il1=\E[L, ind=^J, indn=\E[%p1%dS, + kEND=\E[1;2F, + kHOM=\E[1;2H, + kLFT=\E[1;2D, + kRIT=\E[1;2C, kbs=\177, kcbt=\E[Z, kcub1=\EOD, @@ -70,6 +74,7 @@ xterm-kitty|KovIdTTY, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, + khlp=, khome=\EOH, kich1=\E[2~, kmous=\E[M, diff --git a/terminfo/x/xterm-kitty b/terminfo/x/xterm-kitty index 8f12e4f99..2faf77d5a 100644 Binary files a/terminfo/x/xterm-kitty and b/terminfo/x/xterm-kitty differ