Have the ctrl+shift+<key> generate the ASCII C0 control codes for the few shifted control codes there are.
See #285
This commit is contained in:
parent
0341cae922
commit
872d39eb2c
32
kitty/keys.h
generated
32
kitty/keys.h
generated
@ -760,6 +760,14 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
|
|||||||
} // end switch(key)
|
} // end switch(key)
|
||||||
case 0x3:
|
case 0x3:
|
||||||
switch(key & 0x7f) { default: return NULL;
|
switch(key & 0x7f) { default: return NULL;
|
||||||
|
case 3: // MINUS
|
||||||
|
return "\x01\x1f";
|
||||||
|
case 5: // SLASH
|
||||||
|
return "\x01\x7f";
|
||||||
|
case 8: // 2
|
||||||
|
return "\x01\x00";
|
||||||
|
case 12: // 6
|
||||||
|
return "\x01\x1e";
|
||||||
case 50: // ESCAPE
|
case 50: // ESCAPE
|
||||||
return "\x01\x1b";
|
return "\x01\x1b";
|
||||||
case 51: // ENTER
|
case 51: // ENTER
|
||||||
@ -1958,6 +1966,14 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
|
|||||||
} // end switch(key)
|
} // end switch(key)
|
||||||
case 0x3:
|
case 0x3:
|
||||||
switch(key & 0x7f) { default: return NULL;
|
switch(key & 0x7f) { default: return NULL;
|
||||||
|
case 3: // MINUS
|
||||||
|
return "\x01\x1f";
|
||||||
|
case 5: // SLASH
|
||||||
|
return "\x01\x7f";
|
||||||
|
case 8: // 2
|
||||||
|
return "\x01\x00";
|
||||||
|
case 12: // 6
|
||||||
|
return "\x01\x1e";
|
||||||
case 50: // ESCAPE
|
case 50: // ESCAPE
|
||||||
return "\x01\x1b";
|
return "\x01\x1b";
|
||||||
case 51: // ENTER
|
case 51: // ENTER
|
||||||
@ -3164,6 +3180,14 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
|
|||||||
} // end switch(key)
|
} // end switch(key)
|
||||||
case 0x3:
|
case 0x3:
|
||||||
switch(key & 0x7f) { default: return NULL;
|
switch(key & 0x7f) { default: return NULL;
|
||||||
|
case 3: // MINUS
|
||||||
|
return "\x01\x1f";
|
||||||
|
case 5: // SLASH
|
||||||
|
return "\x01\x7f";
|
||||||
|
case 8: // 2
|
||||||
|
return "\x01\x00";
|
||||||
|
case 12: // 6
|
||||||
|
return "\x01\x1e";
|
||||||
case 50: // ESCAPE
|
case 50: // ESCAPE
|
||||||
return "\x01\x1b";
|
return "\x01\x1b";
|
||||||
case 51: // ENTER
|
case 51: // ENTER
|
||||||
@ -4362,6 +4386,14 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) {
|
|||||||
} // end switch(key)
|
} // end switch(key)
|
||||||
case 0x3:
|
case 0x3:
|
||||||
switch(key & 0x7f) { default: return NULL;
|
switch(key & 0x7f) { default: return NULL;
|
||||||
|
case 3: // MINUS
|
||||||
|
return "\x01\x1f";
|
||||||
|
case 5: // SLASH
|
||||||
|
return "\x01\x7f";
|
||||||
|
case 8: // 2
|
||||||
|
return "\x01\x00";
|
||||||
|
case 12: // 6
|
||||||
|
return "\x01\x1e";
|
||||||
case 50: // ESCAPE
|
case 50: // ESCAPE
|
||||||
return "\x01\x1b";
|
return "\x01\x1b";
|
||||||
case 51: // ENTER
|
case 51: // ENTER
|
||||||
|
|||||||
@ -36,6 +36,7 @@ alt_codes = {
|
|||||||
shift_alt_codes = alt_codes.copy()
|
shift_alt_codes = alt_codes.copy()
|
||||||
shift_alt_codes[defines.GLFW_KEY_TAB] = key_as_bytes('kcbt')
|
shift_alt_codes[defines.GLFW_KEY_TAB] = key_as_bytes('kcbt')
|
||||||
alt_mods = (defines.GLFW_MOD_ALT, defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_ALT)
|
alt_mods = (defines.GLFW_MOD_ALT, defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_ALT)
|
||||||
|
ctrl_shift_mod = defines.GLFW_MOD_SHIFT | defines.GLFW_MOD_CONTROL
|
||||||
|
|
||||||
for kf, kn in {
|
for kf, kn in {
|
||||||
defines.GLFW_KEY_UP: 'kcuu1',
|
defines.GLFW_KEY_UP: 'kcuu1',
|
||||||
@ -189,6 +190,18 @@ 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()}
|
||||||
|
|
||||||
|
|
||||||
def key_to_bytes(key, smkx, extended, mods, action):
|
def key_to_bytes(key, smkx, extended, mods, action):
|
||||||
if extended:
|
if extended:
|
||||||
@ -197,6 +210,8 @@ def key_to_bytes(key, smkx, extended, mods, action):
|
|||||||
if mods == defines.GLFW_MOD_CONTROL and key in control_codes:
|
if mods == defines.GLFW_MOD_CONTROL and key in control_codes:
|
||||||
# Map Ctrl-key to ascii control code
|
# Map Ctrl-key to ascii control code
|
||||||
data.extend(control_codes[key])
|
data.extend(control_codes[key])
|
||||||
|
elif mods == ctrl_shift_mod and key in CTRL_SHIFT_KEYS:
|
||||||
|
data.extend(CTRL_SHIFT_KEYS[key])
|
||||||
elif mods in alt_mods:
|
elif mods in alt_mods:
|
||||||
if key in alt_codes:
|
if key in alt_codes:
|
||||||
data.extend((alt_codes if mods == defines.GLFW_MOD_ALT else shift_alt_codes)[key])
|
data.extend((alt_codes if mods == defines.GLFW_MOD_ALT else shift_alt_codes)[key])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user