A few fixes for the extended key protocol

This commit is contained in:
Kovid Goyal 2018-02-08 12:57:16 +05:30
parent d19f9e5b96
commit f9141120aa
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 11 additions and 488 deletions

View file

@ -139,8 +139,10 @@ send_key_to_child(Window *w, int key, int mods, int action) {
Screen *screen = w->render_data.screen;
const char *data = key_to_bytes(key, screen->modes.mDECCKM, screen->modes.mEXTENDED_KEYBOARD, mods, action);
if (data) {
if (screen->modes.mEXTENDED_KEYBOARD) write_escape_code_to_child(screen, APC, data + 1);
else {
if (screen->modes.mEXTENDED_KEYBOARD) {
if (*data == 1) schedule_write_to_child(w->id, (data + 1), 1);
else write_escape_code_to_child(screen, APC, data + 1);
} else {
if (*data > 2 && data[1] == 0x1b && data[2] == '[') { // CSI code
write_escape_code_to_child(screen, CSI, data + 3);
} else schedule_write_to_child(w->id, (data + 1), *data);

484
kitty/keys.h generated

File diff suppressed because it is too large Load diff

View file

@ -128,13 +128,17 @@ def keyboard_mode_name(screen):
def extended_key_event(key, mods, action):
if key >= defines.GLFW_KEY_LAST or key == defines.GLFW_KEY_UNKNOWN or (
# Shifted printable key should be handled by on_text_input()
mods == defines.GLFW_MOD_SHIFT and 32 <= key <= 126
mods <= defines.GLFW_MOD_SHIFT and 32 <= key <= 126
):
return b''
if mods == 0 and key in (
defines.GLFW_KEY_BACKSPACE, defines.GLFW_KEY_ENTER
):
if action == defines.GLFW_RELEASE:
return b''
return smkx_key_map[key]
if key in (defines.GLFW_KEY_LEFT_SHIFT, defines.GLFW_KEY_RIGHT_SHIFT):
return b''
name = KEY_MAP.get(key)
if name is None:
return b''

View file

@ -110,7 +110,8 @@ The new mode works as follows:
handle basic text entry, so if a _full mode_ using program crashes and does
not reset, the user can still issue a `reset` command in the shell to restore
normal key handling. Note that this includes pressing the `Shift` modifier
and printable keys.
and printable keys. Note that this means there are no repeat and release
events for these keys.
* For non printable keys and key combinations including one or more modifiers,
an escape sequence encoding the key event is sent. For details on the