Debian Codegraph @

upstream/opensuse-leap-16-1/man3/color.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
4 .\" *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
12 .\" *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
15 .\" *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
27 .\" authorization. *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_color.3x,v 1.118 2025/04/05 21:59:03 tom Exp $
31 .TH color 3NCURSES 2025-04-05 "ncurses 6.5" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el .ds `` ""
39 .ie t .ds '' ''
40 .el .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n .IP \(bu 4
45 .el .IP \(bu 2
46 ..
47 .
48 .SH NAME
49 \fB\%start_color\fP,
50 \fB\%has_colors\fP,
51 \fB\%can_change_color\fP,
52 \fB\%init_pair\fP,
53 \fB\%init_color\fP,
54 \fB\%init_extended_pair\fP,
55 \fB\%init_extended_color\fP,
56 \fB\%color_content\fP,
57 \fB\%pair_content\fP,
58 \fB\%extended_color_content\fP,
59 \fB\%extended_pair_content\fP,
60 \fB\%reset_color_pairs\fP,
61 \fB\%COLOR_PAIR\fP,
62 \fB\%PAIR_NUMBER\fP,
63 \fB\%COLORS\fP,
64 \fB\%COLOR_PAIRS\fP,
65 \fB\%COLOR_BLACK\fP,
66 \fB\%COLOR_RED\fP,
67 \fB\%COLOR_GREEN\fP,
68 \fB\%COLOR_YELLOW\fP,
69 \fB\%COLOR_BLUE\fP,
70 \fB\%COLOR_MAGENTA\fP,
71 \fB\%COLOR_CYAN\fP,
72 \fB\%COLOR_WHITE\fP,
73 \fB\%A_COLOR\fP \-
74 manipulate terminal colors with \fIcurses\fR
75 .SH SYNOPSIS
76 .nf
77 \fB#include <ncursesw/curses.h>
78 .PP
79 \fI/* variables */
80 \fBint COLOR_PAIRS;
81 \fBint COLORS;
82 .PP
83 \fBint start_color(void);
84 .PP
85 \fBbool has_colors(void);
86 \fBbool can_change_color(void);
87 .PP
88 \fBint init_pair(short \fIpair\fP, short \fIf\fP, short \fIb\fP);
89 \fBint init_color(short \fIcolor\fP, short \fIr\fP, short \fIg\fP, short \fIb\fP);
90 \fI/* extensions */
91 \fBint init_extended_pair(int \fIpair\fP, int \fIf\fP, int \fIb\fP);
92 \fBint init_extended_color(int \fIcolor\fP, int \fIr\fP, int \fIg\fP, int \fIb\fP);
93 .PP
94 \fBint color_content(short \fIcolor\fP, short *\fIr\fP, short *\fIg\fP, short *\fIb\fP);
95 \fBint pair_content(short \fIpair\fP, short *\fIf\fP, short *\fIb\fP);
96 \fI/* extensions */
97 \fBint extended_color_content(int \fIcolor\fP, int *\fIr\fP, int *\fIg\fP, int *\fIb\fP);
98 \fBint extended_pair_content(int \fIpair\fP, int *\fIf\fP, int *\fIb\fP);
99 .PP
100 \fI/* extension */
101 \fBvoid reset_color_pairs(void);
102 .PP
103 \fI/* macros */
104 \fBint COLOR_PAIR(int \fIn\fP);
105 \fBPAIR_NUMBER(int \fIattr\fP);
106 \fBCOLOR_BLACK
107 \fBCOLOR_RED
108 \fBCOLOR_GREEN
109 \fBCOLOR_YELLOW
110 \fBCOLOR_BLUE
111 \fBCOLOR_MAGENTA
112 \fBCOLOR_CYAN
113 \fBCOLOR_WHITE
114 \fBA_COLOR
115 .fi
116 .SH DESCRIPTION
117 .SS Overview
118 \fIcurses\fP supports color attributes on terminals with that
119 capability.
120 Call \fB\%start_color\fP
121 (typically right after \fB\%initscr\fP(3NCURSES))
122 to enable this feature.
123 Colors are always used in pairs.
124 A
125 .I "color pair"
126 couples a foreground color for characters with a background color for
127 the blank field on which characters are rendered.
128 \fB\%init_pair\fP initializes a color pair.
129 The macro \fB\%COLOR_PAIR\fP(\fIn\fP) can then convert the pair to a
130 video attribute.
131 .PP
132 If a terminal has the relevant capability,
133 \fB\%init_color\fP permits (re)definition of a color.
134 \fB\%has_colors\fP and \fB\%can_change_color\fP
135 return \fBTRUE\fP or \fBFALSE\fP,
136 depending on whether the terminal has color capability and whether the
137 programmer can change the colors.
138 \fB\%color_content\fP permits extraction of the
139 red,
140 green,
141 and blue components of an initialized color.
142 \fB\%pair_content\fP permits discovery of a color pair's current
143 definition.
144 .SS Rendering
145 .I curses
146 combines the following data to render a character cell.
147 Any of them can include color information.
148 .bP
149 .I curses
150 character attributes,
151 as from \fB\%waddch\fP(3NCURSES) or \fB\%wadd_wch\fP(3NCURSES)
152 .bP
153 window attributes,
154 as from \fB\%wattrset\fP(3NCURSES) or \fB\%wattr_set\fP(3NCURSES)
155 .bP
156 window background character attributes,
157 as from \fB\%wbkgdset\fP(3NCURSES) or \fB\%wbkgrndset\fP(3NCURSES)
158 .PP
159 Per-character and window attributes are usually set through a function
160 parameter containing attributes including a color pair value.
161 Some functions,
162 such as \fB\%wattr_set\fP,
163 use a separate color pair number parameter.
164 .PP
165 The background character is a special case:
166 it includes a character code,
167 just as if it were passed to \fB\%waddch\fP.
168 .PP
169 The \fIcurses\fP library does the actual work of combining these color
170 pairs in an internal function called from \fB\%waddch\fP:
171 .bP
172 If the parameter passed to \fB\%waddch\fP is \fIblank\fP,
173 and it uses the special color pair 0,
174 .RS
175 .bP
176 \fIcurses\fP next checks the window attribute.
177 .bP
178 If the window attribute does not use color pair 0,
179 \fIcurses\fP uses the color pair from the window attribute.
180 .bP
181 Otherwise, \fIcurses\fP uses the background character.
182 .RE
183 .bP
184 If the parameter passed to \fB\%waddch\fP is \fInot blank\fP,
185 or it does not use the special color pair 0,
186 \fIcurses\fP prefers the color pair from the parameter,
187 if it is nonzero.
188 Otherwise, it tries the window attribute next, and finally the
189 background character.
190 .PP
191 Some \fIcurses\fP functions such as \fB\%wprintw\fP call \fB\%waddch\fP.
192 Those do not combine its parameter with a color pair.
193 Consequently those calls use only the window attribute or
194 the background character.
195 .SH CONSTANTS
196 ISO\ 6429 and ECMA-48
197 define eight standard colors
198 (also known as \*(``ANSI\*('' colors).
199 .I curses\.h
200 defines object-like macros
201 .BR \%COLOR_BLACK ","
202 .BR \%COLOR_RED ","
203 .BR \%COLOR_GREEN ","
204 .BR \%COLOR_YELLOW ","
205 .BR \%COLOR_BLUE ","
206 .BR \%COLOR_MAGENTA ","
207 .BR \%COLOR_CYAN ","
208 and
209 .B \%COLOR_WHITE
210 accordingly.
211 .I curses
212 assumes that
213 .B \%COLOR_BLACK
214 is the default background color for all terminals.
215 .I \%ncurses
216 offers an extension to override that assumption;
217 see \fB\%assume_default_colors\fP(3NCURSES).
218 Some terminals support additional colors that lack standard names.
219 .PP
220 .B \%A_COLOR
221 is a bit mask that,
222 when bitwise \*(``and\*(''-ed with a
223 .IR \%chtype ","
224 .\" XXX: and right-shifted by...?
225 extracts its color pair identifier.
226 .SH VARIABLES
227 .SS COLORS
228 is initialized by \fB\%start_color\fP to the maximum number of colors
229 the terminal can support.
230 .SS COLOR_PAIRS
231 is initialized by \fB\%start_color\fP to the maximum number of color
232 pairs the terminal can support.
233 Often,
234 its value is the product \fB\%COLORS\fP \(mu \fB\%COLORS\fP,
235 but this is not always true.
236 .bP
237 A few terminals use the HLS color space
238 (see \fB\%start_color\fP below),
239 ignoring this rule;
240 and
241 .bP
242 terminals supporting a large number of colors are limited to the number
243 of color pairs that a
244 .I "signed short"
245 value can represent.
246 .SH FUNCTIONS
247 .SS start_color
248 The \fB\%start_color\fP routine requires no arguments.
249 It must be called if the programmer wants to use colors, and before any other
250 color manipulation routine is called.
251 It is good practice to call this routine right after \fB\%initscr\fP.
252 \fB\%start_color\fP does this:
253 .bP
254 It initializes two global variables, \fB\%COLORS\fP and
255 \fB\%COLOR_PAIRS\fP (respectively defining the maximum number of colors
256 and color pairs the terminal can support).
257 .bP
258 It initializes the special color pair \fB\%0\fP to the default foreground
259 and background colors.
260 No other color pairs are initialized.
261 .bP
262 It restores the colors on the terminal to the values
263 they had when the terminal was just turned on.
264 .bP
265 If the terminal supports the \fBinitc\fP \%(\fBinitialize_color\fP) capability,
266 \fB\%start_color\fP
267 initializes its internal table representing the
268 red, green, and blue components of the color palette.
269 .IP
270 The components depend on whether the terminal uses
271 CGA (aka \*(``ANSI\*('') or
272 HLS (i.e., the \fBhls\fP \%(\fBhue_lightness_saturation\fP) capability is set).
273 The table is initialized first for eight basic colors
274 (black, red, green, yellow, blue, magenta, cyan, and white),
275 using weights that depend upon the CGA/HLS choice.
276 For \*(``ANSI\*('' colors the weights are \fB680\fP or \fB0\fP
277 depending on whether the corresponding
278 red, green, or blue component is used or not.
279 That permits using \fB1000\fP to represent bold/bright colors.
280 After the initial eight colors
281 (if the terminal supports more than eight colors)
282 the components are initialized using the same pattern,
283 but with weights of \fB1000\fP.
284 SVr4 uses a similar scheme, but uses \fB1000\fP
285 for the components of the initial eight colors.
286 .IP
287 \fB\%start_color\fP does not attempt to set the terminal's color palette
288 to match its built-in table.
289 An application may use \fB\%init_color\fP to alter the internal table
290 along with the terminal's color.
291 .PP
292 These limits apply to color values and color pairs.
293 Values outside these limits are not valid, and may result in a runtime error:
294 .bP
295 \fBCOLORS\fP corresponds to the terminal database's \fB\%max_colors\fP capability,
296 (see \fB\%terminfo\fP(5)).
297 .bP
298 color values are expected to be in the range \fB0\fP to \fB\%COLORS\-1\fP,
299 inclusive (including \fB0\fP and \fB\%COLORS\-1\fP).
300 .bP
301 a special color value \fB\-1\fP is used in certain extended functions
302 to denote the \fIdefault color\fP (see \fB\%use_default_colors\fP(3NCURSES)).
303 .bP
304 \fB\%COLOR_PAIRS\fP corresponds to
305 the terminal database's \fB\%max_pairs\fP capability,
306 (see \fB\%terminfo\fP(5)).
307 .bP
308 valid color pair values are in the range \fB1\fP to \fB\%COLOR_PAIRS\-1\fP,
309 inclusive.
310 .bP
311 color pair \fB0\fP is special; it denotes \*(``no color\*(''.
312 .IP
313 Color pair \fB0\fP is assumed to be white on black,
314 but is actually whatever the terminal implements before color is initialized.
315 It cannot be modified by the application.
316 .SS has_colors
317 .B \%has_colors
318 returns
319 .B TRUE
320 if the terminal supports colors and
321 .B FALSE
322 if it does not.
323 \fB\%initscr\fP(3NCURSES) or \fB\%newterm\fP(3NCURSES) must be called first,
324 but
325 .B \%start_color
326 need not be.
327 An application might call
328 .B \%has_colors
329 to decide whether to use color
330 or a video attribute like
331 .B \%A_BOLD
332 to render text.
333 .PP
334 Color support in
335 .I curses
336 requires that the terminal type description
337 support the capabilities
338 .B \%max_colors
339 .RB \%( colors ),
340 .B \%max_pairs
341 .RB \%( pairs ),
342 and any of
343 .bP
344 .B \%set_foreground
345 .RB ( setf )
346 and
347 .B \%set_background
348 .RB ( setb );
349 .bP
350 .B \%set_a_foreground
351 .RB ( setaf )
352 and
353 .B \%set_a_background
354 .RB ( setab );
355 or
356 .bP
357 .B \%set_color_pair
358 .RB ( scp ).
359 .SS can_change_color
360 The \fB\%can_change_color\fP routine requires no arguments.
361 It returns \fBTRUE\fP if the terminal supports colors
362 and can change their definitions;
363 other, it returns \fBFALSE\fP.
364 This routine facilitates writing terminal-independent programs.
365 .SS init_pair
366 The \fB\%init_pair\fP routine changes the definition of a color pair.
367 It takes three arguments:
368 the number of the color pair to be changed, the foreground
369 color number, and the background color number.
370 For portable applications:
371 .bP
372 The first argument must be a valid color pair value.
373 If default colors are used (see \fB\%use_default_colors\fP(3NCURSES))
374 the upper limit is adjusted to allow for extra pairs which use
375 a default color in foreground and/or background.
376 .bP
377 The second and third arguments must be valid color values.
378 .PP
379 If the color pair was previously initialized,
380 the screen is refreshed and all occurrences of that color pair
381 are changed to the new definition.
382 .PP
383 As an extension,
384 \fI\%ncurses\fP allows you to set color pair \fB0\fP via the
385 \fB\%assume_default_colors\fP(3NCURSES) routine, or to specify the use of
386 default colors (color number \fB\-1\fP) if you first invoke the
387 \fB\%use_default_colors\fP(3NCURSES) routine.
388 .SS init_extended_pair
389 Because \fB\%init_pair\fP uses signed \fBshort\fPs for its parameters,
390 that limits color pairs and color-values
391 to 32767 on modern hardware.
392 The extension \fB\%init_extended_pair\fP uses \fBint\fPs
393 for the color pair and color-value,
394 allowing a larger number of colors to be supported.
395 .SS init_color
396 The \fB\%init_color\fP routine changes the definition of a color.
397 It takes four arguments:
398 the number of the color to be changed followed by three RGB values
399 (for the amounts of red, green, and blue components).
400 .bP
401 The first argument must be a valid color value;
402 default colors are not allowed here.
403 (See the section \fB\%Colors\fP for the default color index.)
404 .bP
405 Each of the last three arguments
406 must be a value in the range \fB0\fP through \fB1000\fP.
407 .PP
408 When \fB\%init_color\fP is used, all
409 occurrences of that color on the screen immediately change to the new
410 definition.
411 .SS init_extended_color
412 Because \fB\%init_color\fP uses signed \fBshort\fPs for its parameters,
413 that limits color-values and their red, green, and blue components
414 to 32767 on modern hardware.
415 The extension \fB\%init_extended_color\fP uses \fBint\fPs
416 for the color value and
417 for setting the red, green, and blue components,
418 allowing a larger number of colors to be supported.
419 .SS color_content
420 The \fB\%color_content\fP routine gives programmers a way to find the intensity
421 of the red, green, and blue (RGB) components in a color.
422 It requires four arguments: the color number, and three addresses
423 of \fBshort\fRs for storing
424 the information about the amounts of red, green, and blue components in the
425 given color.
426 .bP
427 The first argument must be a valid color value, i.e.,
428 \fB0\fP through \fB\%COLORS\-1\fP, inclusive.
429 .bP
430 The values that are stored at the addresses pointed to by the
431 last three arguments are in the range
432 \fB0\fP (no component) through \fB1000\fP
433 (maximum amount of component), inclusive.
434 .SS extended_color_content
435 Because \fB\%color_content\fP uses signed \fBshort\fPs for its parameters,
436 that limits color-values and their red, green, and blue components
437 to 32767 on modern hardware.
438 The extension \fB\%extended_color_content\fP uses \fBint\fPs
439 for the color value and
440 for returning the red, green, and blue components,
441 allowing a larger number of colors to be supported.
442 .SS pair_content
443 The \fB\%pair_content\fP routine allows programmers to find out what colors a
444 given color pair consists of.
445 It requires three arguments: the color pair
446 number, and two addresses of \fBshort\fRs for storing the foreground and the
447 background color numbers.
448 .bP
449 The first argument must be a valid color value,
450 i.e., in the range \fB1\fP through \fB\%COLOR_PAIRS\-1\fP, inclusive.
451 .bP
452 The values that are stored at the addresses pointed
453 to by the second and third arguments are in the
454 range \fB0\fP through \fB\%COLORS\fP, inclusive.
455 .SS extended_pair_content
456 Because \fB\%pair_content\fP uses signed \fBshort\fPs for its parameters,
457 that limits color pair and color-values to 32767 on modern hardware.
458 The extension \fB\%extended_pair_content\fP uses \fBint\fPs
459 for the color pair and
460 for returning the foreground and background colors,
461 allowing a larger number of colors to be supported.
462 .SS reset_color_pairs
463 The extension \fB\%reset_color_pairs\fP tells \fI\%ncurses\fP to discard
464 all of the color pair information which was set with \fB\%init_pair\fP.
465 It also touches the current- and standard-screens, allowing an application to
466 switch color palettes rapidly.
467 .SS COLOR_PAIR
468 \fB\%COLOR_PAIR(\fIn\fB)\fR converts a color pair number to an
469 attribute.
470 Attributes can hold color pairs in the range 0 to 255.
471 If you need a color pair larger than that,
472 you must use functions such as \fB\%attr_set\fP
473 (which pass the color pair as a separate parameter)
474 rather than the legacy functions such as \fB\%attrset\fP.
475 .SS PAIR_NUMBER
476 \fB\%PAIR_NUMBER(\fIattr\fR) extracts the color information from its
477 \fIattr\fP parameter and returns it as a color pair number;
478 it is the inverse operation of \fB\%COLOR_PAIR\fP.
479 .SH RETURN VALUE
480 .B \%can_change_color
481 and
482 .B \%has_colors
483 return
484 .B TRUE
485 or
486 .BR FALSE "."
487 The other functions return
488 .B OK
489 on success and
490 .B ERR
491 on failure.
492 .PP
493 In
494 .IR \%ncurses ","
495 functions returning an
496 .I int
497 recognize several error conditions.
498 .bP
499 All return
500 .B ERR
501 if the screen has not been initialized;
502 see \fBinitscr\fP(3NCURSES) or \fBnewterm\fP(3NCURSES).
503 .bP
504 All except
505 .B \%start_color
506 return
507 .B ERR
508 if
509 .B \%start_color
510 has not been called,
511 or itself returned
512 .BR ERR "."
513 .bP
514 .B \%start_color
515 returns
516 .B ERR
517 if it cannot allocate memory for its color pair table.
518 .bP
519 .B \%init_color
520 returns
521 .B ERR
522 if the terminal type does not support assignable color values;
523 that is,
524 if the
525 .B \%initialize_color
526 .RB ( initc )
527 capability is absent from its description.
528 .bP
529 .B \%init_color
530 returns
531 .B ERR
532 if any of its
533 .IR r ","
534 .IR g ","
535 .I b
536 arguments is outside the range 0-1000 inclusive.
537 .bP
538 .BR \%init_pair ","
539 .BR \%init_color ","
540 .BR \%init_extended_pair ","
541 .BR \%init_extended_color ","
542 .BR \%color_content ","
543 .BR \%pair_content ","
544 .BR \%extended_color_content ","
545 and
546 .B \%extended_pair_content
547 return
548 .B ERR
549 on attempts to use
550 .RS
551 .bP
552 color identifiers outside the range
553 .RB \%0- COLORS \-1
554 inclusive,
555 the default colors extension notwithstanding,
556 or
557 .bP
558 color pair identifiers outside the range
559 .RB \%0- COLOR_PAIRS \-1
560 inclusive.
561 .RE
562 .SH NOTES
563 In
564 .IR \%ncurses ","
565 .B \%init_pair
566 accepts negative foreground and background color arguments
567 to support its \fB\%use_default_colors\fP(3NCURSES) extension,
568 but only after the latter function has been called.
569 .PP
570 The assumption that
571 .B \%COLOR_BLACK
572 is the terminal's default background color can be overridden using
573 .IR \%ncurses 's
574 \fB\%assume_default_colors\fP(3NCURSES) extension.
575 .PP
576 In
577 .IR \%ncurses ","
578 each pointer passed to
579 .B \%color_content
580 and
581 .B \%pair_content
582 can be null,
583 in which case the library ignores it,
584 permitting the application to disregard unnecessary information.
585 .PP
586 In
587 .IR \%ncurses ","
588 each screen has a
589 color activation flag,
590 color palette,
591 color pair table,
592 and associated
593 .B \%COLORS
594 and
595 .B \%COLOR_PAIRS
596 values;
597 .B \%start_color
598 affects only the current screen.
599 The SVr4 and X/Open Curses interface was not really designed
600 with this in mind;
601 historical implementations may use a single shared color palette.
602 .PP
603 Setting an implicit background color via a color pair affects only
604 character cells that a character write operation explicitly touches.
605 To change the background color used
606 when parts of a window are blanked by erasing or scrolling operations,
607 see \fB\%bkgd\fP(3NCURSES).
608 .PP
609 Several caveats apply to IBM PC-compatible machines
610 of the 80486 era and earlier
611 with CGA/EGA/VGA video.
612 .bP
613 .B \%COLOR_YELLOW
614 is actually brown.
615 To get yellow,
616 combine
617 .B \%COLOR_YELLOW
618 with the
619 .B \%A_BOLD
620 attribute.
621 .bP
622 The
623 .B \%A_BLINK
624 attribute should in theory make the background bright.
625 This often fails to work,
626 and even VGA controllers for which it mostly works,
627 such as those from Paradise and compatibles,
628 do the wrong thing
629 when you try to set a bright \*(``yellow\*('' background \(em
630 you get a blinking yellow foreground instead.
631 .bP
632 Color RGB values are not configurable on these devices
633 (in text mode).
634 .SH EXTENSIONS
635 The functions marked as extensions originated in
636 .IR \%ncurses ","
637 and are not found in SVr4
638 .IR curses ,
639 4.4BSD
640 .IR curses ,
641 or any other previous
642 .I curses
643 implementation.
644 .SH PORTABILITY
645 Applications employing
646 .I \%ncurses
647 extensions should condition their use on the visibility of the
648 .B \%NCURSES_VERSION
649 preprocessor macro.
650 .PP
651 X/Open Curses Issue\ 4 describes these functions.
652 It specifies no error conditions for them.
653 .PP
654 .I \%ncurses
655 satisfies X/Open Curses's minimum maximums for
656 .I \%COLORS
657 and
658 .IR \%COLOR_PAIRS "."
659 .PP
660 X/Open Curses does not specify a limit for the number of colors and
661 color pairs which a terminal can support.
662 However,
663 in its use of
664 .I short
665 for the parameters,
666 it carries over SVr4's implementation detail for the compiled
667 .I \%term\%info
668 database,
669 which uses signed 16-bit numbers.
670 .I \%ncurses
671 provides extended versions of the functions using
672 .I short
673 parameters,
674 allowing applications to use larger color and pair identifiers.
675 .PP
676 SVr4
677 .I curses
678 returns
679 .I ERR
680 from
681 .I \%pair_content
682 if its
683 .I pair
684 argument
685 was not initialized using
686 .IR \%init_pairs ,
687 and from
688 .I \%color_content
689 if the terminal does not support changing colors.
690 .I \%ncurses
691 does neither.
692 .SH HISTORY
693 SVr3.2 (1987) introduced color support with all of the symbols in the
694 synopsis above except those marked as extensions.
695 It reserved color pair 0 as the terminal's initial,
696 \*(``uncolored\*('' state,
697 .\" "we assume that color 0 is always a default background.", SVr3.2
698 .\" usr/src/lib/libcurses/screen/start_col.c
699 and limited the number of possible color pairs to 64,
700 because the color pair datum was encoded in six bits of a
701 .IR \%chtype "."
702 .PP
703 SVr4 made only internal changes,
704 such as moving the storage of color state
705 from the
706 .I SCREEN
707 structure
708 (pointed to by
709 .IR SP )
710 to the
711 .I \%TERMINAL
712 structure
713 (pointed to by
714 .IR \%cur_term ")."
715 .PP
716 Other
717 .I curses
718 implementations impose different limits on the number of colors and
719 color pairs.
720 .bP
721 .I \%PCCurses
722 (1987-1990) provided for only 8 colors
723 (and therefore required at most 8\(mu8 = 64 color pairs).
724 .bP
725 .I \%PDCurses
726 (1992-present) inherited the 8-color limitation from
727 .IR \%PCCurses ,
728 but changed this to 256 in version 2.5 (2001),
729 and widened its
730 .I \%chtype
731 from 16 to 32 bits.
732 .bP
733 X/Open Curses (1992-present)
734 specified a new structure type,
735 .IR \%cchar_t ","
736 to store the character code,
737 attribute flags,
738 and color pair identifier,
739 allowing an increased range of color pairs.
740 It specifies a
741 .I short
742 as storing identifiers for colors and color pairs,
743 limiting portable values to 15 bits;
744 negative values are invalid in System\ V.
745 .bP
746 .I \%ncurses
747 (1992-present),
748 in its non-wide configuration,
749 uses 8 bits of
750 .I \%chtype
751 for the color pair identifier.
752 .IP
753 Version 5.3 (2002) offered a wide-character interface,
754 but encoded the color pair identifier with attributes
755 in the character type.
756 .IP
757 Since version 6 (2015),
758 .I \%ncurses
759 uses a separate
760 .I int
761 for the color pair identifier in a
762 .IR \%cchar_t ","
763 introducing extension functions to manage the wider type.
764 When a color pair value fits in 8 bits,
765 .I \%ncurses
766 permits color pair data to be manipulated
767 via the functions taking
768 .I \%chtype
769 arguments,
770 even when a
771 .I curses
772 window uses wide-character cells.
773 .bP
774 NetBSD
775 .I curses
776 used 6 bits for the color pair identifier from 2000
777 (when it first added color support)
778 until 2004.
779 At that point,
780 NetBSD widened the color pair identifier to use 9 bits.
781 As of 2025,
782 that size is unchanged.
783 .\" http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libcurses/curses.h?rev=1.133
784 .\" indicates a mask of 0x03fe0000.
785 Like
786 .I \%ncurses
787 before version 6,
788 the NetBSD color pair datum is stored in
789 the attributes field of
790 .IR \%cchar_t ","
791 limiting the number of color pairs.
792 .SH SEE ALSO
793 \fB\%ncurses\fP(3NCURSES),
794 \fB\%attr\fP(3NCURSES),
795 \fB\%initscr\fP(3NCURSES),
796 \fB\%curses_variables\fP(3NCURSES),
797 \fB\%default_colors\fP(3NCURSES)