TUI: kitty keyboard protocol, word movement and deletion keys
ci / linux (clang) (push) Failing after 23s
ci / linux (gcc) (push) Failing after 22s
ci / sanitizers (push) Failing after 21s
ci / musl (push) Failing after 1m12s
ci / macos (push) Canceled after 0s

Query CSI ? u at startup and push the disambiguate flag on the alternate
screen when the terminal answers; CSI u reports are mapped back to legacy
input (Shift/Ctrl+Enter insert a newline, Ctrl+Backspace deletes a word).
Ctrl/Alt+Left/Right move by word, Ctrl/Alt+Delete delete the next word.
Our define_key codes move above the range ncurses uses for terminfo
extended keys.
This commit is contained in:
WHC
2026-10-06 01:52:48 +08:00
parent 8efd63bb31
commit b28bca2cfc
6 changed files with 251 additions and 14 deletions
+8
View File
@@ -90,6 +90,14 @@ int cst_key_parse(const char *s);
/* code → canonical name ("ctrl+x", "tab", "alt+up", ...). */
const char *cst_key_name(int code, char *buf, size_t n);
/* Kitty keyboard protocol ("disambiguate" flag): the report CSI cp;1+mods u
* (mods: 1 shift, 2 alt, 4 ctrl) → the input a legacy terminal would send,
* so the rest of the TUI needs no changes. Alt becomes an Esc prefix;
* shift/ctrl+enter become alt+enter (newline) and ctrl+backspace becomes
* alt+backspace (delete word); shift+tab is CST_K_BTAB. Writes up to two codes
* to out and returns how many (0 when the report means nothing to us). */
int cst_key_from_kitty(int cp, int mods, int out[2]);
#define CST_KEYMAP_MAX 128
typedef struct {
int action;