On Tue, May 11, 2021 at 10:41:29AM +0200, Stein Gunnar Bakkeby wrote:
> From 7fa0a12281f4b595b75e40e497919076497281e8 Mon Sep 17 00:00:00 2001
> From: bakkeby <bakkeby_AT_gmail.com>
> Date: Tue, 11 May 2021 10:20:23 +0200
> Subject: [PATCH] Restore cursor when exiting alt mode.
>
> If the mouse cursor is changed to a bar or an underline then st will use that
> when the terminal is first opened. When an application that changes the cursor
> via escape sequences is executed, e.g. vim which uses a block cursor by default,
> then that cursor will remain after exiting the program.
>
> This change sets the cursor back to default when exiting alt mode.
> ---
> st.c | 2 ++
> win.h | 1 +
> x.c | 6 ++++++
> 3 files changed, 9 insertions(+)
>
> diff --git a/st.c b/st.c
> index ebdf360..f0db3e0 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -1057,6 +1057,8 @@ tswapscreen(void)
> term.line = term.alt;
> term.alt = tmp;
> term.mode ^= MODE_ALTSCREEN;
> + if (!IS_SET(MODE_ALTSCREEN))
> + xsetdefaultcursor();
> tfulldirt();
> }
>
> diff --git a/win.h b/win.h
> index e6e4369..320585f 100644
> --- a/win.h
> +++ b/win.h
> _AT_@ -33,6 +33,7 @@ int xsetcolorname(int, const char *);
> void xseticontitle(char *);
> void xsettitle(char *);
> int xsetcursor(int);
> +void xsetdefaultcursor(void);
> void xsetmode(int, unsigned int);
> void xsetpointermotion(int);
> void xsetsel(char *);
> diff --git a/x.c b/x.c
> index 7186040..eae9f95 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -1712,6 +1712,12 @@ xsetcursor(int cursor)
> return 0;
> }
>
> +void
> +xsetdefaultcursor(void)
> +{
> + xsetcursor(cursorshape);
> +}
> +
> void
> xseturgency(int add)
> {
> --
> 2.31.1
>
Hi,
Which escape sequence does vim use for setting the altscreen, is it CSI 1047 or
1049?
st also has a comment to handle this case:
case 1049: /* swap screen & set/restore cursor as xterm */
To which terminal are you comparing the behaviour?
Can you provide a minimal test-case as a shellscript or a hexdump recording of
your vim session?
I briefly tested and compared it to xterm but found no difference there using a blinking
underline cursor: printf '\x1b[5; q'
and altscreen '\x1b[?1047h' or smcup/rmcup '\x1b[?1049h' / '\x1b[?1049l'.
Maybe I'm missing something.
Thanks,
--
Kind regards,
Hiltjo
Received on Tue May 11 2021 - 14:39:02 CEST