Subject: Re: reverse text
To: None <netbsd-help@netbsd.org>
From: George Georgalis <george@galis.org>
List: netbsd-help
Date: 10/03/2006 12:04:01
Thanks for the info, Johnny.
I did find several ANSI links.
is ANSI part of the POSIX=AE standard
which can be incorporated in netbsd?
eg ansi(5)?
// George
On Mon, Sep 25, 2006 at 11:26:26AM +0200, Johnny Billquist wrote:
>To expand a little. This has nothing to do with bash or NetBSD and so=20
>on... What we're talking about here is the ANSI escape codes to select=20
>graphic rendition (SGR). They are documented by ANSI, and you can=20
>probably find them in any number of places on the net.
>
>Good things to know:
>
>The general format is:
>
>CSI <n> ; <n> ; <n> . . . m
>
>Where CSI is the code to start an escape sequence. It can be the 8-bit=20
>CSI character, or the 7-bit equivalent, which is ESC [
>
>You can then have zero or more numeric parameters, finished by a small=20
>'m'. Each parameter is separated from the next one with a semicolon.
>
>If no number is given, it's the same as giving a '0'.
>
>Parameters are:
>0 - All attributes off
>1 - Bold
>4 - Underline
>5 - Blinking
>7 - Negative image
>8 - Invisible image
>21 - Bold off
>24 - Underline off
>25 - Blinking off
>27 - Negative image off
>28 - Invisible image off
>30 - Foreground color 0 (Black)
>31 - Foreground color 1 (Red)
>32 - Foreground color 2 (Green)
>33 - Foreground color 3 (Yellow)
>34 - Foreground color 4 (Blue)
>35 - Foreground color 5 (Magenta)
>36 - Foreground color 6 (Cyan)
>37 - Foreground color 7 (White)
>39 - Default foreground color
>40 - Background color 0 (Black)
>41 - Background color 1 (Red)
>42 - Background color 2 (Green)
>43 - Background color 3 (Yellow)
>44 - Background color 4 (Blue)
>45 - Background color 5 (Magenta)
>46 - Background color 6 (Cyan)
>47 - Background color 7 (White)
>49 - Default background color
>
>Now, this is as a VT525 will interpret it. On an Xterm, I've found that=20
>37 and 47 are a grayish color, and not white. Also, 90-97 are lighter=20
>versions of the foreground colors, and 100-107 are lighter versions of=20
>the background colors (probably the same as if you select a color and=20
>select bold).
>
>I'm not sure ANSI specifies exactly which colors to expect.
>
>Now, given this information, your answer about light red being 1;30 is=20
>somwhat misleading. What you're actually doing is selecting bold, red=20
>text. :-) However, I'm pretty sure the end result on most terminals will=
=20
>look the same, so it's maybe not that important.
>
>Some people might know parts of this since old times, since the VT100=20
>and all follow ons also implement the applicable parts of this. Color is=
=20
>not something a VT100 can do, and the 2x attributes, to actually turn=20
>off attributes didn't come until the VT200 series, and the same is true=20
>for the concealed attribute.
>
> Johnny
>
>
>George Georgalis wrote:
>>On Sun, Sep 24, 2006 at 03:02:10PM -0400, George Georgalis wrote:
>>
>>>I'm looking for a way to reverse text color. (eg transpose
>>>foreground/background) I'm expecting to find some esc or ctrl
>>>sequence of characters to turn on reverse video and similarly to
>>>turn off. Normally I would ssh in, from an xterm, but I'd like a
>>>technique to work as expected from console, as well--if that's an
>>>issue I can check TERM setting.
>>>
>>>The only doc I've seen on doing this is for PS1 on some shells
>>>but I'm looking for something generic enough that I can invoke
>>>with printf commands.
>>
>>
>>with a little luck and finding some bash PS1 notes... I'm answering
>>my own question.
>>
>># The color terminal (cterm) palette (and bash escape codes)
>># The forground Colors (background colors begin with 4 verses 3)
>># Black 0;30 Dark Gray 1;30
>># Red 0;31 Light Red 1;31
>># Green 0;32 Light Green 1;32
>># Brown 0;33 Yellow 1;33
>># Blue 0;34 Light Blue 1;34
>># Purple 0;35 Light Purple 1;35
>># Cyan 0;36 Light Cyan 1;36
>># Light Gray 0;37 White 1;37
>># Attribute codes:
>># 00=3Dnone 01=3Dbold 04=3Dunderscore 05=3Dblink 07=3Dreverse 08=3Dconcea=
led
>>
>>and looking at 'script' output of some color sequences...
>>
>>echo "=1B[7mhello=1B[m"
>>
>>(if this email comes in 8 bit) that's ^[[7m to start reverse and
>>^[[m to reset the change (note esc char, ^[).
>>
>>but a more universal way might be using "tput" unfortunately
>>you may need the termcap(5) man page too for that.
>>
>>tput mr ; printf hello ; tput me ; echo world
>>
>>and this works both on console and xterm. I never did find netbsd
>>doc on the color codes but this generates a palette of available
>>colors.
>>
>>for n in `seq 0 9` ; do for u in `seq 0 57` ; do
>> printf "^[[${n};${u}m${n};${u}^[[m"
>>done; done
>>echo
>>
>>(note two esc characters as "^[")
>>
>>// George
>>
>>
>
--=20
George Georgalis, systems architect, administrator <IXOYE><