Subject: Re: bug#66128: 28.2; visible-bell breaks setterm --inversescreen on

From: Eli Zaretskii <[email-masked]>
Date: Mon, 25 Sep 2023 08:03:38 +0300

> Date: Sun, 24 Sep 2023 20:07:03 -0400
> From: Thomas Dickey <[email-masked]>
> Cc: Tomas Hlavaty <[email-masked]>, Thomas Dickey <[email-masked]>,
> 	[email-masked]
> 
> setterm doesn't have any special way of manipulating the terminal -
> it uses the same escape sequences that emacs would
> 
> >     $ emacs -Q --eval '(setq visible-bell t)'
> > 
> >   Then in Emacs do something that causes a bell, like try moving beyond
> >   the buffer's end.  This causes the Emacs background to become white,
> >   i.e. the visible-bell somehow countermands the inversescreen state.
> > 
> > Can you think of any reason for this behavior?  Do terminals honor
> 
> https://github.com/util-linux/util-linux/blob/master/term-utils/setterm.c
> 
> https://github.com/util-linux/util-linux/blob/1e0ad14b3ac08d855cda6de346a65f9b834e00db/term-utils/setterm.c#L1005
> 
> 	/* -inversescreen [on|off]. */
> 	if (ctl->opt_inversescreen)
> 		fputs(ctl->opt_invsc_on ? "\033[?5h" : "\033[?5l", stdout);
> 
> man console_codes
> 
>        ESC [ ? 5 h
>               DECSCNM (default off): Set reverse-video mode.
> 
> but visual-bell can be the same thing
> 
> The "vb" termcap capability is found with "man 5 terminfo"
> 
>           flash_screen                flash     vb     visible bell (may
>                                                        not move cursor)
> 
> to be "flash" in terminfo,
> and "infocmp linux" shows
> 
> 	flash=\E[?5h$<200/>\E[?5l,
> 
> which is to say,
> 	turn reverse-video on
> 	wait 200 milliseconds
> 	turn reverse-video off

Thanks.  So Emacs should ideally reverse the sequence when the
terminal is in the reverse-video mode, or at least send the "\033[?5h"
sequence after sending "flash"?  But can Emacs know that the terminal
is in this mode at startup?