Fix ctrl+alt+<special> not working in normal and application keyboard modes.

Fixes #548
This commit is contained in:
Kovid Goyal 2018-05-17 20:43:18 +05:30
parent 6ae58e6882
commit 7c47bd547f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 97 additions and 90 deletions

176
kitty/keys.h generated
View File

@ -1291,49 +1291,49 @@ 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\x37\x7e";
case 55: // DELETE
return "\x04\x1b\x5b\x33\x7e";
return "\x06\x1b\x5b\x33\x3b\x37\x7e";
case 56: // RIGHT
return "\x03\x1b\x5b\x43";
return "\x06\x1b\x5b\x31\x3b\x37\x43";
case 57: // LEFT
return "\x03\x1b\x5b\x44";
return "\x06\x1b\x5b\x31\x3b\x37\x44";
case 58: // DOWN
return "\x03\x1b\x5b\x42";
return "\x06\x1b\x5b\x31\x3b\x37\x42";
case 59: // UP
return "\x03\x1b\x5b\x41";
return "\x06\x1b\x5b\x31\x3b\x37\x41";
case 60: // PAGE_UP
return "\x04\x1b\x5b\x35\x7e";
return "\x06\x1b\x5b\x35\x3b\x37\x7e";
case 61: // PAGE_DOWN
return "\x04\x1b\x5b\x36\x7e";
return "\x06\x1b\x5b\x36\x3b\x37\x7e";
case 62: // HOME
return "\x03\x1b\x5b\x48";
return "\x06\x1b\x5b\x31\x3b\x37\x48";
case 63: // END
return "\x03\x1b\x5b\x46";
return "\x06\x1b\x5b\x31\x3b\x37\x46";
case 69: // F1
return "\x03\x1b\x4f\x50";
return "\x06\x1b\x5b\x31\x3b\x37\x50";
case 70: // F2
return "\x03\x1b\x4f\x51";
return "\x06\x1b\x5b\x31\x3b\x37\x51";
case 71: // F3
return "\x03\x1b\x4f\x52";
return "\x06\x1b\x5b\x31\x3b\x37\x52";
case 72: // F4
return "\x03\x1b\x4f\x53";
return "\x06\x1b\x5b\x31\x3b\x37\x53";
case 73: // F5
return "\x05\x1b\x5b\x31\x35\x7e";
return "\x07\x1b\x5b\x31\x35\x3b\x37\x7e";
case 74: // F6
return "\x05\x1b\x5b\x31\x37\x7e";
return "\x07\x1b\x5b\x31\x37\x3b\x37\x7e";
case 75: // F7
return "\x05\x1b\x5b\x31\x38\x7e";
return "\x07\x1b\x5b\x31\x38\x3b\x37\x7e";
case 76: // F8
return "\x05\x1b\x5b\x31\x39\x7e";
return "\x07\x1b\x5b\x31\x39\x3b\x37\x7e";
case 77: // F9
return "\x05\x1b\x5b\x32\x30\x7e";
return "\x07\x1b\x5b\x32\x30\x3b\x37\x7e";
case 78: // F10
return "\x05\x1b\x5b\x32\x31\x7e";
return "\x07\x1b\x5b\x32\x31\x3b\x37\x7e";
case 79: // F11
return "\x05\x1b\x5b\x32\x33\x7e";
return "\x07\x1b\x5b\x32\x33\x3b\x37\x7e";
case 80: // F12
return "\x05\x1b\x5b\x32\x34\x7e";
return "\x07\x1b\x5b\x32\x34\x3b\x37\x7e";
case 81: // F13
return "\x06\x1b\x5b\x31\x3b\x32\x50";
case 82: // F14
@ -2914,49 +2914,49 @@ 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\x37\x7e";
case 55: // DELETE
return "\x04\x1b\x5b\x33\x7e";
return "\x06\x1b\x5b\x33\x3b\x37\x7e";
case 56: // RIGHT
return "\x03\x1b\x5b\x43";
return "\x06\x1b\x5b\x31\x3b\x37\x43";
case 57: // LEFT
return "\x03\x1b\x5b\x44";
return "\x06\x1b\x5b\x31\x3b\x37\x44";
case 58: // DOWN
return "\x03\x1b\x5b\x42";
return "\x06\x1b\x5b\x31\x3b\x37\x42";
case 59: // UP
return "\x03\x1b\x5b\x41";
return "\x06\x1b\x5b\x31\x3b\x37\x41";
case 60: // PAGE_UP
return "\x04\x1b\x5b\x35\x7e";
return "\x06\x1b\x5b\x35\x3b\x37\x7e";
case 61: // PAGE_DOWN
return "\x04\x1b\x5b\x36\x7e";
return "\x06\x1b\x5b\x36\x3b\x37\x7e";
case 62: // HOME
return "\x03\x1b\x5b\x48";
return "\x06\x1b\x5b\x31\x3b\x37\x48";
case 63: // END
return "\x03\x1b\x5b\x46";
return "\x06\x1b\x5b\x31\x3b\x37\x46";
case 69: // F1
return "\x03\x1b\x4f\x50";
return "\x06\x1b\x5b\x31\x3b\x37\x50";
case 70: // F2
return "\x03\x1b\x4f\x51";
return "\x06\x1b\x5b\x31\x3b\x37\x51";
case 71: // F3
return "\x03\x1b\x4f\x52";
return "\x06\x1b\x5b\x31\x3b\x37\x52";
case 72: // F4
return "\x03\x1b\x4f\x53";
return "\x06\x1b\x5b\x31\x3b\x37\x53";
case 73: // F5
return "\x05\x1b\x5b\x31\x35\x7e";
return "\x07\x1b\x5b\x31\x35\x3b\x37\x7e";
case 74: // F6
return "\x05\x1b\x5b\x31\x37\x7e";
return "\x07\x1b\x5b\x31\x37\x3b\x37\x7e";
case 75: // F7
return "\x05\x1b\x5b\x31\x38\x7e";
return "\x07\x1b\x5b\x31\x38\x3b\x37\x7e";
case 76: // F8
return "\x05\x1b\x5b\x31\x39\x7e";
return "\x07\x1b\x5b\x31\x39\x3b\x37\x7e";
case 77: // F9
return "\x05\x1b\x5b\x32\x30\x7e";
return "\x07\x1b\x5b\x32\x30\x3b\x37\x7e";
case 78: // F10
return "\x05\x1b\x5b\x32\x31\x7e";
return "\x07\x1b\x5b\x32\x31\x3b\x37\x7e";
case 79: // F11
return "\x05\x1b\x5b\x32\x33\x7e";
return "\x07\x1b\x5b\x32\x33\x3b\x37\x7e";
case 80: // F12
return "\x05\x1b\x5b\x32\x34\x7e";
return "\x07\x1b\x5b\x32\x34\x3b\x37\x7e";
case 81: // F13
return "\x06\x1b\x5b\x31\x3b\x32\x50";
case 82: // F14
@ -4546,49 +4546,49 @@ 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\x37\x7e";
case 55: // DELETE
return "\x04\x1b\x5b\x33\x7e";
return "\x06\x1b\x5b\x33\x3b\x37\x7e";
case 56: // RIGHT
return "\x03\x1b\x4f\x43";
return "\x06\x1b\x5b\x31\x3b\x37\x43";
case 57: // LEFT
return "\x03\x1b\x4f\x44";
return "\x06\x1b\x5b\x31\x3b\x37\x44";
case 58: // DOWN
return "\x03\x1b\x4f\x42";
return "\x06\x1b\x5b\x31\x3b\x37\x42";
case 59: // UP
return "\x03\x1b\x4f\x41";
return "\x06\x1b\x5b\x31\x3b\x37\x41";
case 60: // PAGE_UP
return "\x04\x1b\x5b\x35\x7e";
return "\x06\x1b\x5b\x35\x3b\x37\x7e";
case 61: // PAGE_DOWN
return "\x04\x1b\x5b\x36\x7e";
return "\x06\x1b\x5b\x36\x3b\x37\x7e";
case 62: // HOME
return "\x03\x1b\x4f\x48";
return "\x06\x1b\x5b\x31\x3b\x37\x48";
case 63: // END
return "\x03\x1b\x4f\x46";
return "\x06\x1b\x5b\x31\x3b\x37\x46";
case 69: // F1
return "\x03\x1b\x4f\x50";
return "\x06\x1b\x5b\x31\x3b\x37\x50";
case 70: // F2
return "\x03\x1b\x4f\x51";
return "\x06\x1b\x5b\x31\x3b\x37\x51";
case 71: // F3
return "\x03\x1b\x4f\x52";
return "\x06\x1b\x5b\x31\x3b\x37\x52";
case 72: // F4
return "\x03\x1b\x4f\x53";
return "\x06\x1b\x5b\x31\x3b\x37\x53";
case 73: // F5
return "\x05\x1b\x5b\x31\x35\x7e";
return "\x07\x1b\x5b\x31\x35\x3b\x37\x7e";
case 74: // F6
return "\x05\x1b\x5b\x31\x37\x7e";
return "\x07\x1b\x5b\x31\x37\x3b\x37\x7e";
case 75: // F7
return "\x05\x1b\x5b\x31\x38\x7e";
return "\x07\x1b\x5b\x31\x38\x3b\x37\x7e";
case 76: // F8
return "\x05\x1b\x5b\x31\x39\x7e";
return "\x07\x1b\x5b\x31\x39\x3b\x37\x7e";
case 77: // F9
return "\x05\x1b\x5b\x32\x30\x7e";
return "\x07\x1b\x5b\x32\x30\x3b\x37\x7e";
case 78: // F10
return "\x05\x1b\x5b\x32\x31\x7e";
return "\x07\x1b\x5b\x32\x31\x3b\x37\x7e";
case 79: // F11
return "\x05\x1b\x5b\x32\x33\x7e";
return "\x07\x1b\x5b\x32\x33\x3b\x37\x7e";
case 80: // F12
return "\x05\x1b\x5b\x32\x34\x7e";
return "\x07\x1b\x5b\x32\x34\x3b\x37\x7e";
case 81: // F13
return "\x06\x1b\x5b\x31\x3b\x32\x50";
case 82: // F14
@ -6169,49 +6169,49 @@ 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\x37\x7e";
case 55: // DELETE
return "\x04\x1b\x5b\x33\x7e";
return "\x06\x1b\x5b\x33\x3b\x37\x7e";
case 56: // RIGHT
return "\x03\x1b\x4f\x43";
return "\x06\x1b\x5b\x31\x3b\x37\x43";
case 57: // LEFT
return "\x03\x1b\x4f\x44";
return "\x06\x1b\x5b\x31\x3b\x37\x44";
case 58: // DOWN
return "\x03\x1b\x4f\x42";
return "\x06\x1b\x5b\x31\x3b\x37\x42";
case 59: // UP
return "\x03\x1b\x4f\x41";
return "\x06\x1b\x5b\x31\x3b\x37\x41";
case 60: // PAGE_UP
return "\x04\x1b\x5b\x35\x7e";
return "\x06\x1b\x5b\x35\x3b\x37\x7e";
case 61: // PAGE_DOWN
return "\x04\x1b\x5b\x36\x7e";
return "\x06\x1b\x5b\x36\x3b\x37\x7e";
case 62: // HOME
return "\x03\x1b\x4f\x48";
return "\x06\x1b\x5b\x31\x3b\x37\x48";
case 63: // END
return "\x03\x1b\x4f\x46";
return "\x06\x1b\x5b\x31\x3b\x37\x46";
case 69: // F1
return "\x03\x1b\x4f\x50";
return "\x06\x1b\x5b\x31\x3b\x37\x50";
case 70: // F2
return "\x03\x1b\x4f\x51";
return "\x06\x1b\x5b\x31\x3b\x37\x51";
case 71: // F3
return "\x03\x1b\x4f\x52";
return "\x06\x1b\x5b\x31\x3b\x37\x52";
case 72: // F4
return "\x03\x1b\x4f\x53";
return "\x06\x1b\x5b\x31\x3b\x37\x53";
case 73: // F5
return "\x05\x1b\x5b\x31\x35\x7e";
return "\x07\x1b\x5b\x31\x35\x3b\x37\x7e";
case 74: // F6
return "\x05\x1b\x5b\x31\x37\x7e";
return "\x07\x1b\x5b\x31\x37\x3b\x37\x7e";
case 75: // F7
return "\x05\x1b\x5b\x31\x38\x7e";
return "\x07\x1b\x5b\x31\x38\x3b\x37\x7e";
case 76: // F8
return "\x05\x1b\x5b\x31\x39\x7e";
return "\x07\x1b\x5b\x31\x39\x3b\x37\x7e";
case 77: // F9
return "\x05\x1b\x5b\x32\x30\x7e";
return "\x07\x1b\x5b\x32\x30\x3b\x37\x7e";
case 78: // F10
return "\x05\x1b\x5b\x32\x31\x7e";
return "\x07\x1b\x5b\x32\x31\x3b\x37\x7e";
case 79: // F11
return "\x05\x1b\x5b\x32\x33\x7e";
return "\x07\x1b\x5b\x32\x33\x3b\x37\x7e";
case 80: // F12
return "\x05\x1b\x5b\x32\x34\x7e";
return "\x07\x1b\x5b\x32\x34\x3b\x37\x7e";
case 81: // F13
return "\x06\x1b\x5b\x31\x3b\x32\x50";
case 82: // F14

