It was thus said that the Great Mouse once stated:
I've come
to the conclusion [1] that terminfo and curses aren't
needed any more. If you target VT100 (or Xterm or any other
derivative) and directly write ANSI sequences, it'll just work.
(a) That is not my experience.
I did acknowledge (but it was snipped in your reply---it's the missing
footnote).
(b) To the extent that it's true, it works only if
you stick to a very
much least-common-denominator set of sequences. VT-100s, VT-220s,
VT-240s, xterms, kterms, etc, each support a slightly different set of
sequences, with in some cases (eg, DCS) slightly different semantics
for the same basic sequences. Assume anything more than some very
minimal set and you are likely to find it breaks somewhere.
Again, it's been easily fifteen years since I last used a physical
terminal, and even then, back around 2000, I only knew one other person (in
person) that owned a physical terminal like I did.
Today?
Any terms I use (and I think the most users *NOT ON THIS LIST*) use are
xterms or derivatives of xterm.
I've also checked the xterm use of DCS. I *still* don't understand where
you would use those particular sequences.
I've also come across plenty of libraries and modules (for various
langauges) that use raw ANSI sequences to color things when they
"technically" should be using the Termcap Sf and Sb capabilities---those
scuflaws! Touting non-portable behavior like that!
It's a few
lines of code to get the current TTY (on any modern Unix
system) into raw mode in order to read characters [2].
"Raw mode" has been ill-defined since sgtty.h gave way to termios.h.
Raw mode usually means something like -icanon -isig -echo -opost, and
for lots of purposes you don't need to go that far; -icanon with min=1
time=0 is enough for anything that doesn't want to read
usually-signal-generating characters as data.
[2] It's six lines to get an open TTY into
raw mode,
system("stty raw");
:-)
Let's see.
struct termios o, n; tcgetattr(fd,&o); n=o; cfmakeraw(&n);
tcsetattr(fd,TCSANOW,&n);
If I found that in any code I had to maintain, I'd reject that line as the
unmaintainable mess that it is. Personally, I use:
struct termios old;
struct termios raw;
int fh;
fh = open("/dev/tty",O_RDWR);
tcgetattr(fh,&old);
raw = old;
cfmakeraw(&raw);
raw.c_cc[VMIN] = 1;
raw.c_cc[VTIME] = 1;
tcsetattr(fh,TCSANOW,&raw);
(I didn't include variable declarations or obtaining the file handle to the
TTY device in my initial message).
-spc (Fraktur? Really? Fraktur? What company had enough blackmail
material to get Fraktur part of the ECMA-48 standard?)