Fix :kbd:ctrl+shift+special key not working in normal and application keyboard modes

Fixes #1114
This commit is contained in:
Kovid Goyal 2018-11-03 09:03:50 +05:30
parent d0a2eab79e
commit a958cabf01
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 57 additions and 53 deletions

View File

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

80
kitty/keys.h generated
View File

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

View File

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