From 9a6422aa401b95c2bf4e351adc467bbfe3aa01a8 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 4 Apr 2026 04:17:48 +0100 Subject: [PATCH] Emit CSI-u control sequences to (mostly) disable its use while running. --- joe/scrn.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/joe/scrn.c b/joe/scrn.c index a0a9c437..89860fb3 100644 --- a/joe/scrn.c +++ b/joe/scrn.c @@ -18,6 +18,10 @@ int opt_usetabs = 0; int assume_color = 0; int assume_256color = 0; +/* see https://sw.kovidgoyal.net/kitty/keyboard-protocol/ */ +#define CSI_U_ENTRY "\033[>0u" +#define CSI_U_EXIT "\033[cap, t->cl, 1, 0, 0, 0, 0); if (t->brp) texec(t->cap, t->brp, 1, 0, 0, 0, 0); + /* disable (most) CSI-u on terminals which support it */ + ttputs(CSI_U_ENTRY); + ttflsh(); /* Initialize variable screen size dependent vars */ t->scrn = NULL; @@ -1873,6 +1880,9 @@ void nescape(SCRN *t) eraeol(t, 0, t->li - 1, 0); if (t->bre) texec(t->cap, t->bre, 1, 0, 0, 0, 0); + /* restore previous CSI-u setting on terminals which support it */ + ttputs(CSI_U_EXIT); + ttflsh(); if (t->te) texec(t->cap, t->te, 1, 0, 0, 0, 0); } @@ -1882,6 +1892,9 @@ void nreturn(SCRN *t) mouseopen(); if (t->ti) texec(t->cap, t->ti, 1, 0, 0, 0, 0); + /* disable (most) CSI-u on terminals which support it */ + ttputs(CSI_U_ENTRY); + ttflsh(); if (!skiptop && t->cl) texec(t->cap, t->cl, 1, 0, 0, 0, 0); if (t->brp) @@ -1899,6 +1912,9 @@ void nclose(SCRN *t) cpos(t, 0, t->li - 1); if (t->bre) texec(t->cap, t->bre, 1, 0, 0, 0, 0); + /* restore previous CSI-u setting on terminals which support it */ + ttputs(CSI_U_EXIT); + ttflsh(); if (t->te) texec(t->cap, t->te, 1, 0, 0, 0, 0); ttclose();