> > These codes depend on the terminal used, right? So just to get this
> > straight, you think column should get the valid escape sequences for the
> > terminal it runs in and then filter those out?

> Yep, if libtinfo makes that easy to do.  Otherwise, checking for ANSI
> standard sequences would already be useful enough.

Using libtinfo means trusting TERM, which is almost never the right thing
to do since about 30 years ago when terminals got mostly standardized and
termcap/terminfo databases stopped being reasonably maintained (heck,
Solaris still doesn't know about TERM=linux; xterm, putty, konsole and
everything on libvte use the same TERM string despite having lots of
differences, etc).

But, weeding out color codes is far easier than that: all valid SGR ("set
graphics rendition") codes match the same syntax: \e [ <commands> m, where
<commands> matches /[0-9;]*/.  There was an attempt to break this simplicity
in ITU T.416, but fortunately it was mostly ignored, and you can safely
assume all codes that alter character attributes follow this syntax.
There are more ANSI codes than SGR, but those all either move the cursor,
alter the screen, request some feedback or have a similar effect that's
inappropriate inside regular text.

Thus, I'd recommend ignoring /\e\[[0-9;]*m/ and nothing else.

-- 
A tit a day keeps the vet away.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to