Subject: curses background color issue
To: None <netbsd-help@netbsd.org>
From: Peter Bex <Peter.Bex@student.kun.nl>
List: netbsd-help
Date: 03/08/2004 20:07:21
--/Uq4LBwYP4y1W6pO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello list,

A little question that arised while learning libcurses:
How does one correctly initialise a color pair so as only to set the
foreground color?  (thus preserving the terminal's background)

Right now I'm using (on -CURRENT, as 1.6.1 doesn't support
use_default_colors) the following:

        init_pair(1, COLOR_YELLOW, -1);

which works, but there's no mentioning of this (the -1) in the manpages
of -CURRENT, and there are absolutely no checks in the code of curses on
what to do with -1, it seems (or I'm missing them).

The ncurses manpages mention -1:

	As  an  extension,  ncurses  allows  you  to  set  color pair 0
	via the assume_default_colors routine, or to specify the use of
	default  colors (color number -1) if you first invoke the
	use_default_colors routine.

But later they are saying it does not have to be -1 necessarily, but
can be any negative value:

	The init_pair routine accepts negative values of foreground
	and  background  color  to support the use_default_colors
	extension, but only if that routine has been first invoked.

And I've observed that 0 also works as background color in NetBSD
curses, but negative values other than -1 don't work, while in ncurses
they do.

Does this mean our curses implementation is flawed, or the documentation
is incomplete, or both?  IMHO the ncurses documentation is not clear
enough on this either.

By the way, I'm using ncurses-5.3nb1 from pkgsrc and curses from -CURRENT.

Regards,
Peter
--=20
http://www.student.kun.nl/peter.bex
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
							-- Donald Knuth

--/Uq4LBwYP4y1W6pO
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFATMRpLg33BXzVMqsRAjjNAJ9NABoEwlgABMH77IZ6BRVPEX8IvQCgxjFx
TQUNk11HfFPe5sxs7UYKG0k=
=HQ4l
-----END PGP SIGNATURE-----

--/Uq4LBwYP4y1W6pO--