Re: [hackers] [st][PATCH] Do not interpret CSI ? u as DECRC

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Thu, 30 Jan 2025 17:51:19 +0100

On Sun, Jan 26, 2025 at 01:40:57PM +0100, Johannes Altmanninger wrote:
> The kitty keyboard protocol docs recommend CSI ? u to query support for
> that protocol, see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
>
> For better or worse, fish shell uses this query to work around bugs
> in other terminals triggered by requesting that protocol via CSI = 5 u.
>
> Unfortunately, st interprets CSI ? u as DECRC (restore cursor
> position). reproduce with 'printf "\x1b[?u"; cat'.
>
> fish could work around this by switching to the alternate screen
> before running this query; but that might cause tearing on terminals
> that don't support Synchronized Output. I'm not sure.
>
> In the meantime, let's correct our parser.
>
> This adds a redundant else-after-return, for consistency with the
> surrounding code.
> ---
> st.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/st.c b/st.c
> index 2e3800e..03b9bc8 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -1801,7 +1801,11 @@ csihandle(void)
> tcursor(CURSOR_SAVE);
> break;
> case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
> - tcursor(CURSOR_LOAD);
> + if (csiescseq.priv) {
> + goto unknown;
> + } else {
> + tcursor(CURSOR_LOAD);
> + }
> break;
> case ' ':
> switch (csiescseq.mode[1]) {
> --
> 2.48.1
>
>

Applied, thanks!

-- 
Kind regards,
Hiltjo
Received on Thu Jan 30 2025 - 17:51:19 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 30 2025 - 18:00:40 CET