[dev] [st] Prevent clear screen when leaving alt-mode

From: Eloy Espinaco <eloyesp_AT_gmail.com>
Date: Sun, 20 Dec 2020 11:00:18 -0300

Hi,

I've just updated st and applied all the patches I like, one of those is the
[scrollback][1]. I've found that there is a new option there to scroll with
the mouse without shift, that should work always except on ALTMODE.

I've tested it but I found that it does work fine, except when git does use
the pager. So I've tested with less (the pager used by git), and it worked,
but it didn't work when invoked by git.

Then I found that [git sends 'FRX' arguments by default][2] to less, where
X does:

    Disables sending the termcap initialization and deinitialization strings
    to the terminal. This is sometimes desirable if the deinitialization
    string does something unnecessary, like clearing the screen.

So it seems it is just a workaround an issue with most terminal emulators
that clear the screen when leaving the ALTMODE. So I've disabled that X
flag and tested with st, to check if that works, but it seems that st also do
"unnecessary clear the screen".

I were testing a little bit, and it seems that this patch should fix it, but I'm
not sure if there is something else being broken with the following patch:

Regards.

[1]: https://st.suckless.org/patches/scrollback/
[2]: https://github.com/git/git/blob/398dd4bd039680ba98497fbedffa415a43583c16/pager.c#L88

----------------------->8-------------------------

diff --git a/st.c b/st.c
index e2dd722..4254721 100644
--- a/st.c
+++ b/st.c
_AT_@ -1601,12 +1601,7 @@ tsetmode(int priv, int set, int *args, int narg)
                        case 1047:
                                if (!allowaltscreen)
                                        break;
- alt = IS_SET(MODE_ALTSCREEN);
- if (alt) {
- tclearregion(0, 0, term.col-1,
- term.row-1);
- }
- if (set ^ alt) /* set is always 1 or 0 */
+ if (set ^ IS_SET(MODE_ALTSCREEN)) /* set is always 1 or 0 */
                                        tswapscreen();
                                if (*args != 1049)
                                        break;
Received on Sun Dec 20 2020 - 15:00:18 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 21 2020 - 11:48:08 CET