On Mon, Nov 30, 2020 at 12:56:13AM +0100, François-Xavier Carton wrote:
> On Sun, Nov 29, 2020 at 05:37:30PM +0100, Hiltjo Posthuma wrote:
> >
> > Hi Francois,
> >
> > First: thanks for the patch.
> >
> > Do you have maybe a practical use-case example why you'd like to request
> > supporting this?
> >
> > In all st years it has not been requested before. I'd like to prevent
> > obscure/non-tested features. Although maybe it's not so obscure and useful, in
> > that case please say so :)
> >
> > --
> > Kind regards,
> > Hiltjo
>
> Hi Hiltjo,
>
> Well, I guess that if it's not been requested before, then it's not a
> highly used feature. And I do understand your concern about that.
>
> I implemented this because I wanted to use that feature in one of my
> programs (and the only terminal emulator I have installed is st). More
> precisely, the program switches to alternate screen at the beginning,
> and restores normal screen at the end. However, this can break things
> when run under another program that does the same thing (eg. vim, less,
> ...). So in my program, I wanted to test whether alternate screen is
> enabled at the beginning, and if so, omit switching back to normal
> screen at the end.
>
> The reason I posted the patch here is 1) to get feedback; and 2) if this
> is deemed useful to have, I'd rather have it mainlined than maintain it
> separately, as the patch makes changes in core functions.
>
> That being said, I understand why you would like not to support this, as
> the feature is rarely used.
>
> Best,
> François-Xavier
>
Hi Francois,
Thanks for the detailed reply.
Maybe you could use the tcsetattr and tcgetattr interfaces. This is the more
common way to handle that from what I've seen and it should work on many
systems.
In a nutshell:
Store (at startup):
tcgetattr(0, &tsave);
<change properties and set)
Restore (at cleanup on exit):
tcsetattr(0, TCSANOW, &tsave);
To set application mode you could use curses "enter_ca_mode" and "exit_ca_mode"
(smcup, rmcup):
https://man.openbsd.org/terminfo.5
--
Kind regards,
Hiltjo
Received on Mon Nov 30 2020 - 14:32:27 CET