Skip to content

Commit

Permalink
Keyboard events: Fix turning on only the "Report all keys as escape c…
Browse files Browse the repository at this point in the history
…odes" enhancement not reporting modifier+enter/tab/backspace using escape codes
  • Loading branch information
kovidgoyal committed Jan 12, 2025
1 parent abd3363 commit d7ce3eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kitty/key_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ encode_function_key(const KeyEvent *ev, char *output) {
#define SIMPLE(val) return snprintf(output, KEY_BUFFER_SIZE, "%s", val);
char csi_trailer = 'u';
uint32_t key_number = ev->key;
bool legacy_mode = !ev->report_all_event_types && !ev->disambiguate;
bool legacy_mode = !ev->report_all_event_types && !ev->disambiguate && !ev->report_text;

if (ev->cursor_key_mode && legacy_mode && !ev->mods.value) {
switch(key_number) {
Expand Down Expand Up @@ -435,7 +435,7 @@ encode_glfw_key_event(const GLFWkeyevent *e, const bool cursor_key_mode, const u
ev.has_text = e->text && !startswith_ascii_control_char(e->text);
if (!ev.key && !ev.has_text) return 0;
bool send_text_standalone = !ev.report_text;
if (!ev.disambiguate && GLFW_FKEY_KP_0 <= ev.key && ev.key <= GLFW_FKEY_KP_BEGIN) {
if (!ev.disambiguate && !ev.report_text && GLFW_FKEY_KP_0 <= ev.key && ev.key <= GLFW_FKEY_KP_BEGIN) {
ev.key = convert_kp_key_to_normal_key(ev.key);
}
switch (e->action) {
Expand Down
1 change: 1 addition & 0 deletions kitty_tests/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def mkp(name, *a, **kw):
ae(kq(defines.GLFW_FKEY_UP), '\x1b[A')
ae(kq(defines.GLFW_FKEY_LEFT_SHIFT), csi(num=defines.GLFW_FKEY_LEFT_SHIFT))
ae(kq(defines.GLFW_FKEY_ENTER), '\x1b[13u')
ae(kq(defines.GLFW_FKEY_ENTER, mods=ctrl), '\x1b[13;5u')
ae(kq(defines.GLFW_FKEY_TAB), '\x1b[9u')
ae(kq(defines.GLFW_FKEY_BACKSPACE), '\x1b[127u')

Expand Down

0 comments on commit d7ce3eb

Please sign in to comment.