This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 37c33da66f12ecc7d3c8f0d6fa0d7d6b9bf26264
Author: Boris Faure <[email protected]>
AuthorDate: Sat Nov 14 23:00:54 2026 +0000
keyin: report the text associated with a key
Implement the report-associated-text flag (0b10000) of the kitty
keyboard protocol: with flag 8 also set, the third field of CSI u
carries the key's text as codepoints, as in CSI 97;;97u for a plain
"a". Text holding any control or C1 codepoint is dropped altogether,
and none is reported with Ctrl, Alt or Super held, per the definition
of text-ish keys in the protocol. Flag 16 without 8 is undefined in
the spec; the text is then sent as plain text.
The encoder already carried the gate behind the flag; this advertises
it, so the query now answers 31 (1|2|4|8|16) and the
kitty-kbd-unsupported.sh checksum changes.
https://sw.kovidgoyal.net/kitty/keyboard-protocol/
---
src/bin/termpty.c | 12 ++++++------
src/bin/termptyops.h | 3 ++-
src/bin/tytest.c | 1 +
src/bin/tytest_keyin.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/bin/unit_tests.h | 1 +
tests/tests.results | 2 +-
6 files changed, 58 insertions(+), 8 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 870aad52..fc8ef5ee 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -3433,15 +3433,15 @@ tytest_kitty_kbd_query(void)
_ty_feed(&ty, "\x1b[?0u");
_ty_reply_is(&ty, "\x1b[?0u");
- /* only implemented flags are stored and answered: 31 is 1|2|4|8|16,
- * the report-text flag 16 is not implemented yet */
- _ty_feed(&ty, "\x1b[>31u"); /* push */
+ /* only implemented flags are stored and answered: 63 is all the
+ * defined flags plus the undefined bit 32, masked to 31 */
+ _ty_feed(&ty, "\x1b[>63u"); /* push */
_ty_feed(&ty, "\x1b[?u");
- _ty_reply_is(&ty, "\x1b[?15u");
+ _ty_reply_is(&ty, "\x1b[?31u");
_ty_feed(&ty, "\x1b[<u"); /* pop */
- _ty_feed(&ty, "\x1b[=31;1u"); /* set */
+ _ty_feed(&ty, "\x1b[=63;1u"); /* set */
_ty_feed(&ty, "\x1b[?u");
- _ty_reply_is(&ty, "\x1b[?15u");
+ _ty_reply_is(&ty, "\x1b[?31u");
_ty_feed(&ty, "\x1b[=0;1u"); /* set */
assert(ty.write_buffer.len == 0);
diff --git a/src/bin/termptyops.h b/src/bin/termptyops.h
index 2381e290..aa99190d 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -39,7 +39,8 @@ void termpty_soft_reset_state(Termpty *ty);
/* kitty keyboard protocol: the flags implemented so far */
#define TERMPTY_KITTY_KBD_SUPPORTED \
(TERMPTY_KITTY_KBD_DISAMBIGUATE | TERMPTY_KITTY_KBD_REPORT_EVENTS | \
- TERMPTY_KITTY_KBD_REPORT_ALTERNATES | TERMPTY_KITTY_KBD_REPORT_ALL)
+ TERMPTY_KITTY_KBD_REPORT_ALTERNATES | TERMPTY_KITTY_KBD_REPORT_ALL | \
+ TERMPTY_KITTY_KBD_REPORT_TEXT)
unsigned int termpty_kitty_kbd_flags_get(const Termpty *ty);
void termpty_kitty_kbd_set(Termpty *ty, unsigned int flags, int mode);
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index e264fc92..872348e6 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -111,6 +111,7 @@ static struct {
{ "keyin_kitty_alternates", tytest_keyin_kitty_alternates},
{ "keyin_kitty_events", tytest_keyin_kitty_events},
{ "keyin_kitty_all_keys", tytest_keyin_kitty_all_keys},
+ { "keyin_kitty_text", tytest_keyin_kitty_text},
{ "keyin_pressed", tytest_keyin_pressed},
{ "config_erase_is_del_upgrade", tytest_config_erase_is_del_upgrade},
{ "config_selection_read_upgrade", tytest_config_selection_read_upgrade},
diff --git a/src/bin/tytest_keyin.c b/src/bin/tytest_keyin.c
index dd02546f..873757e2 100644
--- a/src/bin/tytest_keyin.c
+++ b/src/bin/tytest_keyin.c
@@ -769,6 +769,53 @@ tytest_keyin_kitty_all_keys(void)
return bad;
}
+int
+tytest_keyin_kitty_text(void)
+{
+ static const Kitty_Case cases[] = {
+ /* flags key keyname string mods action expected */
+ { 24, "a", "a", "a", 0, P, "\033[97;;97u" },
+ { 24, "A", "a", "A", S, P, "\033[97;2;65u" },
+ /* a control codepoint in the text suppresses it entirely */
+ { 24, "a", "a", "\001", C, P, "\033[97;5u" },
+ { 24, "Return", "Return", "\r", 0, P, "\033[13u" },
+ { 24, "KP_1", "KP_End", "1", NL, P, "\033[57400;129;49u" },
+ { 31, "A", "a", "A", S, P, "\033[97:65;2;65u" },
+ { 31, "A", "a", NULL, S, U, "\033[97:65;2:3u" },
+ /* the base-layout alternate of a Cyrillic key is its latin name */
+ { 31, "Cyrillic_ES", "c", "\320\241", S, P, "\033[1089:1057:99;2;1057u" },
+ /* a C1 codepoint anywhere in the text rejects all of it */
+ { 24, "a", "a", "a\302\205", 0, P, "\033[97u" },
+ /* flag 16 without 8 is undefined in the spec; the text goes raw */
+ { 17, "a", "a", "a", 0, P, "a" },
+ };
+ char *saved_locale;
+ size_t i;
+ int bad = 0;
+
+ /* towlower() needs a UTF-8 locale; the real terminal gets one from
+ * elm_init(), the harness does not */
+ saved_locale = strdup(setlocale(LC_CTYPE, NULL));
+ assert(saved_locale);
+ if (!setlocale(LC_CTYPE, "C.UTF-8"))
+ {
+ fprintf(stderr, "\n no C.UTF-8 locale, skipping");
+ free(saved_locale);
+ return 0;
+ }
+
+ _init();
+ for (i = 0; i < sizeof(cases) / sizeof(cases[0]); i++)
+ bad += _kitty_case_is(&cases[i]);
+ _shutdown();
+ setlocale(LC_CTYPE, saved_locale);
+ free(saved_locale);
+
+ if (bad)
+ fprintf(stderr, "\n %d wrong encoding%s", bad, bad == 1 ? "" : "s");
+ return bad;
+}
+
#undef S
#undef A
#undef C
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 38f2db60..c92bf460 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -112,6 +112,7 @@ int tytest_keyin_kitty_alternates(void);
int tytest_keyin_pressed(void);
int tytest_keyin_kitty_events(void);
int tytest_keyin_kitty_all_keys(void);
+int tytest_keyin_kitty_text(void);
int tytest_config_erase_is_del_upgrade(void);
int tytest_config_selection_read_upgrade(void);
int tytest_config_cursor_blink_timeout_upgrade(void);
diff --git a/tests/tests.results b/tests/tests.results
index 52bda03b..1d33f699 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -246,5 +246,5 @@ kitty-kbd-query.sh 2aeecb0992989a62a9b4cf5ce687852f
kitty-kbd-stack.sh 1940619ffdbe765b2495edbce9cf22cc
kitty-kbd-altscreen.sh df9913f9d85f856c75dd525a806da4f6
kitty-kbd-reset.sh bd10ee95b6b71d150fbe1a11c7b6ac94
-kitty-kbd-unsupported.sh 3cf7cfe08b0d5fee7c38d0dc570f7c53
+kitty-kbd-unsupported.sh 63cfb663085848fd972e9ba667a2901b
kitty-kbd-malformed.sh bd10ee95b6b71d150fbe1a11c7b6ac94
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.