1 .\" $NetBSD: curses_color.3,v 1.12 2009/07/22 16:57:14 roy Exp $
2 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
3 .\" All rights reserved.
5 .\" This code is derived from software contributed to The NetBSD Foundation
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 .\" POSSIBILITY OF SUCH DAMAGE.
34 .Nm can_change_color ,
42 .Nm no_color_attributes
43 .Nd curses color manipulation routines
51 .Fn can_change_color void
55 .Fn init_pair "short pair" "short fore" "short back"
57 .Fn pair_content "short pair" "short *fore" "short *back"
59 .Fn COLOR_PAIR "int n"
61 .Fn PAIR_NUMBER "int val"
63 .Fn init_color "short color" "short red" "short green" "short blue"
65 .Fn color_content "short color" "short *red" "short *green" "short *blue"
67 .Fn no_color_attributes void
69 .Va extern int COLOR_PAIRS ;
71 .Va extern int COLORS ;
73 These functions manipulate color on terminals that support color attributes.
77 indicates whether a terminal is capable of displaying color attributes.
80 if the terminal is capable of displaying color attributes and
86 indicates whether a terminal is capable of redefining colors.
89 if colors can be redefined and
95 initializes the curses color support on a terminal.
96 It must be called before any color manipulation functions are called on that
98 The function initializes the eight basic colors (black, red, green, yellow,
99 blue, magenta, cyan and white) that are specified using the color macros
103 .Em \*[Lt]curses.h\*[Gt] .
105 also initializes the global external variables
110 defines the number of colors that the terminal supports and
112 defines the number of color-pairs that the terminal supports.
113 These color-pairs are initialized to white foreground on black background.
115 sets the colors on the terminal to the curses defaults of white
116 foreground on black background unless the functions
117 .Fn assume_default_colors
119 .Fn use_default_colors
120 have been called previously.
123 .Fn init_pair pair fore back
124 sets foreground color
128 for color-pair number
130 The valid range for the color-pair
135 and the valid range for the colors is any number less than
137 Specifying a negative number will set that color to the default foreground
139 The 8 initial colors are defined as:
140 .Bl -tag -width "COLOR_MAGENTA" -compact -offset indent
150 Color-pair 0 is used as the default color pair, so changing this will
153 .Fn assume_default_colors
154 to change the default colors.
157 .Fn pair_content pair *fore *back
158 stores the foreground and background color numbers of color-pair
168 gives the attribute value of color-pair number
170 This is the value that is used to set the attribute of a character to this
173 .Dl attrset(COLOR_PAIR(2))
174 will display characters using color-pair 2.
178 gives the color-pair number associated with the attribute value
182 .Fn init_color color red green blue
183 sets the red, green and blue intensity components of color
191 The minimum intensity value is 0 and the maximum intensity value is 1000.
194 .Fn color_content color *red *green *blue
195 stores the red, green and blue intensity components of color
205 .Fn no_color_attributes
206 returns those attributes that a terminal is unable to combine with color.
215 return OK on success and ERR on failure.
217 .Xr curses_attributes 3 ,
218 .Xr curses_background 3 ,
219 .Xr curses_default_colors 3
223 Curses library complies with the X/Open Curses specification, part of the
224 Single Unix Specification.
227 .Fn no_color_attributes
228 and the use of negative color numbers
229 are extensions to the X/Open Curses specification.
231 These functions first appeared in