View File

@ -49,6 +49,7 @@ def modify_complex_key(name, amt):
defines.GLFW_KEY_DOWN: key_as_bytes('kind'),
}
control_alt_codes = {}
for kf, kn in {
defines.GLFW_KEY_UP: 'kcuu1',
@ -66,6 +67,7 @@ def modify_complex_key(name, amt):
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_alt_codes[kf] = modify_complex_key(kn, 7)
for f in range(1, 13):
kf = getattr(defines, 'GLFW_KEY_F{}'.format(f))
kn = 'kf{}'.format(f)
@ -74,6 +76,7 @@ def modify_complex_key(name, amt):
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_alt_codes[kf] = modify_complex_key(kn, 7)
for f in range(13, 26):
kf = getattr(defines, 'GLFW_KEY_F{}'.format(f))
kn = 'kf{}'.format(f)
@ -213,6 +216,7 @@ def pmap(names, r):
}
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)
def key_to_bytes(key, smkx, extended, mods, action):
@ -231,8 +235,11 @@ def key_to_bytes(key, smkx, extended, mods, action):
m = UN_SHIFTED_PRINTABLE if mods == defines.GLFW_MOD_ALT else SHIFTED_PRINTABLE
data.append(0o33)
data.extend(m[key])
elif mods == ctrl_alt_mod and key in CTRL_ALT_KEYS:
data.append(0x1b), data.extend(control_codes[key])
elif mods == ctrl_alt_mod and key in all_control_alt_keys:
if key in CTRL_ALT_KEYS:
data.append(0x1b), data.extend(control_codes[key])
else:
data.extend(control_alt_codes[key])
else:
key_map = cursor_key_mode_map[smkx]
x = key_map.get(key)