forked from WHC/Hermit
TUI: kitty keyboard protocol, word movement and deletion keys
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user