[Toybox] [PATCH] clear.c: Clear scrollback buffer on non-vte (gnome based) terminals
Oliver Webb
aquahobbyist at proton.me
Tue Mar 5 13:53:14 PST 2024
On Tuesday, March 5th, 2024 at 15:31, Mouse <mouse at Rodents-Montreal.ORG> wrote:
> > "\ec" is supported by linux ttys, and clears the screen in all
> > terminals I tested. And "\e[3J" has been supported by linux since
> > 3.0, and clears the scrollback buffer in every terminal I've tested
> > that has one, and is a NOP for terminals without one like linux tty's
> > or st
>
>
> What about terminals - and emulators - that don't do X3.64?
I haven't found one that doesn't do X3.64 yet, except ancient outdated ones
that toybox probably shouldn't care about for the same reason it doesn't care
about EBCDIC or the 'mt' command.
> ESC does nothing for me, so \e[3J would display as [3J.
Do you edit text in your terminal? If so what editor do you use,
I'm interested since I haven't found a vi implementation that
doesn't use ANSI escape codes, nor any CLI editor that isn't ed.
> Or do you simply not care about portability to that extent?
No not really, The vast majority of terminals from probably at least the last
25 years have ANSI escape code (X3.64) support. They are bad to use unnecessarily.
But clearing the screen and scrollback buffer requires them. Terminal manipulation
is what X3.64 codes are _for_
Maybe you should just put "alias clear="yes '' | head -n $LINES"" in a rc file
if clearing the screen without ANSI codes matters to you. although that method puts
the prompt at the bottom of the screen and doesn't clear the scrollback buffer, it's the
best you can achieve without checking the terminfo database and using strange escape code
protocols that stopped being relevant decades ago or just using the ANSI codes that
99% of modern terminals support anyway.
- Oliver Webb <aquahobbyist at proton.me>
More information about the Toybox
mailing list