]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/html/curs_color.3x.html
ncurses 4.1
[ncurses.git] / Ada95 / html / curs_color.3x.html
1 <HTML>
2 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
3 <PRE>
4        <STRONG>start_color</STRONG>,     <STRONG>init_pair</STRONG>,     <STRONG>init_color</STRONG>,    <STRONG>has_colors</STRONG>,
5        <STRONG>can_change_color</STRONG>,  <STRONG>color_content</STRONG>,  <STRONG>pair_content</STRONG>  -  <STRONG>curses</STRONG>
6        color manipulation routines
7
8
9 </PRE>
10 <H2>SYNOPSIS</H2><PRE>
11        <STRONG>#</STRONG> <STRONG>include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
12        <STRONG>int</STRONG> <STRONG>start_color(void);</STRONG>
13        <STRONG>int</STRONG> <STRONG>init_pair(short</STRONG> <STRONG>pair,</STRONG> <STRONG>short</STRONG> <STRONG>f,</STRONG> <STRONG>short</STRONG> <STRONG>b);</STRONG>
14        <STRONG>int</STRONG> <STRONG>init_color(short</STRONG> <STRONG>color,</STRONG> <STRONG>short</STRONG> <STRONG>r,</STRONG> <STRONG>short</STRONG> <STRONG>g,</STRONG> <STRONG>short</STRONG> <STRONG>b);</STRONG>
15        <STRONG>bool</STRONG> <STRONG>has_colors(void);</STRONG>
16        <STRONG>bool</STRONG> <STRONG>can_change_color(void);</STRONG>
17        <STRONG>int</STRONG>  <STRONG>color_content(short</STRONG>  <STRONG>color,</STRONG> <STRONG>short</STRONG> <STRONG>*r,</STRONG> <STRONG>short</STRONG> <STRONG>*g,</STRONG> <STRONG>short</STRONG>
18        <STRONG>*b);</STRONG>
19        <STRONG>int</STRONG> <STRONG>pair_content(short</STRONG> <STRONG>pair,</STRONG> <STRONG>short</STRONG> <STRONG>*f,</STRONG> <STRONG>short</STRONG> <STRONG>*b);</STRONG>
20
21
22 </PRE>
23 <H2>DESCRIPTION</H2><PRE>
24    <STRONG>Overview</STRONG>
25        <STRONG>curses</STRONG> support color attributes  on  terminals  with  that
26        capability.   To  use  these  routines <STRONG>start_color</STRONG> must be
27        called, usually right after <STRONG>initscr</STRONG>.   Colors  are  always
28        used  in pairs (referred to as color-pairs).  A color-pair
29        consists of a foreground  color  (for  characters)  and  a
30        background color (for the blank field on which the charac-
31        ters are displayed).  A programmer  initializes  a  color-
32        pair  with  the routine <STRONG>init_pair</STRONG>.  After it has been ini-
33        tialized, <STRONG>COLOR_PAIR</STRONG>(<EM>n</EM>), a macro  defined  in  <STRONG>&lt;curses.h&gt;</STRONG>,
34        can be used as a new video attribute.
35
36        If  a  terminal  is capable of redefining colors, the pro-
37        grammer can use the routine <STRONG>init_color</STRONG> to change the defi-
38        nition   of   a   color.    The  routines  <STRONG>has_colors</STRONG>  and
39        <STRONG>can_change_color</STRONG>  return  <STRONG>TRUE</STRONG>  or  <STRONG>FALSE</STRONG>,  depending   on
40        whether  the  terminal  has color capabilities and whether
41        the  programmer  can  change  the  colors.   The   routine
42        <STRONG>color_content</STRONG>  allows  a programmer to extract the amounts
43        of red, green,  and  blue  components  in  an  initialized
44        color.   The  routine  <STRONG>pair_content</STRONG> allows a programmer to
45        find out how a given color-pair is currently defined.
46
47    <STRONG>Routine</STRONG> <STRONG>Descriptions</STRONG>
48        The <STRONG>start_color</STRONG> routine requires no arguments.  It must be
49        called  if  the programmer wants to use colors, and before
50        any other color manipulation routine  is  called.   It  is
51        good  practice  to  call this routine right after <STRONG>initscr</STRONG>.
52        <STRONG>start_color</STRONG> initializes eight basic  colors  (black,  red,
53        green,  yellow,  blue,  magenta, cyan, and white), and two
54        global variables,  <STRONG>COLORS</STRONG>  and  <STRONG>COLOR_PAIRS</STRONG>  (respectively
55        defining  the maximum number of colors and color-pairs the
56        terminal can support).  It also restores the colors on the
57        terminal to the values they had when the terminal was just
58        turned on.
59
60        pair to be changed, the foreground color number,  and  the
61        background  color number.  The value of the first argument
62        must be between <STRONG>1</STRONG> and <STRONG>COLOR_PAIRS-1</STRONG>.   The  value  of  the
63        second  and  third  arguments must be between 0 and <STRONG>COLORS</STRONG>
64        (the 0 color pair is wired to white on black and cannot be
65        changed).   If  the color-pair was previously initialized,
66        the screen is refreshed and all occurrences of that color-
67        pair is changed to the new definition.
68
69        The  <STRONG>init_color</STRONG> routine changes the definition of a color.
70        It takes four arguments: the number of  the  color  to  be
71        changed  followed  by three RGB values (for the amounts of
72        red, green, and blue components).  The value of the  first
73        argument  must  be between <STRONG>0</STRONG> and <STRONG>COLORS</STRONG>.  (See the section
74        <STRONG>Colors</STRONG> for the default color index.)   Each  of  the  last
75        three  arguments must be a value between 0 and 1000.  When
76        <STRONG>init_color</STRONG> is used, all occurrences of that color  on  the
77        screen immediately change to the new definition.
78
79        The  <STRONG>has_colors</STRONG> routine requires no arguments.  It returns
80        <STRONG>TRUE</STRONG> if the terminal can manipulate colors; otherwise,  it
81        returns <STRONG>FALSE</STRONG>.  This routine facilitates writing terminal-
82        independent programs.  For example, a programmer  can  use
83        it  to  decide  whether  to  use color or some other video
84        attribute.
85
86        The <STRONG>can_change_color</STRONG> routine requires  no  arguments.   It
87        returns  <STRONG>TRUE</STRONG>  if  the  terminal  supports  colors and can
88        change their definitions; other, it returns  <STRONG>FALSE</STRONG>.   This
89        routine facilitates writing terminal-independent programs.
90
91        The <STRONG>color_content</STRONG> routine gives programmers a way to  find
92        the intensity of the red, green, and blue (RGB) components
93        in a color.  It requires four arguments: the color number,
94        and  three addresses of <STRONG>short</STRONG>s for storing the information
95        about the amounts of red, green, and  blue  components  in
96        the  given color.  The value of the first argument must be
97        between 0 and <STRONG>COLORS</STRONG>.  The values that are stored  at  the
98        addresses  pointed  to  by  the  last  three arguments are
99        between 0 (no component) and 1000 (maximum amount of  com-
100        ponent).
101
102        The  <STRONG>pair_content</STRONG>  routine  allows programmers to find out
103        what colors a given color-pair consists of.   It  requires
104        three  arguments: the color-pair number, and two addresses
105        of <STRONG>short</STRONG>s for storing the foreground  and  the  background
106        color  numbers.   The  value of the first argument must be
107        between 1 and <STRONG>COLOR_PAIRS-1</STRONG>.  The values that  are  stored
108        at  the addresses pointed to by the second and third argu-
109        ments are between 0 and <STRONG>COLORS</STRONG>.
110
111    <STRONG>Colors</STRONG>
112        is the default background color for all terminals.
113
114              <STRONG>COLOR_BLACK</STRONG>
115              <STRONG>COLOR_RED</STRONG>
116              <STRONG>COLOR_GREEN</STRONG>
117              <STRONG>COLOR_YELLOW</STRONG>
118              <STRONG>COLOR_BLUE</STRONG>
119              <STRONG>COLOR_MAGENTA</STRONG>
120              <STRONG>COLOR_CYAN</STRONG>
121              <STRONG>COLOR_WHITE</STRONG>
122
123
124 </PRE>
125 <H2>RETURN VALUE</H2><PRE>
126        The routines <STRONG>can_change_color()</STRONG>  and  <STRONG>has_colors()</STRONG>  return
127        <STRONG>TRUE</STRONG> or <STRONG>FALSE</STRONG>.
128
129        All other routines return the integer <STRONG>ERR</STRONG> upon failure and
130        an <STRONG>OK</STRONG> (SVr4 specifies only "an integer  value  other  than
131        <STRONG>ERR</STRONG>") upon successful completion.
132
133
134 </PRE>
135 <H2>NOTES</H2><PRE>
136        In  the  <EM>ncurses</EM> implementation, there is a separate color
137        activation flag, color palette,  color  pairs  table,  and
138        associated  COLORS and COLOR_PAIRS counts for each screen;
139        the <STRONG>start_color</STRONG> function only affects the current  screen.
140        The SVr4/XSI interface is not really designed with this in
141        mind, and historical  implementations  may  use  a  single
142        shared color palette.
143
144        Note that setting an implicit background color via a color
145        pair affects only character cells that a  character  write
146        operation  explicitly  touches.   To change the background
147        color used when parts of a window are blanked  by  erasing
148        or scrolling operations, see <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>.
149
150        Several  caveats  apply  on 386 and 486 machines with VGA-
151        compatible graphics:
152
153        COLOR_YELLOW  is  actually  brown.   To  get  yellow,  use
154        COLOR_YELLOW combined with the <STRONG>A_BOLD</STRONG> attribute.
155
156        The  A_BLINK  attribute  should  in theory cause the back-
157        ground to go bright.  This often fails to work,  and  even
158        some cards for which it mostly works (such as the Paradise
159        and compatibles) do the wrong thing when you try to set  a
160        bright  "yellow"  background  (you  get  a blinking yellow
161        foreground instead).
162
163        Color RGB values are not settable.
164
165
166 </PRE>
167 <H2>PORTABILITY</H2><PRE>
168        This implementation satisfies XSI Curses's  minimum  maxi-
169        mums for <STRONG>COLORS</STRONG> and <STRONG>COLOR_PAIRS</STRONG>.
170        ground   and   background    color    to    support    the
171        <STRONG>use_default_colors</STRONG> extension, but only if that routine has
172        been first invoked.
173
174
175 </PRE>
176 <H2>SEE ALSO</H2><PRE>
177        <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3X)</A></STRONG>, <STRONG><A HREF="curs_attr.3x.html">curs_attr(3X)</A></STRONG>, <STRONG><A HREF="dft_fgbg.3x.html">dft_fgbg(3X)</A></STRONG>
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224 </PRE>
225 </BODY>
226 </HTML>