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 5f13afd04c8e54225f174bd195a6366bf134e627
Author: Boris Faure <[email protected]>
AuthorDate: Sat Nov 14 22:45:07 2026 +0000

    keyin: report kitty alternate keys
    
    Implement the report-alternate-keys flag (4) of the kitty keyboard
    protocol, so that shortcuts can be matched on any layout:
    https://sw.kovidgoyal.net/kitty/keyboard-protocol/#report-alternate-keys
    
    Functional keys get no alternates: the spec only defines them for keys
    reported by their codepoint.
    
    The kitty-kbd-unsupported.sh checksum changes: the flags it pushes are
    masked against the supported set, which now holds flag 4.
---
 src/bin/keyin_kitty.c  | 14 ++++++++++++++
 src/bin/termpty.c      | 11 ++++++-----
 src/bin/termptyops.h   |  3 ++-
 src/bin/tytest.c       |  1 +
 src/bin/tytest_keyin.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/bin/unit_tests.h   |  1 +
 tests/tests.results    |  2 +-
 7 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/src/bin/keyin_kitty.c b/src/bin/keyin_kitty.c
index 46efc6cd..ee59ce90 100644
--- a/src/bin/keyin_kitty.c
+++ b/src/bin/keyin_kitty.c
@@ -346,6 +346,20 @@ keyin_kitty_encode(Termpty *ty, const Keyin_Event *kev, unsigned int flags)
      }
 
    seq.mods = kev->mods;
+
+   /* the spec defines alternates for keys reported by codepoint only */
+   if ((flags & TERMPTY_KITTY_KBD_REPORT_ALTERNATES) && !fk)
+     {
+        Eina_Unicode shifted = (kev->mods & KEYIN_MOD_SHIFT) ?
+                               keyin_keysym_codepoint(kev->key) : 0;
+        Eina_Unicode base = keyin_keysym_codepoint(kev->keyname);
+
+        if (shifted != seq.number)
+          seq.shifted = shifted;
+        if (base != seq.number && base != seq.shifted)
+          seq.base = base;
+     }
+
    if ((flags & TERMPTY_KITTY_KBD_REPORT_EVENTS) &&
        kev->action != KEYIN_ACTION_PRESS)
      seq.action = ""
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index fd7ca271..05e13c4b 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -3433,14 +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 */
-   _ty_feed(&ty, "\x1b[>5u");      /* push */
+   /* only implemented flags are stored and answered: 7 is 1|4, the
+    * event-types flag 2 is not implemented yet */
+   _ty_feed(&ty, "\x1b[>7u");      /* push */
    _ty_feed(&ty, "\x1b[?u");
-   _ty_reply_is(&ty, "\x1b[?1u");
+   _ty_reply_is(&ty, "\x1b[?5u");
    _ty_feed(&ty, "\x1b[<u");       /* pop */
-   _ty_feed(&ty, "\x1b[=5;1u");    /* set */
+   _ty_feed(&ty, "\x1b[=7;1u");    /* set */
    _ty_feed(&ty, "\x1b[?u");
-   _ty_reply_is(&ty, "\x1b[?1u");
+   _ty_reply_is(&ty, "\x1b[?5u");
    _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 5f0df737..9e1852a3 100644
--- a/src/bin/termptyops.h
+++ b/src/bin/termptyops.h
@@ -37,7 +37,8 @@ void termpty_reset_state(Termpty *ty);
 void termpty_soft_reset_state(Termpty *ty);
 
 /* kitty keyboard protocol: the flags implemented so far */
-#define TERMPTY_KITTY_KBD_SUPPORTED (TERMPTY_KITTY_KBD_DISAMBIGUATE)
+#define TERMPTY_KITTY_KBD_SUPPORTED \
+   (TERMPTY_KITTY_KBD_DISAMBIGUATE | TERMPTY_KITTY_KBD_REPORT_ALTERNATES)
 
 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 302e4807..f5ee9bda 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -108,6 +108,7 @@ static struct {
        { "keyin_keypad", tytest_keyin_keypad},
        { "keyin_keysyms", tytest_keyin_keysyms},
        { "keyin_kitty_disambiguate", tytest_keyin_kitty_disambiguate},
+       { "keyin_kitty_alternates", tytest_keyin_kitty_alternates},
        { "config_erase_is_del_upgrade", tytest_config_erase_is_del_upgrade},
        { "config_selection_read_upgrade", tytest_config_selection_read_upgrade},
        { "config_cursor_blink_timeout_upgrade", tytest_config_cursor_blink_timeout_upgrade},
diff --git a/src/bin/tytest_keyin.c b/src/bin/tytest_keyin.c
index 04c6a38e..20cd8624 100644
--- a/src/bin/tytest_keyin.c
+++ b/src/bin/tytest_keyin.c
@@ -557,6 +557,48 @@ tytest_keyin_kitty_disambiguate(void)
    return bad;
 }
 
+int
+tytest_keyin_kitty_alternates(void)
+{
+   static const Kitty_Case cases[] = {
+        /* flags key             keyname  string     mods    action expected */
+        { 5, "A",                "a",     "A",       S,      P,     "A" },
+        { 5, "A",                "a",     "A",       C|S,    P,     "\033[97:65;6u" },
+        { 5, "a",                "a",     "\001",    C,      P,     "\033[97;5u" },
+        { 5, "exclam",           "1",     "!",       C|S,    P,     "\033[49:33;6u" },
+        { 5, "Cyrillic_es",      "c",     NULL,      C,      P,     "\033[1089::99;5u" },
+        { 5, "Cyrillic_ES",      "c",     "\xd0\xa1", C|S,   P,     "\033[1089:1057:99;6u" },
+        { 5, "Left",             "Left",  NULL,      C|S,    P,     "\033[1;6D" },
+        { 5, "KP_1",             "KP_End", NULL,     C|NL,   P,     "\033[57400;133u" },
+        { 5, "plus",             "equal", "+",       C|S,    P,     "\033[61:43;6u" },
+   };
+   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 05b2395c..5af95193 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -108,6 +108,7 @@ int tytest_keyin_backspace(void);
 int tytest_keyin_keypad(void);
 int tytest_keyin_keysyms(void);
 int tytest_keyin_kitty_disambiguate(void);
+int tytest_keyin_kitty_alternates(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 fe98f3e2..6101c9b7 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 e1de2502f1ec6c40e2bee6f0f2f54bf3
+kitty-kbd-unsupported.sh bdc45fbe16a618e5576ee943cfcdfb09
 kitty-kbd-malformed.sh bd10ee95b6b71d150fbe1a11c7b6ac94

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to