Fix enter/tab/backspace not being reported in all keys mode

This commit is contained in:
Kovid Goyal 2021-01-15 11:50:51 +05:30
parent af0a24c702
commit 0163bf3edb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 13 additions and 9 deletions

View File

@ -326,6 +326,8 @@ only key events are sent. If the text is needed as well, combine with the
Report associated text enhancement below. Report associated text enhancement below.
Additionally, with this mode, events for pressing modifier keys are reported. Additionally, with this mode, events for pressing modifier keys are reported.
Note that *all* keys are reported as escape codes, including :kbd:`Enter, Tab,
Backspace` etc.
.. _report_text: .. _report_text:

View File

@ -143,15 +143,14 @@ encode_function_key(const KeyEvent *ev, char *output) {
} }
} }
if (!ev->mods.value) { if (!ev->mods.value) {
switch(key_number) { if (!ev->disambiguate && !ev->report_text && key_number == GLFW_FKEY_ESCAPE) SIMPLE("\x1b");
case GLFW_FKEY_ENTER: SIMPLE("\r"); if (!ev->report_text) {
case GLFW_FKEY_ESCAPE: { switch(key_number) {
if (ev->disambiguate) { return encode_csi_string('u', "27", output); } case GLFW_FKEY_ENTER: SIMPLE("\r");
SIMPLE("\x1b"); case GLFW_FKEY_BACKSPACE: SIMPLE("\x7f");
case GLFW_FKEY_TAB: SIMPLE("\t");
default: break;
} }
case GLFW_FKEY_BACKSPACE: SIMPLE("\x7f");
case GLFW_FKEY_TAB: SIMPLE("\t");
default: break;
} }
} }
if (ev->mods.value == ALT && !ev->disambiguate) { if (ev->mods.value == ALT && !ev->disambiguate) {

View File

@ -437,6 +437,9 @@ class TestKeys(BaseTest):
ae(kq(ord('a'), mods=ctrl), csi(ctrl, num='a')) ae(kq(ord('a'), mods=ctrl), csi(ctrl, num='a'))
ae(kq(defines.GLFW_FKEY_UP), '\x1b[A') 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_LEFT_SHIFT), csi(num=defines.GLFW_FKEY_LEFT_SHIFT))
ae(kq(defines.GLFW_FKEY_ENTER), '\x1b[13u')
ae(kq(defines.GLFW_FKEY_TAB), '\x1b[9u')
ae(kq(defines.GLFW_FKEY_BACKSPACE), '\x1b[127u')
# test embed text # test embed text
eq = partial(enc, key_encoding_flags=0b11000) eq = partial(enc, key_encoding_flags=0b11000)

View File

@ -3,7 +3,7 @@
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net> # License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from kitty.config import defaults from kitty.config import defaults
from kitty.constants import WindowGeometry from kitty.types import WindowGeometry
from kitty.layout.interface import Grid, Horizontal, Splits, Stack, Tall from kitty.layout.interface import Grid, Horizontal, Splits, Stack, Tall
from kitty.window import EdgeWidths from kitty.window import EdgeWidths
from kitty.window_list import WindowList, reset_group_id_counter from kitty.window_list import WindowList, reset_group_id_counter