bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: attroff and COLOR_PAIR


From: Thomas Dickey
Subject: Re: attroff and COLOR_PAIR
Date: Tue, 26 Oct 2010 19:11:58 -0400 (EDT)

On Tue, 26 Oct 2010, Dulek wrote:

Look at this piece of code:

attron(COLOR_PAIR(1));
addstr("a");
attron(COLOR_PAIR(2));
addstr("b");
attroff(COLOR_PAIR(2));
addstr("c");
attroff(COLOR_PAIR(1));
refresh();

According to  http://www.mkssoftware.com/docs/man3/curs_attr.3.asp manual :

fwiw, the mks page is an old port of ncurses (from the late 1990's iirc).

There's a current set of manpages on my website, e.g.,

http://invisible-island.net/ncurses/man/curs_attr.3x.html

The routine attroff() turns off the named attributes without turning any
other attributes on or off.

This means, that this code should display 'a' in COLOR_PAIR(1) color, 'b' in
COLOR_PAIR(2) color, and 'c' in COLOR_PAIR(1) color. Unfortunately 'c' is
displayed in default terminal color. Why this is happening?

As far as attron/attroff are concerned, the whole field masked by A_COLOR
is a single attribute.

By the way, this is an extension from X/Open, because it accepts color as one of the attributes (matching the SVr4 implementation). X/Open only defines attr_on/attr_off, which separates color from the other attributes (because it's allowing for color pairs past the 6-8 bits used for implementing A_COLOR).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]