'\"macro stdmacro
.if n .pH g3x.curs_color @(#)curs_color	40.3 of 12/15/89
.\" Copyright 1989 AT&T
.\" ident	"@(#)svid_ti:ti_lib/curs_color	1.4"
.nr X
.if \nX=0 .ds x} curs_color 3X "" "\&"
.if \nX=1 .ds x} curs_color 3X ""
.if \nX=2 .ds x} curs_color 3X "" "\&"
.if \nX=3 .ds x} curs_color "" "" "\&"
.TH \*(x}
.SH NAME
\f4curs_color\f2: \f4 start_color\f1, \f4init_pair\f1, \f4init_color\f1, \f4has_colors\f1, \f4can_change_color\f1, \f4color_content\f1, \f4pair_content\f1 \- \f4curses\fP color manipulation routines
.SH SYNOPSIS
.nf
.ft 4
# include <curses.h>
.sp .5
int start_color(void);
.sp .25
int init_pair(short pair, short f, short b);
.sp .25
int init_color(short color, short r, short g, short b);
.sp .25
bool has_colors(void);
.sp .25
bool can_change_color(void);
.sp .25
int color_content(short color, short *r, short *g, short *b);
.sp .25
int pair_content(short pair, short *f, short *b);
.ft 1
.fi
.SH DESCRIPTION
.SS Overview
\f4curses\fP provides routines  that manipulate color on color
alphanumeric terminals.
To use these routines \f4start_color\f1 must be called, usually right after
\f4initscr\f1.
Colors are always used in pairs (referred to as color-pairs).
A color-pair consists of a foreground color (for characters) and
a background color (for the field on which the characters are displayed).
A programmer initializes a color-pair with the routine \f4init_pair\f1.
After it has been initialized, \f4COLOR_PAIR\f1(\f2n\fP), a macro defined in
\f4<curses.h>\f1, can be used in the same ways other
video attributes can be used.
If a terminal is capable of redefining colors, the programmer can use the
routine \f4init_color\f1 to change the definition of a color.
The routines \f4has_colors\f1 and \f4can_change_color\f1
return \f4TRUE\f1 or \f4FALSE\f1, depending on whether the terminal
has color capabilities and whether the programmer can change the colors.
The routine \f4color_content\f1 allows a programmer to identify
the amounts of red, green, and blue components in an initialized color.
The routine \f4pair_content\f1 allows a programmer to find out
how a given color-pair is currently defined.
.SS "Routine Descriptions"
The \f4start_color\f1 routine requires no arguments.
It must be called if the programmer wants to use colors,
and before any other color manipulation routine is called.
It is good practice to call this routine right after \f4initscr\f1.
\f4start_color\f1 initializes eight basic colors
(black, red, green, yellow, blue, magenta, cyan, and white),
and two global variables, \f4COLORS\f1 and \f4COLOR_PAIRS\f1
(respectively defining the maximum number of colors and color-pairs
the terminal can support).
It also restores the colors on the terminal to the values they had
when the terminal was just turned on.
.P
The \f4init_pair\f1 routine changes the definition of a color-pair.
It takes three arguments: the number of the color-pair to be changed,
the foreground color number, and the background color number.
The value of the first argument must be between \f41\fP and
\f4COLOR_PAIRS-1\f1.
The value of the second and third arguments must be between 0
and
\f4COLORS\f1.
If the color-pair was previously initialized, the screen is
refreshed and all occurrences of that color-pair is
changed to the new definition.
.P
The \f4init_color\f1 routine changes the definition of a color.
It takes four arguments: the number of the color to be changed
followed by three RGB values (for the amounts of
red, green, and blue components).
The value of the first argument must be between \f40\fP and
\f4COLORS\f1.
(See the section \f3Colors\f1 for the default color index.)
Each of the last three arguments must be a value between 0 and 1000.
When \f4init_color\f1 is used,
all occurrences of that color on the screen immediately
change to the new definition.
.P
The \f4has_colors\f1 routine requires no arguments.
It returns
\f4TRUE\f1
if the terminal can manipulate colors;
otherwise, it returns \f4FALSE\f1.
This routine facilitates writing terminal-independent programs.
For example, a programmer can
use it to decide whether to use color or some other video attribute.
.P
The \f4can_change_color\f1 routine requires no arguments.
It returns \f4TRUE\s0\f1 if the terminal supports colors and can
change their definitions; other, it returns \f4FALSE\s0\f1.
This routine facilitates writing terminal-independent programs.
.P
The \f4color_content\f1 routine gives users a way to
find the intensity of the red,
green, and blue (\RGB\) components in a color.
It requires four arguments: the color number, and three
addresses of \f4short\f1s for storing the information about the
amounts of red, green, and blue components in the given color.
The value of the first argument must be between 0 and
\f4COLORS\f1.
The values that are stored at the addresses pointed to by
the last three arguments
are between 0 (no component) and 1000 (maximum amount of component).
.P
The \f4pair_content\f1 routine allows users to find out what
colors a given color-pair consists of.
It requires three arguments: the color-pair number, and two addresses
of \f4short\f1s for storing the foreground and the background color numbers.
The value of the first argument must be between 1 and \f4COLOR_PAIRS-1\f1.
The values that are stored at the addresses pointed to by the second
and third arguments are between 0 and \f4COLORS\f1.
.SS Colors
In \f4<curses.h>\f1 the following macros are defined.
These are the default colors.
\f4curses\fP also assumes that \f4COLOR_BLACK\fP is the default
background color for all terminals.
.P
.RS
.nf
\f4COLOR_BLACK\fP
\f4COLOR_RED\fP
\f4COLOR_GREEN\fP
\f4COLOR_YELLOW\fP
\f4COLOR_BLUE\fP
\f4COLOR_MAGENTA\fP
\f4COLOR_CYAN\fP
\f4COLOR_WHITE\fP
.fi
.RE
.SH RETURN VALUE
All routines that return an integer return \f4ERR\f1 upon
failure and \f4OK\f1 upon successful completion.
.br
.ne5
.SH NOTES
.P
The header file \f4<curses.h>\f1 automatically includes the header files
\f4<stdio.h>\f1 and \f4<unctrl.h>\f1.
.SH SEE ALSO
.na
\f4curses\fP(3X),
\f4curs_initscr\fP(3X),
\f4curs_attr\fP(3X).
.ad
