From a958cabf01b6669aa8b1bc61e62ea1d46792bd86 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Nov 2018 09:03:50 +0530 Subject: [PATCH] Fix :kbd:`ctrl+shift+special` key not working in normal and application keyboard modes Fixes #1114 --- docs/changelog.rst | 3 ++ kitty/keys.h | 80 +++++++++++++++++++++++----------------------- kitty/keys.py | 27 ++++++++-------- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 23037e9c8..283be1d92 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -66,6 +66,9 @@ Changelog - Fix focusing neighboring windows in the grid layout with less than 4 windows not working (:iss:`1115`) +- Fix :kbd:`ctrl+shift+special` key not working in normal and application keyboard + modes (:iss:`1114`) + 0.12.3 [2018-09-29] ------------------------------ diff --git a/kitty/keys.h b/kitty/keys.h index 67f4697cb..15948a99d 100644 --- a/kitty/keys.h +++ b/kitty/keys.h @@ -856,25 +856,25 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { case 53: // BACKSPACE return "\x01\x7f"; case 54: // INSERT - return "\x04\x1b\x5b\x32\x7e"; + return "\x06\x1b\x5b\x32\x3b\x36\x7e"; case 55: // DELETE - return "\x04\x1b\x5b\x33\x7e"; + return "\x06\x1b\x5b\x33\x3b\x36\x7e"; case 56: // RIGHT - return "\x03\x1b\x5b\x43"; + return "\x06\x1b\x5b\x31\x3b\x36\x43"; case 57: // LEFT - return "\x03\x1b\x5b\x44"; + return "\x06\x1b\x5b\x31\x3b\x36\x44"; case 58: // DOWN - return "\x03\x1b\x5b\x42"; + return "\x06\x1b\x5b\x31\x3b\x36\x42"; case 59: // UP - return "\x03\x1b\x5b\x41"; + return "\x06\x1b\x5b\x31\x3b\x36\x41"; case 60: // PAGE_UP - return "\x04\x1b\x5b\x35\x7e"; + return "\x06\x1b\x5b\x35\x3b\x36\x7e"; case 61: // PAGE_DOWN - return "\x04\x1b\x5b\x36\x7e"; + return "\x06\x1b\x5b\x36\x3b\x36\x7e"; case 62: // HOME - return "\x03\x1b\x5b\x48"; + return "\x06\x1b\x5b\x31\x3b\x36\x48"; case 63: // END - return "\x03\x1b\x5b\x46"; + return "\x06\x1b\x5b\x31\x3b\x36\x46"; case 69: // F1 return "\x03\x1b\x4f\x50"; case 70: // F2 @@ -2483,25 +2483,25 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { case 53: // BACKSPACE return "\x01\x7f"; case 54: // INSERT - return "\x04\x1b\x5b\x32\x7e"; + return "\x06\x1b\x5b\x32\x3b\x36\x7e"; case 55: // DELETE - return "\x04\x1b\x5b\x33\x7e"; + return "\x06\x1b\x5b\x33\x3b\x36\x7e"; case 56: // RIGHT - return "\x03\x1b\x5b\x43"; + return "\x06\x1b\x5b\x31\x3b\x36\x43"; case 57: // LEFT - return "\x03\x1b\x5b\x44"; + return "\x06\x1b\x5b\x31\x3b\x36\x44"; case 58: // DOWN - return "\x03\x1b\x5b\x42"; + return "\x06\x1b\x5b\x31\x3b\x36\x42"; case 59: // UP - return "\x03\x1b\x5b\x41"; + return "\x06\x1b\x5b\x31\x3b\x36\x41"; case 60: // PAGE_UP - return "\x04\x1b\x5b\x35\x7e"; + return "\x06\x1b\x5b\x35\x3b\x36\x7e"; case 61: // PAGE_DOWN - return "\x04\x1b\x5b\x36\x7e"; + return "\x06\x1b\x5b\x36\x3b\x36\x7e"; case 62: // HOME - return "\x03\x1b\x5b\x48"; + return "\x06\x1b\x5b\x31\x3b\x36\x48"; case 63: // END - return "\x03\x1b\x5b\x46"; + return "\x06\x1b\x5b\x31\x3b\x36\x46"; case 69: // F1 return "\x03\x1b\x4f\x50"; case 70: // F2 @@ -4119,25 +4119,25 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { case 53: // BACKSPACE return "\x01\x7f"; case 54: // INSERT - return "\x04\x1b\x5b\x32\x7e"; + return "\x06\x1b\x5b\x32\x3b\x36\x7e"; case 55: // DELETE - return "\x04\x1b\x5b\x33\x7e"; + return "\x06\x1b\x5b\x33\x3b\x36\x7e"; case 56: // RIGHT - return "\x03\x1b\x4f\x43"; + return "\x06\x1b\x5b\x31\x3b\x36\x43"; case 57: // LEFT - return "\x03\x1b\x4f\x44"; + return "\x06\x1b\x5b\x31\x3b\x36\x44"; case 58: // DOWN - return "\x03\x1b\x4f\x42"; + return "\x06\x1b\x5b\x31\x3b\x36\x42"; case 59: // UP - return "\x03\x1b\x4f\x41"; + return "\x06\x1b\x5b\x31\x3b\x36\x41"; case 60: // PAGE_UP - return "\x04\x1b\x5b\x35\x7e"; + return "\x06\x1b\x5b\x35\x3b\x36\x7e"; case 61: // PAGE_DOWN - return "\x04\x1b\x5b\x36\x7e"; + return "\x06\x1b\x5b\x36\x3b\x36\x7e"; case 62: // HOME - return "\x03\x1b\x4f\x48"; + return "\x06\x1b\x5b\x31\x3b\x36\x48"; case 63: // END - return "\x03\x1b\x4f\x46"; + return "\x06\x1b\x5b\x31\x3b\x36\x46"; case 69: // F1 return "\x03\x1b\x4f\x50"; case 70: // F2 @@ -5746,25 +5746,25 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { case 53: // BACKSPACE return "\x01\x7f"; case 54: // INSERT - return "\x04\x1b\x5b\x32\x7e"; + return "\x06\x1b\x5b\x32\x3b\x36\x7e"; case 55: // DELETE - return "\x04\x1b\x5b\x33\x7e"; + return "\x06\x1b\x5b\x33\x3b\x36\x7e"; case 56: // RIGHT - return "\x03\x1b\x4f\x43"; + return "\x06\x1b\x5b\x31\x3b\x36\x43"; case 57: // LEFT - return "\x03\x1b\x4f\x44"; + return "\x06\x1b\x5b\x31\x3b\x36\x44"; case 58: // DOWN - return "\x03\x1b\x4f\x42"; + return "\x06\x1b\x5b\x31\x3b\x36\x42"; case 59: // UP - return "\x03\x1b\x4f\x41"; + return "\x06\x1b\x5b\x31\x3b\x36\x41"; case 60: // PAGE_UP - return "\x04\x1b\x5b\x35\x7e"; + return "\x06\x1b\x5b\x35\x3b\x36\x7e"; case 61: // PAGE_DOWN - return "\x04\x1b\x5b\x36\x7e"; + return "\x06\x1b\x5b\x36\x3b\x36\x7e"; case 62: // HOME - return "\x03\x1b\x4f\x48"; + return "\x06\x1b\x5b\x31\x3b\x36\x48"; case 63: // END - return "\x03\x1b\x4f\x46"; + return "\x06\x1b\x5b\x31\x3b\x36\x46"; case 69: // F1 return "\x03\x1b\x4f\x50"; case 70: // F2 diff --git a/kitty/keys.py b/kitty/keys.py index 63965fb43..97675fedf 100644 --- a/kitty/keys.py +++ b/kitty/keys.py @@ -54,6 +54,17 @@ SHIFTED_KEYS = { control_alt_codes = { defines.GLFW_KEY_SPACE: b'\x1b\0', } +ASCII_C0_SHIFTED = { + # ^@ + '2': b'\x00', + # ^^ + '6': b'\x1e', + # ^_ + 'MINUS': b'\x1f', + # ^? + 'SLASH': b'\x7f', +} +control_shift_keys = {getattr(defines, 'GLFW_KEY_' + k): v for k, v in ASCII_C0_SHIFTED.items()} for kf, kn in { defines.GLFW_KEY_UP: 'kcuu1', @@ -71,6 +82,7 @@ for kf, kn in { alt_codes[kf] = modify_complex_key(kn, 3) shift_alt_codes[kf] = modify_complex_key(kn, 4) control_codes[kf] = modify_complex_key(kn, 5) + control_shift_keys[kf] = modify_complex_key(kn, 6) control_alt_codes[kf] = modify_complex_key(kn, 7) for f in range(1, 13): kf = getattr(defines, 'GLFW_KEY_F{}'.format(f)) @@ -215,17 +227,6 @@ SHIFTED_PRINTABLE.update(pmap( "{|}~" )) -ASCII_C0_SHIFTED = { - # ^@ - '2': b'\x00', - # ^^ - '6': b'\x1e', - # ^_ - 'MINUS': b'\x1f', - # ^? - 'SLASH': b'\x7f', -} -CTRL_SHIFT_KEYS = {getattr(defines, 'GLFW_KEY_' + k): v for k, v in ASCII_C0_SHIFTED.items()} CTRL_ALT_KEYS = {getattr(defines, 'GLFW_KEY_' + k) for k in string.ascii_uppercase} all_control_alt_keys = set(CTRL_ALT_KEYS) | set(control_alt_codes) @@ -237,8 +238,8 @@ def key_to_bytes(key, smkx, extended, mods, action): if mods == defines.GLFW_MOD_CONTROL and key in control_codes: # Map Ctrl-key to ascii control code data.extend(control_codes[key]) - elif mods == ctrl_shift_mod and key in CTRL_SHIFT_KEYS: - data.extend(CTRL_SHIFT_KEYS[key]) + elif mods == ctrl_shift_mod and key in control_shift_keys: + data.extend(control_shift_keys[key]) elif mods in alt_mods: if key in alt_codes: data.extend((alt_codes if mods == defines.GLFW_MOD_ALT else shift_alt_codes)[key])