HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)
c
can_change_color(3X) can_change_color(3X)
(ENHANCED CURSES)
User-Defined Colour Pairs
Calling init_pair() defines or redefines colour-pair number pair to have foreground colour f and
background colour b. Calling
init_pair() changes any characters that were displayed in the colour
pair’s old definition to the new definition and refreshes the screen.
After defining the colour pair, the macro
COLOR_PAIR(n) returns the value of colour pair n. This value
is the colour attribute as it would be extracted from a
chtype. Conversely, the macro
PAIR_NUMBER(value) returns the colour pair number associated with the colour attribute value.
The
pair_content()
function retrieves the component colours of a colour-pair number pair.Itstores
the foreground and background colour numbers in the variables pointed to by f and b, respectively.
With
init_pair() and pair_content()
, the value of pair must be in a range from 0 to and includ-
ing
COLOR_PAIRS − 1. (There may be an implementation-specific lower limit on the valid value of pair,
but any such limit is at least 63.) Valid values for f and b are the range from 0 to and including
COLORS − 1.
RETURN VALUE
The
has_colors() function returns TRUE if the terminal can manipulate colors; otherwise, it returns
FALSE.
The
can_change_color()
function returns TRUE if the terminal supports colors and can change
their definitions; otherwise, it returns FALSE.
Upon successful completion, the other functions return OK; otherwise, they return ERR.
ERRORS
No errors are defined.
APPLICATION USAGE
To use these functions,
start_color()
must be called, usually right after initscr().
The
can_change_color()
and has_colors() functions facilitate writing terminal-independent
programs. For example, a programmer can use them to decide whether to use colour or some other video
attribute.
On color terminals, a typical value of
COLORS is 8 and the macros such as COLOR_BLACK
return a value
within the range from 0 to and including 7. However, applications cannot rely on this to be true.
SEE ALSO
attroff(3X), delscreen(3X), <curses.h>.
CHANGE HISTORY
First released in X/Open Curses, Issue 4.
HP-UX 11i Version 2: September 2004 − 2 − Hewlett-Packard Company Section 3−−81