[Toybox] [PATCH] clear.c: Clear scrollback buffer on non-vte (gnome based) terminals
Rob Landley
rob at landley.net
Tue Mar 5 23:30:11 PST 2024
On 3/5/24 14:44, Oliver Webb via Toybox wrote:
>>From https://landley.net/notes-2022.html#17-10-2022:
> the smallest one is "clear" which is actually fraught (the escape does not reset the TTY out of "cooked" mode,
It's actually "reset" that should yank the tty out of cooked mode, which I
believe it does now.
Why we have both "clear" and "reset", I couldn't tell you. Other than the
gratuitous 2 second delay "reset" had so physical teletype hardware could move
the platen back to the left which then went all "pot roast principle" and
everybody cargo culted it without asking WHY for the next 40 years:
https://www.psychologytoday.com/us/blog/thinking-makes-it-so/201402/the-pot-roast-principle
> Looking more at ncurses clear, what does it do?
Way too much, all of which is historical nonsense.
We went from 1960's teletypes (speaking multiple incompatible dialects via
serial cable) to 1970's "glass ttys" like the TN3270 and VT100 (speaking
multiple incompatible dialects via serial cable) to integrated bitmapped
displays (under 100% software control) back in the 1980s. All our "terminal
programs" are software since X11 came out in 1987 (and defeated NeWS, which
sadly freed up those guys to inflict Java upon the world:
http://www.blinkenlights.com/classiccmp/javaorigin.html), so the translation
layers to speak different tty dialects became vestigial years before Linux 0.0.1
came out. I mean it's fascinating as computer history:
https://landley.net/history/mirror/intel/Hoff.html
But should not exist on any modern system. All that termsys/termio/curses crap
is remains frozen in amber like the qwerty keyboard and vi. All xterm
descendants are software (and so is the linux vga terminal), meaning two pieces
of software are talking to each other and they just have to agree on a protocol.
(Such as the one standardized by the American National Standards Institute so
long ago that DOS 3.x had ANSI.SYS in the OS base image in 1984.)
The fact there are several options for that protocol is historical leftovers,
and even "ansi, linux, xterm" are TOO MANY. (And 99% subsets of each other anyway.)
Toybox produces ansi escape sequences (well, "man 7 console_codes" really, but
MOSTLY ansi), and OFFICIALLY does not care what the TERM= is set to (or that it
is set at all) as a matter of policy.
> It has a -T option to specify TERM (because env wasn't good enough apparently):
...
> Trying to find all the terminals clear supported lead me down a rabbit hole
> through decompiling the entire terminfo database and sorting through it.
Oh goddess no:
https://landley.net/notes-2010.html#17-02-2010
> 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
Toybox assumes Linux. There's some support for mac and freebsd, but mac has
homebrew and freebsd has Linuxulator and windows has its own reverse wine now.
Retaining termio/termcap/curses is gnu/braindamage.
Rob
More information about the Toybox
mailing list