[Toybox] [PATCH] clear.c: Clear scrollback buffer on non-vte (gnome based) terminals
Oliver Webb
aquahobbyist at proton.me
Tue Mar 5 15:59:37 PST 2024
(Yes, I did read "I believe there is no point in continuing this conversation.",
but there are still some questions and statements I feel the need to respond to)
On Tuesday, March 5th, 2024 at 16:32, Mouse <mouse at Rodents-Montreal.ORG> wrote:
> except for a recent spate of programs that insist on
> throwing X3.64 at me even when $TERM gives them no reason to think it
> will work (that becomes really obvious, when ESC does nothing!)
This is one of those programs. And has always been back to whenever it was first
made, so is toybox vi and probably toybox top as well.
Admittedly, I haven't been a developer for very long, but you are the only
person I've ever seen that does not use ANSI escape codes,
at least from my standpoint, your problem is not widely shared.
> > The vast majority of terminals from probably at least the last 25
> > years have ANSI escape code (X3.64) support.
>
> So, the last 25 years are all that matters to you?
TL;DR: Yes.
To Paraphrase design.html:
One of the design goals of toybox is to be as simplistic as possible,
while still being as fast, small, and feature-full as possible. A
general rule is that you should be able to implement 80% of the features
you need before you have to start compromising on speed, features, smallness,
or simplicity. From there, complexity is a budget, and you should spend it implementing
the most sensible things.
I'd much rather spend complexity implementing something else than rewriting
terminfo from scratch.
Portability falls under "full-featured", and trying to
support platforms and strange implementations from over 25 years ago
creates GNU-like code full of ifdef's and other ugly, complex, ambiguous things.
Any terminfo implementation would be massive, terminfo thousands of terminals
to check, over 150 ways to clear the screen, even if you strip that down it's still bad
We have a 7-10 year support horizon, How many terminal escape protocols have been relevant
in the last 10 years: One. The story is the same for UTF8 and LP64
> Also, I don't recall seeing anything in X3.41 or X3.64 for scrollback
> manipulation; as far as I can recall, it doesn't mention anything like
> scrollback. The closest I find in my notes with a few quick greps are
> CSI ... U and CSI ... V, which aren't a very good fit to most
> scrollback implementations I've seen.
\e[3J is a widely implemented extension (so is \ec), not standardized, but
linux tty's, VTE terminals (gnome-terminal and the dozen derivatives of it),
st, xterm, kitty, and tmux all have it. And probably more that I haven't tested yet.
I haven't found a terminal without support for it, which is why I decided to use it.
> > Terminal manipulation is what X3.64 codes are for
>
> Indeed. And communication is what German is for. But I, at least,
> don't expect everyone to speak German,
Comparing terminal manipulation codes to human languages isn't very
accurate. The difference between X3.64 and "the rest of the protocols"
is much more like the difference between ASCII and EBCDIC. Or Linux and
the rest of the unix-es (HP-UX, Solaris, SunOS, Hurd and Minix to some extent)
that were relevant in the unix wars.
A very long time ago, different standards were relevant. Then after some dispute, one won out over
the other. And since 99.9% of people use one, us spending time and complexity
writing support for both is annoying, pointless for all except the 0.1% of people
who use another protocol, and detrimental for the 99.9% of people who have agreed
on the standard (more code is harder to maintain, non-portability creates ifdef forests, etc)
Portability to older/different things is good, but replicating terminfo in toybox would kinda be
like adding EBCDIC help text. Times have changed and people use, implement, and write stuff for
the _one_ thing everyone uses.
> nor any other single language.
> Nor do I expect all terminals to speak any single control/escape
> sequence language.
The vast majority (Every modern terminal I've ever seen) of them do, which is why I expect it.
> I...see.
>
> I believe there is no point in continuing this conversation.
I'll stop replying beyond this then if you believe there is nothing to add
- Oliver Webb <aquahobbyist at proton.me>
More information about the Toybox
mailing list