[Toybox] [PATCH] clear.c: Clear scrollback buffer on non-vte (gnome based) terminals

Mouse mouse at Rodents-Montreal.ORG
Tue Mar 5 14:32:42 PST 2024


>> 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.

Ah.

>> 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.

First, the easy one to dispose of: I use ed only very occasionally,
mostly for automated tasks.

Depending on the task, I use vi or I use emacs.  (These days, "emacs"
seems to mean "GNU emacs" to most people.  I do not use GNU emacs.  I
use a different emacs variant.)

I have yet to find a vi variant that doesn't work just fine when
presented with a suitable $TERM (and $TERMCAP, on systems that don't
come with a description of my terminal type, which in my experience
most do).  Admittedly, I haven't actively looked for such a variant.

Even vim works, as well as vim ever works - which, for me, isn't very
well; my brushes with vim have mostly been concerned with shutting off
its "improvements", until I learned that most systems where I find vim
also have or can get nvi, which is much closer to what my fingers and
eyes expect from vi.

Yes, vi works fine with X3.64, when presented with a $TERM that tells
it that's what the terminal expects.  The whole point of $TERM (and
termcap/terminfo) is for programs to adjust themselves to the terminal,
after all, and, 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!), it's
done its job excellently.  (I even, recently, ran into one thing so
obnoxious as to outright hang on startup because it didn't get a
response to some X3.64 sequence I forget the name of.)

>> Or do you simply not care about portability to that extent?
> No not really,

Ah.

> 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?

> They are bad to use unnecessarily.  But clearing the screen and
> scrollback buffer requires them.

No, it does not.  Clearing the screen - when supported! - and the
scrollback buffer - when supported! - do not necessarily use X3.64;
they use terminal-dependent sequences, which may or may not be a single
sequence for both functions and may or may not be an X3.64 sequence.

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.

> 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, nor any other single language.
Nor do I expect all terminals to speak any single control/escape
sequence language.

> 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.

No.  I put the correct terminal type in $TERM and, in my experience,
clear(1) Just Works - though admittedly I haven't tried toybox's -
because it _does_ understand what $TERM is for.

> 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.

I...see.

I believe there is no point in continuing this conversation.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse at rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


More information about the Toybox mailing list