Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: print color escapes



On Thu, Jan 1, 2015 at 3:02 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

But terminal will always grab ESC 'hard' will it not?  That is to say that
no matter how you dress it up, the terminal always sees it verbatim.  And
I'd expect that that convention is now written in stone.


The terminal always sees every character verbatim. How it treats the
character depends on many things. In the past (circa the 1980s) you could
purchase "smart" terminals from different companies each of which
implemented their own "language". Language in this context means the
 specific mapping of character sequences to actions such as clearing the
screen or changing the foreground color. The reason the terminfo and
termcap databases and associated programming APIs exist (try typing "man
terminfo" or "man tercap" at your shell prompt) was to make it possible for
programs to perform actions like moving the cursor to a specific location
on the screen without explicitly knowing which control language the
terminal implemented.

One of those was the DEC VT100. The "language" it recognized eventually
became the winner. Winner in the sense that by the 1990s nearly all
terminals implemented that language. That de-facto standard was eventually
turned into standard ANSI X3.64
<http://en.wikipedia.org/wiki/ANSI_escape_code> which is now pretty much
the only terminal control language you'll find in use.

P.S., Yes, I've glossed over many important details above. Such as the fact
the DEC VT52 was actually the first terminal to implement what would
eventually become the ANSI X3.64 standard. But it was the VT100 that made
that transition all but inevitable. Today things are even more complicated
by Unicode and encodings such as UTF-8 which a terminal should understand
in order to translate multi-byte characters into the appropriate human
language glyph.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank


Messages sorted by: Reverse Date, Date, Thread, Author