-\fBcurses\fR support color attributes on terminals with that capability. To
-use these routines \fBstart_color\fR must be called, usually right after
-\fBinitscr\fR. 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 blank field on which the characters are displayed). A
-programmer initializes a color-pair with the routine \fBinit_pair\fR. After it
-has been initialized, \fBCOLOR_PAIR\fR(\fIn\fR), a macro defined in
-\fB<curses.h>\fR, can be used as a new video attribute.
-.PP
-If a terminal is capable of redefining colors, the programmer can use the
-routine \fBinit_color\fR to change the definition of a color. The routines
-\fBhas_colors\fR and \fBcan_change_color\fR return \fBTRUE\fR or \fBFALSE\fR,
-depending on whether the terminal has color capabilities and whether the
-programmer can change the colors. The routine \fBcolor_content\fR allows a
-programmer to extract the amounts of red, green, and blue components in an
-initialized color. The routine \fBpair_content\fR allows a programmer to find
-out how a given color-pair is currently defined.
-.SS Routine Descriptions
-The \fBstart_color\fR 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 \fBinitscr\fR. \fBstart_color\fR initializes
-eight basic colors (black, red, green, yellow, blue, magenta, cyan,
-and white), and two global variables, \fBCOLORS\fR and
-\fBCOLOR_PAIRS\fR (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.
-.PP
-The \fBinit_pair\fR routine changes the definition of a color-pair. It takes
-three arguments: the number of the color-pair to be changed, the foreground
+\fIcurses\fP supports color attributes on terminals with that
+capability.
+Call \fB\%start_color\fP
+(typically right after \fB\%initscr\fP(3X))
+to enable this feature.
+Colors are always used in pairs.
+A
+.I "color pair"
+couples a foreground color for characters with a background color for
+the blank field on which characters are rendered.
+\fB\%init_pair\fP initializes a color pair.
+The macro \fB\%COLOR_PAIR\fP(\fIn\fP) can then convert the pair to a
+video attribute.
+.PP
+If a terminal has the relevant capability,
+\fB\%init_color\fP permits (re)definition of a color.
+\fB\%has_colors\fP and \fB\%can_change_color\fP
+return \fBTRUE\fP or \fBFALSE\fP,
+depending on whether the terminal has color capability and whether the
+programmer can change the colors.
+\fB\%color_content\fP permits extraction of the
+red,
+green,
+and blue components of an initialized color.
+\fB\%pair_content\fP permits discovery of a color pair's current
+definition.
+.SS Rendering
+.I curses
+combines the following data to render a character cell.
+Any of them can include color information.
+.bP
+.I curses
+character attributes,
+as from \fB\%waddch\fP(3X) or \fB\%wadd_wch\fP(3X)
+.bP
+window attributes,
+as from \fB\%wattrset\fP(3X) or \fB\%wattr_set\fP(3X)
+.bP
+window background character attributes,
+as from \fB\%wbkgdset\fP(3X) or \fB\%wbkgrndset\fP(3X)
+.PP
+Per-character and window attributes are usually set through a function
+parameter containing attributes including a color pair value.
+Some functions,
+such as \fB\%wattr_set\fP,
+use a separate color pair number parameter.
+.PP
+The background character is a special case:
+it includes a character code,
+just as if it were passed to \fB\%waddch\fP.
+.PP
+The \fIcurses\fP library does the actual work of combining these color
+pairs in an internal function called from \fB\%waddch\fP:
+.bP
+If the parameter passed to \fB\%waddch\fP is \fIblank\fP,
+and it uses the special color pair 0,
+.RS
+.bP
+\fIcurses\fP next checks the window attribute.
+.bP
+If the window attribute does not use color pair 0,
+\fIcurses\fP uses the color pair from the window attribute.
+.bP
+Otherwise, \fIcurses\fP uses the background character.
+.RE
+.bP
+If the parameter passed to \fB\%waddch\fP is \fInot blank\fP,
+or it does not use the special color pair 0,
+\fIcurses\fP prefers the color pair from the parameter,
+if it is nonzero.
+Otherwise, it tries the window attribute next, and finally the
+background character.
+.PP
+Some \fIcurses\fP functions such as \fB\%wprintw\fP call \fB\%waddch\fP.
+Those do not combine its parameter with a color pair.
+Consequently those calls use only the window attribute or
+the background character.
+.SH CONSTANTS
+In \fB\%<curses.h>\fP the following macros are defined.
+These are the standard colors (ISO-6429).
+\fIcurses\fP also assumes that \fB\%COLOR_BLACK\fP is the default
+background color for all terminals.
+.PP
+.nf
+ \fBCOLOR_BLACK\fP
+ \fBCOLOR_RED\fP
+ \fBCOLOR_GREEN\fP
+ \fBCOLOR_YELLOW\fP
+ \fBCOLOR_BLUE\fP
+ \fBCOLOR_MAGENTA\fP
+ \fBCOLOR_CYAN\fP
+ \fBCOLOR_WHITE\fP
+.fi
+.PP
+Some terminals support more than the eight (8) \*(``ANSI\*('' colors.
+There are no standard names for those additional colors.
+.SH VARIABLES
+.SS COLORS
+is initialized by \fB\%start_color\fP to the maximum number of colors
+the terminal can support.
+.SS COLOR_PAIRS
+is initialized by \fB\%start_color\fP to the maximum number of color
+pairs the terminal can support.
+Often,
+its value is the product \fB\%COLORS\fP \(mu \fB\%COLORS\fP,
+but this is not always true.
+.bP
+A few terminals use the HLS color space
+(see \fB\%start_color\fP below),
+ignoring this rule;
+and
+.bP
+terminals supporting a large number of colors are limited to the number
+of color pairs that a
+.I "signed short"
+value can represent.
+.SH FUNCTIONS
+.SS start_color
+The \fB\%start_color\fP 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 \fB\%initscr\fP.
+\fB\%start_color\fP does this:
+.bP
+It initializes two global variables, \fB\%COLORS\fP and
+\fB\%COLOR_PAIRS\fP (respectively defining the maximum number of colors
+and color pairs the terminal can support).
+.bP
+It initializes the special color pair \fB\%0\fP to the default foreground
+and background colors.
+No other color pairs are initialized.
+.bP
+It restores the colors on the terminal to the values
+they had when the terminal was just turned on.
+.bP
+If the terminal supports the \fBinitc\fP \%(\fBinitialize_color\fP) capability,
+\fB\%start_color\fP
+initializes its internal table representing the
+red, green, and blue components of the color palette.
+.IP
+The components depend on whether the terminal uses
+CGA (aka \*(``ANSI\*('') or
+HLS (i.e., the \fBhls\fP \%(\fBhue_lightness_saturation\fP) capability is set).
+The table is initialized first for eight basic colors
+(black, red, green, yellow, blue, magenta, cyan, and white),
+using weights that depend upon the CGA/HLS choice.
+For \*(``ANSI\*('' colors the weights are \fB680\fP or \fB0\fP
+depending on whether the corresponding
+red, green, or blue component is used or not.
+That permits using \fB1000\fP to represent bold/bright colors.
+After the initial eight colors
+(if the terminal supports more than eight colors)
+the components are initialized using the same pattern,
+but with weights of \fB1000\fP.
+SVr4 uses a similar scheme, but uses \fB1000\fP
+for the components of the initial eight colors.
+.IP
+\fB\%start_color\fP does not attempt to set the terminal's color palette
+to match its built-in table.
+An application may use \fB\%init_color\fP to alter the internal table
+along with the terminal's color.
+.PP
+These limits apply to color values and color pairs.
+Values outside these limits are not valid, and may result in a runtime error:
+.bP
+\fBCOLORS\fP corresponds to the terminal database's \fB\%max_colors\fP capability,
+(see \fB\%terminfo\fP(5)).
+.bP
+color values are expected to be in the range \fB0\fP to \fB\%COLORS\-1\fP,
+inclusive (including \fB0\fP and \fB\%COLORS\-1\fP).
+.bP
+a special color value \fB\-1\fP is used in certain extended functions
+to denote the \fIdefault color\fP (see \fB\%use_default_colors\fP(3X)).
+.bP
+\fB\%COLOR_PAIRS\fP corresponds to
+the terminal database's \fB\%max_pairs\fP capability,
+(see \fB\%terminfo\fP(5)).
+.bP
+valid color pair values are in the range \fB1\fP to \fB\%COLOR_PAIRS\-1\fP,
+inclusive.
+.bP
+color pair \fB0\fP is special; it denotes \*(``no color\*(''.
+.IP
+Color pair \fB0\fP is assumed to be white on black,
+but is actually whatever the terminal implements before color is initialized.
+It cannot be modified by the application.
+.SS has_colors
+The \fB\%has_colors\fP routine requires no arguments.
+It returns \fBTRUE\fP if
+the terminal can manipulate colors; otherwise, it returns \fBFALSE\fP.
+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.
+.SS can_change_color
+The \fB\%can_change_color\fP routine requires no arguments.
+It returns \fBTRUE\fP if the terminal supports colors
+and can change their definitions;
+other, it returns \fBFALSE\fP.
+This routine facilitates writing terminal-independent programs.
+.SS init_pair
+The \fB\%init_pair\fP routine changes the definition of a color pair.
+It takes three arguments:
+the number of the color pair to be changed, the foreground