HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)
c
can_change_color(3X) can_change_color(3X)
(ENHANCED CURSES)
NAME
can_change_color(), color_content(), has_colors(), init_color(), init_pair(), start_color(), pair_content() - color
manipulation functions
SYNOPSIS
#include <curses.h>
bool can_change_color(void);
int color_content(short color, short *red, short *green, short *blue);
int COLOR_PAIR(int n);
bool has_colors(void);
int init_color(short color, short red, short green, short blue);
int init_pair(short pair, short f, short b);
int pair_content(short pair, short *f, short *b);
int PAIR_NUMBER(int value);
int start_color(void);
extern int COLOR_PAIRS;
extern int COLORS;
DESCRIPTION
These functions manipulate colour on terminals that support colour.
Querying Capabilities
The has_colors() function indicates whether the terminal is a colour terminal. The
can_change_color()
function indicates whether the terminal is a colour terminal on which colours
can be redefined.
Initialisation
The
start_color() function must be called in order to enable use of colours and before any colour
manipulation function is called. The function initialises eight basic colours (black, blue, green, cyan, red,
magenta, yellow, and white) that can be specified by the colour macros (such as
COLOR_BLACK ) defined in
<curses.h> . (See Colour-related Macros in
<curses.h> .) The initial appearance of these eight
colours is not specified.
The function also initialises two global external variables:
•
COLORS defines the number of colours that the terminal supports. (See Colour Identification
below.) If
COLORS is 0, the terminal does not support redefinition of colours (and
can_change_colour()
will return FALSE).
•
COLOR_PAIRS defines the maximum number of colour-pairs that the terminal supports. (See
User-Defined Colour Pairs below.)
The start_color() function also restores the colours on the terminal to terminal-specific initial values.
The initial background colour is assumed to be black for all terminals.
Colour Identification
The init_color() function redefines colour number color, on terminals that support the redefinition of
colours, to have the red, green, and blue intensity components specified by red, green, and blue, respec-
tively. Calling init_color() also changes all occurrences of the specified colour on the screen to the
new definition.
The color_content() function identifies the intensity components of colour number color.Itstores
the red, green, and blue intensity components of this colour in the addresses pointed to by red, green, and
blue, respectively.
For both functions, the color argument must be in the range from 0 to and including COLORS − 1. Valid
intensity values range from 0 (no intensity component) up to and including 1000 (maximum intensity in
that component).
152 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: December 2007 Update