From efb0f6f24af85189fd107058ea32bcc764d4fd55 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 May 2021 15:09:42 +0530 Subject: [PATCH] Fix a regression in 0.20.0 that sent incorrect bytes for the F1-F4 keys in rmkx mode Fixes #3586 --- docs/changelog.rst | 3 +++ kitty/key_encoding.c | 9 +++++++++ kitty_tests/keys.py | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5a44c3cc6..00e012bee 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,6 +12,9 @@ To update |kitty|, :doc:`follow the instructions `. - Unicode input kitten: Fix a regression in 0.20.0 that broke keyboard handling when the num lock or caps lock modifiers were engaged. (:iss:`3587`) +- Fix a regression in 0.20.0 that sent incorrect bytes for the :kbd:`F1-F4` keys + in rmkx mode (:iss:`3586`) + 0.20.3 [2021-05-06] ---------------------- diff --git a/kitty/key_encoding.c b/kitty/key_encoding.c index 2cf1d68cb..7ffe082f2 100644 --- a/kitty/key_encoding.c +++ b/kitty/key_encoding.c @@ -185,6 +185,15 @@ encode_function_key(const KeyEvent *ev, char *output) { } if (!ev->mods.value) { if (!ev->disambiguate && !ev->report_text && key_number == GLFW_FKEY_ESCAPE) SIMPLE("\x1b"); + if (legacy_mode) { + switch(key_number) { + case GLFW_FKEY_F1: SIMPLE("\x1bOP"); + case GLFW_FKEY_F2: SIMPLE("\x1bOQ"); + case GLFW_FKEY_F3: SIMPLE("\x1bOR"); + case GLFW_FKEY_F4: SIMPLE("\x1bOS"); + default: break; + } + } if (!ev->report_text) { switch(key_number) { case GLFW_FKEY_ENTER: SIMPLE("\r"); diff --git a/kitty_tests/keys.py b/kitty_tests/keys.py index a08dadfb6..16d310089 100644 --- a/kitty_tests/keys.py +++ b/kitty_tests/keys.py @@ -91,10 +91,10 @@ class TestKeys(BaseTest): mkp('PAGE_DOWN', csi_num=6, trailer='~') mkp('HOME', csi_num=1, trailer='H') mkp('END', csi_num=1, trailer='F') - mods_test(defines.GLFW_FKEY_F1, csi_num=1, trailer='P') - mods_test(defines.GLFW_FKEY_F2, csi_num=1, trailer='Q') - mods_test(defines.GLFW_FKEY_F3, csi_num=1, trailer='R') - mods_test(defines.GLFW_FKEY_F4, csi_num=1, trailer='S') + mods_test(defines.GLFW_FKEY_F1, '\x1bOP', csi_num=1, trailer='P') + mods_test(defines.GLFW_FKEY_F2, '\x1bOQ', csi_num=1, trailer='Q') + mods_test(defines.GLFW_FKEY_F3, '\x1bOR', csi_num=1, trailer='R') + mods_test(defines.GLFW_FKEY_F4, '\x1bOS', csi_num=1, trailer='S') mods_test(defines.GLFW_FKEY_F5, csi_num=15, trailer='~') mods_test(defines.GLFW_FKEY_F6, csi_num=17, trailer='~') mods_test(defines.GLFW_FKEY_F7, csi_num=18, trailer='~')