[Toybox] [PATCH] clear.c: Clear scrollback buffer on non-vte (gnome based) terminals
Oliver Webb
aquahobbyist at proton.me
Fri Mar 8 17:47:24 PST 2024
On Friday, March 8th, 2024 at 19:15, Rob Landley <rob at landley.net> wrote:
> On 3/8/24 00:02, Oliver Webb wrote:
>
> > On Wednesday, March 6th, 2024 at 01:22, Rob Landley rob at landley.net wrote:
> >
> > > 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.
> >
> > reset sets tty settings while clear doesn't,
>
>
> clear -r
Ah, so it could probally be a OLDTOY, or at least in the same file
> shrug That ship has long since sailed, just...
>
> > large enough
> > difference to probably not make one a OLDTOY pointing at the other.
> > Although reset does everything clear does
> >
> > Looking at the man page for reset, it does even more historical stuff that
> > doesn't matter today, like "-r" which is the same as "reset; echo Terminal type is ${TERM}."
> > and "-s" which is "reset; echo TERM=$TERM;"
>
>
> I'm not sure why it would feel the need to display an environment variable.
> Stuff like "tty" is generally performing a system call.
>
> > > > Looking more at ncurses clear, what does it do?
> > >
> > > Way too much, all of which is historical nonsense.
> >
> > ncurses clear does seem to have a -x option to save the scrollback buffer.
> > Not too important but it'd be one line of code to implement ("if (!toys.optargs) xputsn("\e[3J");")
>
> echo -ne '\e[3J'
By that logic, the entire clear command could be delegated to users as "just use a shell
script (Like the shell script we did use for clear before we replaced it with C)"
> > > 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.
> >
> > > Toybox assumes Linux.
> >
> > What is the oldest version of Linux are we planning to support?
[...]
> > The nommu stuff seems to have only
> > been done on 2.4/2.6 kernels from 15 years ago.
>
> Um, no. Not remotely. Lots of embedded devs use older kernels because they're
> way SMALLER than the modern bloated nonsense, but we support and regression test
> stuff all the time.
Ah, to be fair that isn't a completely unreasonable assumption to make. UcLinux
only supported kernels up to 2.6, and the main NOMMU crowd is embedded developers.
I've never seen anything before about modern linux doing NoMMU, and since they haven't
supported it for at least a decade I assumed modern ones couldn't do it.
> > So is "\e[3J" (A escape code added in 3.0)
> > something we can use?
>
> A) Toybox has a 7 year support horizon, 2011 was 13 years ago, 13 > 7, so I'd
> assume so.
Supporting NoMMU -> NoMMU is usually done on decade old kernels -> Special Case to ask about
when talking about support horizon
> B) Added to what?
That paragraph was talking about the kernel, so the linux VGA text console...
Every terminal I've tested has it too (Because 99% of modern terminals try to be a superset
of linux console_codes)
> The kernel's VGA text console (and/or bitmap console)
> interpreting a sequence has nothing to do with XFCE's Terminal program
> interpreting a sequence which has nothing to do with KDE's terminal interpreting
> a sequence which has nothing to do with gnome terminal interpreting a sequence
> which has nothing to do with the terminal Rich Felker wrote
> (https://git.musl-libc.org/cgit/uuterm/) and there's a dozen others out there.
Actually, yes it does. The same way that if your terminal doesn't do ANSI codes
it's defective. Like how "ANSI escape codes have nothing to do with how they are processed in [XYZ]" doesn't
make much sense because EVERYONE does them. Every terminal I've ever seen implements the linux console_codes.
(At least the subset of the main things that matter), I've tested on VTE terminals (Gnome, XFCE) and they work,
so does st (Which doesn't have a scrollback buffer), and so does tmux.
> When was the sequence added to "man 7 console_codes"?
Linux Kernel Version 3.0, like I said in the paragraph talking about linux support,
didn't think I'd have to spell it out because of the context...
- Oliver Webb <aquahobbyist at proton.me>
More information about the Toybox
mailing list