1 /****************************************************************************
2 * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-on *
33 * and: Juergen Pfeifer 2009 *
34 ****************************************************************************/
38 * Handles color emulation of SYS V curses
41 #define NEW_PAIR_INTERNAL 1
43 #include <curses.priv.h>
48 #define CUR SP_TERMTYPE
51 MODULE_ID("$Id: lib_color.c,v 1.115 2017/03/09 00:35:14 tom Exp $")
53 #ifdef USE_TERM_DRIVER
54 #define CanChange InfoOf(SP_PARM).canchange
55 #define DefaultPalette InfoOf(SP_PARM).defaultPalette
56 #define HasColor InfoOf(SP_PARM).hascolor
57 #define InitColor InfoOf(SP_PARM).initcolor
58 #define MaxColors InfoOf(SP_PARM).maxcolors
59 #define MaxPairs InfoOf(SP_PARM).maxpairs
60 #define UseHlsPalette (DefaultPalette == _nc_hls_palette)
62 #define CanChange can_change
63 #define DefaultPalette (hue_lightness_saturation ? hls_palette : cga_palette)
64 #define HasColor has_color
65 #define InitColor initialize_color
66 #define MaxColors max_colors
67 #define MaxPairs max_pairs
68 #define UseHlsPalette (hue_lightness_saturation)
71 #ifndef USE_TERM_DRIVER
73 * These should be screen structure members. They need to be globals for
74 * historical reasons. So we assign them in start_color() and also in
75 * set_term()'s screen-switching logic.
79 NCURSES_PUBLIC_VAR(COLOR_PAIRS) (void)
81 return SP ? SP->_pair_count : -1;
84 NCURSES_PUBLIC_VAR(COLORS) (void)
86 return SP ? SP->_color_count : -1;
89 NCURSES_EXPORT_VAR(int) COLOR_PAIRS = 0;
90 NCURSES_EXPORT_VAR(int) COLORS = 0;
92 #endif /* !USE_TERM_DRIVER */
94 #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
96 #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
100 #define OkColorHi(n) (((n) < COLORS) && ((n) < maxcolors))
101 #define InPalette(n) ((n) >= 0 && (n) < MAX_PALETTE)
104 * Given a RGB range of 0..1000, we'll normally set the individual values
105 * to about 2/3 of the maximum, leaving full-range for bold/bright colors.
110 static const color_t cga_palette[] =
113 DATA(RGB_OFF, RGB_OFF, RGB_OFF), /* COLOR_BLACK */
114 DATA(RGB_ON, RGB_OFF, RGB_OFF), /* COLOR_RED */
115 DATA(RGB_OFF, RGB_ON, RGB_OFF), /* COLOR_GREEN */
116 DATA(RGB_ON, RGB_ON, RGB_OFF), /* COLOR_YELLOW */
117 DATA(RGB_OFF, RGB_OFF, RGB_ON), /* COLOR_BLUE */
118 DATA(RGB_ON, RGB_OFF, RGB_ON), /* COLOR_MAGENTA */
119 DATA(RGB_OFF, RGB_ON, RGB_ON), /* COLOR_CYAN */
120 DATA(RGB_ON, RGB_ON, RGB_ON), /* COLOR_WHITE */
123 static const color_t hls_palette[] =
126 DATA( 0, 0, 0), /* COLOR_BLACK */
127 DATA( 120, 50, 100), /* COLOR_RED */
128 DATA( 240, 50, 100), /* COLOR_GREEN */
129 DATA( 180, 50, 100), /* COLOR_YELLOW */
130 DATA( 330, 50, 100), /* COLOR_BLUE */
131 DATA( 60, 50, 100), /* COLOR_MAGENTA */
132 DATA( 300, 50, 100), /* COLOR_CYAN */
133 DATA( 0, 50, 100), /* COLOR_WHITE */
136 #ifdef USE_TERM_DRIVER
137 NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette = cga_palette;
138 NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette;
143 #if NCURSES_EXT_FUNCS
145 * These are called from _nc_do_color(), which in turn is called from
146 * vidattr - so we have to assume that sp may be null.
149 default_fg(NCURSES_SP_DCL0)
151 return (SP_PARM != 0) ? SP_PARM->_default_fg : COLOR_WHITE;
155 default_bg(NCURSES_SP_DCL0)
157 return SP_PARM != 0 ? SP_PARM->_default_bg : COLOR_BLACK;
160 #define default_fg(sp) COLOR_WHITE
161 #define default_bg(sp) COLOR_BLACK
164 #ifndef USE_TERM_DRIVER
166 * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
167 * to maintain compatibility with a pre-ANSI scheme. The same scheme is
168 * also used in the FreeBSD syscons.
171 toggled_colors(int c)
174 static const int table[] =
175 {0, 4, 2, 6, 1, 5, 3, 7,
176 8, 12, 10, 14, 9, 13, 11, 15};
184 set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)
186 #ifdef USE_TERM_DRIVER
187 CallDriver_3(SP_PARM, td_color, FALSE, bg, outc);
189 if (set_a_background) {
190 TPUTS_TRACE("set_a_background");
191 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
192 TPARM_1(set_a_background, bg),
195 TPUTS_TRACE("set_background");
196 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
197 TPARM_1(set_background, toggled_colors(bg)),
204 set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc)
206 #ifdef USE_TERM_DRIVER
207 CallDriver_3(SP_PARM, td_color, TRUE, fg, outc);
209 if (set_a_foreground) {
210 TPUTS_TRACE("set_a_foreground");
211 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
212 TPARM_1(set_a_foreground, fg),
215 TPUTS_TRACE("set_foreground");
216 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
217 TPARM_1(set_foreground, toggled_colors(fg)),
224 init_color_table(NCURSES_SP_DCL0)
226 const color_t *tp = DefaultPalette;
231 for (n = 0; n < COLORS; n++) {
233 SP_PARM->_color_table[n] = tp[n];
235 SP_PARM->_color_table[n] = tp[n % MAX_PALETTE];
237 SP_PARM->_color_table[n].green = 100;
239 if (SP_PARM->_color_table[n].red)
240 SP_PARM->_color_table[n].red = 1000;
241 if (SP_PARM->_color_table[n].green)
242 SP_PARM->_color_table[n].green = 1000;
243 if (SP_PARM->_color_table[n].blue)
244 SP_PARM->_color_table[n].blue = 1000;
251 * Reset the color pair, e.g., to whatever color pair 0 is.
254 reset_color_pair(NCURSES_SP_DCL0)
256 #ifdef USE_TERM_DRIVER
257 return CallDriver(SP_PARM, td_rescol);
262 if (orig_pair != 0) {
263 (void) NCURSES_PUTP2("orig_pair", orig_pair);
271 * Reset color pairs and definitions. Actually we do both more to accommodate
272 * badly-written terminal descriptions than for the relatively rare case where
273 * someone has changed the color definitions.
276 NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0)
280 T((T_CALLED("_nc_reset_colors(%p)"), (void *) SP_PARM));
281 if (SP_PARM->_color_defs > 0)
282 SP_PARM->_color_defs = -(SP_PARM->_color_defs);
283 if (reset_color_pair(NCURSES_SP_ARG))
286 #ifdef USE_TERM_DRIVER
287 result = CallDriver(SP_PARM, td_rescolors);
289 if (orig_colors != 0) {
290 NCURSES_PUTP2("orig_colors", orig_colors);
299 _nc_reset_colors(void)
301 return NCURSES_SP_NAME(_nc_reset_colors) (CURRENT_SCREEN);
306 NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
309 int maxpairs = 0, maxcolors = 0;
311 T((T_CALLED("start_color(%p)"), (void *) SP_PARM));
315 } else if (SP_PARM->_coloron) {
319 maxcolors = MaxColors;
320 if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
321 set_foreground_color(NCURSES_SP_ARGx
322 default_fg(NCURSES_SP_ARG),
323 NCURSES_SP_NAME(_nc_outch));
324 set_background_color(NCURSES_SP_ARGx
325 default_bg(NCURSES_SP_ARG),
326 NCURSES_SP_NAME(_nc_outch));
328 #if !NCURSES_EXT_COLORS
330 * Without ext-colors, we cannot represent more than 256 color pairs.
336 if (maxpairs > 0 && maxcolors > 0) {
337 SP_PARM->_pair_limit = maxpairs;
339 #if NCURSES_EXT_FUNCS
341 * If using default colors, allocate extra space in table to
342 * allow for default-color as a component of a color-pair.
344 SP_PARM->_pair_limit += (1 + (2 * maxcolors));
345 if ((NCURSES_PAIRS_T) SP_PARM->_pair_limit < 0)
346 SP_PARM->_pair_limit = MAX_XCURSES_PAIR;
348 SP_PARM->_pair_count = maxpairs;
349 SP_PARM->_color_count = maxcolors;
351 COLOR_PAIRS = maxpairs;
355 SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, SP_PARM->_pair_limit);
356 if (SP_PARM->_color_pairs != 0) {
357 SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
358 if (SP_PARM->_color_table != 0) {
359 MakeColorPair(SP_PARM->_color_pairs[0],
360 default_fg(NCURSES_SP_ARG),
361 default_bg(NCURSES_SP_ARG));
362 init_color_table(NCURSES_SP_ARG);
364 T(("started color: COLORS = %d, COLOR_PAIRS = %d",
365 COLORS, COLOR_PAIRS));
367 SP_PARM->_coloron = 1;
369 } else if (SP_PARM->_color_pairs != 0) {
370 FreeAndNull(SP_PARM->_color_pairs);
384 return NCURSES_SP_NAME(start_color) (CURRENT_SCREEN);
388 /* This function was originally written by Daniel Weaver <danw@znyx.com> */
390 rgb2hls(int r, int g, int b, NCURSES_COLOR_T *h, NCURSES_COLOR_T *l, NCURSES_COLOR_T *s)
391 /* convert RGB to HLS system */
395 if ((min = g < r ? g : r) > b)
397 if ((max = g > r ? g : r) < b)
400 /* calculate lightness */
401 *l = (NCURSES_COLOR_T) ((min + max) / 20);
403 if (min == max) { /* black, white and all shades of gray */
409 /* calculate saturation */
411 *s = (NCURSES_COLOR_T) (((max - min) * 100) / (max + min));
413 *s = (NCURSES_COLOR_T) (((max - min) * 100) / (2000 - max - min));
417 t = (NCURSES_COLOR_T) (120 + ((g - b) * 60) / (max - min));
419 t = (NCURSES_COLOR_T) (240 + ((b - r) * 60) / (max - min));
421 t = (NCURSES_COLOR_T) (360 + ((r - g) * 60) / (max - min));
423 *h = (NCURSES_COLOR_T) (t % 360);
427 * Change all cells which use(d) a given color pair to force a repaint.
430 _nc_change_pair(SCREEN *sp, int pair)
434 for (y = 0; y <= CurScreen(sp)->_maxy; y++) {
435 struct ldat *ptr = &(CurScreen(sp)->_line[y]);
436 bool changed = FALSE;
437 for (x = 0; x <= CurScreen(sp)->_maxx; x++) {
438 if (GetPair(ptr->text[x]) == pair) {
439 /* Set the old cell to zero to ensure it will be
440 updated on the next doupdate() */
441 SetChar(ptr->text[x], 0, 0);
442 CHANGED_CELL(ptr, x);
447 NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y);
452 * Extension (1997/1/18) - Allow negative f/b values to set default color
456 NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx
457 NCURSES_PAIRS_T pair,
461 static colorpair_t null_pair;
462 colorpair_t result = null_pair;
463 colorpair_t previous;
466 T((T_CALLED("init_pair(%p,%d,%d,%d)"),
472 if (!ValidPair(SP_PARM, pair))
475 maxcolors = MaxColors;
477 previous = SP_PARM->_color_pairs[pair];
478 #if NCURSES_EXT_FUNCS
479 if (SP_PARM->_default_color || SP_PARM->_assumed_color) {
480 bool isDefault = FALSE;
481 bool wasDefault = FALSE;
482 int default_pairs = SP_PARM->_default_pairs;
485 * Map caller's color number, e.g., -1, 0, 1, .., 7, etc., into
486 * internal unsigned values which we will store in the _color_pairs[]
489 if (isDefaultColor(f)) {
492 } else if (!OkColorHi(f)) {
496 if (isDefaultColor(b)) {
499 } else if (!OkColorHi(b)) {
504 * Check if the table entry that we are going to init/update used
507 if (isDefaultColor(FORE_OF(previous))
508 || isDefaultColor(BACK_OF(previous)))
512 * Keep track of the number of entries in the color pair table which
513 * used a default color.
515 if (isDefault && !wasDefault) {
517 } else if (wasDefault && !isDefault) {
522 * As an extension, ncurses allows the pair number to exceed the
523 * terminal's color_pairs value for pairs using a default color.
525 * Note that updating a pair which used a default color with one
526 * that does not will decrement the count - and possibly interfere
527 * with sequentially adding new pairs.
529 if (pair > (SP_PARM->_pair_count + default_pairs)) {
532 SP_PARM->_default_pairs = default_pairs;
536 if ((f < 0) || !OkColorHi(f)
537 || (b < 0) || !OkColorHi(b)
544 * When a pair's content is changed, replace its colors (if pair was
545 * initialized before a screen update is performed replacing original
546 * pair colors with the new ones).
548 MakeColorPair(result, f, b);
549 if (FORE_OF(previous) != 0
550 && BACK_OF(previous) != 0
551 && !isSamePair(previous, result)) {
552 _nc_change_pair(SP_PARM, pair);
555 _nc_reset_color_pair(SP_PARM, pair, &result);
556 SP_PARM->_color_pairs[pair] = result;
557 _nc_set_color_pair(SP_PARM, pair, cpINIT);
559 if (GET_SCREEN_PAIR(SP_PARM) == pair)
560 SET_SCREEN_PAIR(SP_PARM, (int) (~0)); /* force attribute update */
562 #ifdef USE_TERM_DRIVER
563 CallDriver_3(SP_PARM, td_initpair, pair, f, b);
565 if (initialize_pair && InPalette(f) && InPalette(b)) {
566 const color_t *tp = DefaultPalette;
569 ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
571 (int) tp[f].red, (int) tp[f].green, (int) tp[f].blue,
572 (int) tp[b].red, (int) tp[b].green, (int) tp[b].blue));
574 NCURSES_PUTP2("initialize_pair",
575 TPARM_7(initialize_pair,
591 init_pair(NCURSES_COLOR_T pair, NCURSES_COLOR_T f, NCURSES_COLOR_T b)
593 return NCURSES_SP_NAME(init_pair) (CURRENT_SCREEN, pair, f, b);
597 #define okRGB(n) ((n) >= 0 && (n) <= 1000)
600 NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx
601 NCURSES_COLOR_T color,
609 T((T_CALLED("init_color(%p,%d,%d,%d,%d)"),
617 maxcolors = MaxColors;
621 && (color >= 0 && OkColorHi(color))
622 && (okRGB(r) && okRGB(g) && okRGB(b))) {
624 SP_PARM->_color_table[color].init = 1;
625 SP_PARM->_color_table[color].r = r;
626 SP_PARM->_color_table[color].g = g;
627 SP_PARM->_color_table[color].b = b;
631 &SP_PARM->_color_table[color].red,
632 &SP_PARM->_color_table[color].green,
633 &SP_PARM->_color_table[color].blue);
635 SP_PARM->_color_table[color].red = r;
636 SP_PARM->_color_table[color].green = g;
637 SP_PARM->_color_table[color].blue = b;
640 #ifdef USE_TERM_DRIVER
641 CallDriver_4(SP_PARM, td_initcolor, color, r, g, b);
643 NCURSES_PUTP2("initialize_color",
644 TPARM_4(initialize_color, color, r, g, b));
646 SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs);
655 init_color(NCURSES_COLOR_T color,
660 return NCURSES_SP_NAME(init_color) (CURRENT_SCREEN, color, r, g, b);
665 NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL)
669 T((T_CALLED("can_change_color(%p)"), (void *) SP_PARM));
671 if (HasTerminal(SP_PARM) && (CanChange != 0)) {
680 can_change_color(void)
682 return NCURSES_SP_NAME(can_change_color) (CURRENT_SCREEN);
687 NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0)
692 T((T_CALLED("has_colors()")));
693 if (HasTerminal(SP_PARM)) {
694 #ifdef USE_TERM_DRIVER
697 code = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs)
698 && (((set_foreground != NULL)
699 && (set_background != NULL))
700 || ((set_a_foreground != NULL)
701 && (set_a_background != NULL))
702 || set_color_pair)) ? TRUE : FALSE);
712 return NCURSES_SP_NAME(has_colors) (CURRENT_SCREEN);
717 NCURSES_SP_NAME(color_content) (NCURSES_SP_DCLx
718 NCURSES_COLOR_T color,
726 T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
736 maxcolors = MaxColors;
738 if (color < 0 || !OkColorHi(color) || !SP_PARM->_coloron) {
741 NCURSES_COLOR_T c_r = SP_PARM->_color_table[color].red;
742 NCURSES_COLOR_T c_g = SP_PARM->_color_table[color].green;
743 NCURSES_COLOR_T c_b = SP_PARM->_color_table[color].blue;
752 TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
753 color, c_r, c_g, c_b));
761 color_content(NCURSES_COLOR_T color,
766 return NCURSES_SP_NAME(color_content) (CURRENT_SCREEN, color, r, g, b);
771 NCURSES_SP_NAME(pair_content) (NCURSES_SP_DCLx
772 NCURSES_PAIRS_T pair,
778 T((T_CALLED("pair_content(%p,%d,%p,%p)"),
784 if (!ValidPair(SP_PARM, pair)) {
787 NCURSES_COLOR_T fg = (NCURSES_COLOR_T) FORE_OF(SP_PARM->_color_pairs[pair]);
788 NCURSES_COLOR_T bg = (NCURSES_COLOR_T) BACK_OF(SP_PARM->_color_pairs[pair]);
790 #if NCURSES_EXT_FUNCS
791 if (isDefaultColor(fg))
793 if (isDefaultColor(bg))
802 TR(TRACE_ATTRS, ("...pair_content(%p,%d,%d,%d)",
805 (int) fg, (int) bg));
813 pair_content(NCURSES_COLOR_T pair, NCURSES_COLOR_T *f, NCURSES_COLOR_T *b)
815 return NCURSES_SP_NAME(pair_content) (CURRENT_SCREEN, pair, f, b);
820 NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
824 NCURSES_SP_OUTC outc)
826 #ifdef USE_TERM_DRIVER
827 CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc);
829 NCURSES_COLOR_T fg = COLOR_DEFAULT;
830 NCURSES_COLOR_T bg = COLOR_DEFAULT;
831 NCURSES_COLOR_T old_fg = -1;
832 NCURSES_COLOR_T old_bg = -1;
834 if (!ValidPair(SP_PARM, pair)) {
836 } else if (pair != 0) {
837 if (set_color_pair) {
838 TPUTS_TRACE("set_color_pair");
839 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
840 TPARM_1(set_color_pair, pair),
843 } else if (SP_PARM != 0) {
844 if (pair_content((NCURSES_COLOR_T) pair, &fg, &bg) == ERR)
851 && pair_content((NCURSES_COLOR_T) old_pair, &old_fg, &old_bg) != ERR) {
852 if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
853 || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
854 #if NCURSES_EXT_FUNCS
856 * A minor optimization - but extension. If "AX" is specified in
857 * the terminal description, treat it as screen's indicator of ECMA
858 * SGR 39 and SGR 49, and assume the two sequences are independent.
860 if (SP_PARM->_has_sgr_39_49
861 && isDefaultColor(old_bg)
862 && !isDefaultColor(old_fg)) {
863 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc);
864 } else if (SP_PARM->_has_sgr_39_49
865 && isDefaultColor(old_fg)
866 && !isDefaultColor(old_bg)) {
867 NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc);
870 reset_color_pair(NCURSES_SP_ARG);
873 reset_color_pair(NCURSES_SP_ARG);
874 if (old_pair < 0 && pair <= 0)
878 #if NCURSES_EXT_FUNCS
879 if (isDefaultColor(fg))
880 fg = (NCURSES_COLOR_T) default_fg(NCURSES_SP_ARG);
881 if (isDefaultColor(bg))
882 bg = (NCURSES_COLOR_T) default_bg(NCURSES_SP_ARG);
886 NCURSES_COLOR_T xx = fg;
891 TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
894 if (!isDefaultColor(fg)) {
895 set_foreground_color(NCURSES_SP_ARGx fg, outc);
897 if (!isDefaultColor(bg)) {
898 set_background_color(NCURSES_SP_ARGx bg, outc);
905 _nc_do_color(int old_pair, int pair, int reverse, NCURSES_OUTC outc)
907 SetSafeOutcWrapper(outc);
908 NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN,