Subject: Re: colors
To: None <netbsd-help@netbsd.org>
From: =?iso-8859-1?Q?Florian_St=F6hr?= <florian.stoehr@login-solutions.de>
List: netbsd-help
Date: 01/15/2003 16:51:02
Hi,

thanks to all who replied. I discovered something:

when setting

TERM=vs100; export TERM

(why "vs" and not "vt" ?!?)

all the curses applications work with colors. btw, "wsvt25l1" dumps curses
app's core.

sequences like "ESC[33m" (ANSI) work for the VT220 terminal only.

I had a short look at the BitchX-sourcecode. They seem to use ANSI sequences
if other ways don't work, so
they can always display colors.

Thanks for source, I didn't know hwo to set the blink/reverse attrs befor
(since console vs100 uses dark colors
and xterm bright colors by default). Now i can force bright/dark.

thanks again.
flo

----- Original Message -----
From: "Julian Coleman" <jdc@coris.demon.co.uk>
To: "Florian St?hr" <florian.stoehr@login-solutions.de>
Cc: "NetBSD netbsd-help mailing list" <netbsd-help@netbsd.org>
Sent: Wednesday, January 15, 2003 3:25 PM
Subject: Re: colors


> > VT220 supports colors.
> >
> > NetBSD-terminal SEEM to support em, too - but only sometimes ?!?
> >
> > IRC-client "Bitch-X" produces well-colored output. But my own (n)curses
programs don't.
> >
> > I know that the kernel prints its messages on color (and i always change
the color to cyan
> > in my own kernels).
> >
> > How to make those curses programs work colored ?
>
> Not sure if you mean "which terminal types support colour?", or "how do I
use
> colour inside a curses application?", so I'll try and answer both.
>
> The terminals that support colour are those that have 'Co' (colours) and
'pa'
> (colour pairs) capabilities in the termcap database, plus either the 'Ab'
and
> 'Af' or the 'Sb' and 'Sf' capabilities, to set the background and
foreground
> colours, repectively.  Examples are 'xterm', 'rxvt' and 'wsvt25' (wscons).
I
> don't think a real vt220 does colour (or maybe it has only 4 colours), but
I
> could be wrong.  Certainly, our termcap entry has no colour support for
the
> vt220.
>
> In order to write curses applications that use colours :
>
>   1) check to see if the terminal supports colours
>   2) initialise colours
>   3) set up the colour pairs
>   4) set the colour pair attribute
>   5) add the characters to the window
>
> Curses applications use colour pairs - a foreground and background colour
> pair for each character on the screen.  Set this colour pair as an
attribute
> using the COLOR_PAIR macro and your text will have these foreground and
> background colours.
>
> The manual pages covering this are curses_color(3), curses_attributes(3),
> curses_background(3) and curses_default_colors(3).  Note that the routines
> in curses_default_colors(3) and the full manual pages have only appeared
> after the 1.6 release.  The manual pages are available online at :
>
>   http://netbsd.gw.com/cgi-bin/man-cgi?curses_color+3
>   http://netbsd.gw.com/cgi-bin/man-cgi?curses_attributes+3
>   http://netbsd.gw.com/cgi-bin/man-cgi?curses_background+3
>   http://netbsd.gw.com/cgi-bin/man-cgi?curses_default_colors+3
>
> A trivial example using colours is :
>
> #include "curses.h"
>
> main() {
> initscr();
> move(1, 10);
> if (has_colors()) {
> start_color();
> init_pair(1, COLOR_WHITE, COLOR_RED);
> attrset(COLOR_PAIR(1));
> addstr("Has colours - using white on red");
> } else {
> attrset(A_REVERSE);
> addstr("No colours - using reverse video");
> }
> getch();
> endwin();
> }
>
> Run this in (say) an xterm and then set the terminal type to vt100 and run
it
> again.
>
> J
>
> --
>                     My other computer also runs NetBSD
>                           http://www.netbsd.org/
>