Re: [dev] [st] XTSMGRAPHICS query

From: Markus Wichmann <nullplan_AT_gmx.net>
Date: Sun, 18 Feb 2024 06:45:56 +0100

Am Sat, Feb 17, 2024 at 09:45:44PM -0500 schrieb Tim Culverhouse:
> Hello - I am the author of a TUI library and received a bug report regarding
> cursor placement on exiting an application.
>
> I was able to narrow down a simple reproducer to how st a XTSMGRAPHICS query:
>
> echo -e "\x1b[?2;1;0S"
>
> This can also be seen when using a notcurses application which *doesn't* enter
> the altscreen (ie `ncls`). notcurses does the XTSMGRAPHICS query in the alt
> screen (which is also the solution I will be using), but `ncls` uses notcurses
> direct mode, which never enters the alt screen thus this bug appears there as
> well.
>
> I checked the source and it looks like the parser is not checking for a private
> indicator when handling a CSI with final character S. In that case, this query
> gets parsed as a SU sequence. I think that ought be modified to ensure there
> isn't a '?' private indicator in the sequence before handling as SU.
>
> Not much of a C programmer but I could take a shot at this if the solution
> sounds ok.
>
> --
> Tim
>

Had to research what this is supposed to do: XTerm replies to it with
the screen size. Except the docs explicitly warn you that it is not
necessarily the screen size.

I wonder why a TUI application needs to know the screen size in pixels.
If a screensize in characters is acceptable, then just use
tcgetwinsize() or ioctl(TIOCGWINSZ). Yes, I know that in theory it could
tell you the pixels as well, but in practice those never did get
implemented after all.

Ciao,
Markus
Received on Sun Feb 18 2024 - 06:45:56 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 18 2024 - 07:36:08 CET