- * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
/* find the number of bits needed for the maximum color value */
for (width = 0; (1 << width) - 1 < (COLORS - 1); ++width) {
;
}
/* find the number of bits needed for the maximum color value */
for (width = 0; (1 << width) - 1 < (COLORS - 1); ++width) {
;
}
if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
set_foreground_color(NCURSES_SP_ARGx
default_fg(NCURSES_SP_ARG),
if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
set_foreground_color(NCURSES_SP_ARGx
default_fg(NCURSES_SP_ARG),
* allow for default-color as a component of a color-pair.
*/
SP_PARM->_pair_limit += (1 + (2 * maxcolors));
* allow for default-color as a component of a color-pair.
*/
SP_PARM->_pair_limit += (1 + (2 * maxcolors));
- if ((sp->_color_pairs != 0) && (want < sp->_pair_alloc)) {
- result = &(sp->_color_pairs[want]);
- } else {
-
- if (have == 0)
- have = 1;
- while (have <= want)
- have *= 2;
- if (have > sp->_pair_limit)
- have = sp->_pair_limit;
+ if (have == 0)
+ have = 1;
+ while (have <= want)
+ have *= 2;
+ if (have > sp->_pair_limit)
+ have = sp->_pair_limit;
- if (sp->_color_pairs == 0) {
- sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
- } else if (have > sp->_pair_alloc) {
+ if (sp->_color_pairs == 0) {
+ sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
+ } else if (have > sp->_pair_alloc) {
- colorpair_t *next;
-
- if ((next = typeCalloc(colorpair_t, have)) == 0)
- _nc_err_abort(MSG_NO_MEMORY);
- memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
- _nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
- free(sp->_color_pairs);
- sp->_color_pairs = next;
+ colorpair_t *next;
+
+ if ((next = typeCalloc(colorpair_t, have)) == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
+ _nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
+ free(sp->_color_pairs);
+ sp->_color_pairs = next;
- TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
- if (sp->_color_pairs != 0) {
- memset(sp->_color_pairs + sp->_pair_alloc, 0,
- sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
- }
-#endif
- }
+ TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
- sp->_pair_alloc = have;
- result = &(sp->_color_pairs[want]);
+ memset(sp->_color_pairs + sp->_pair_alloc, 0,
+ sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
(int) tp[b].red, (int) tp[b].green, (int) tp[b].blue));
NCURSES_PUTP2("initialize_pair",
(int) tp[b].red, (int) tp[b].green, (int) tp[b].blue));
NCURSES_PUTP2("initialize_pair",
CallDriver_4(sp, td_initcolor, color, r, g, b);
#else
NCURSES_PUTP2("initialize_color",
CallDriver_4(sp, td_initcolor, color, r, g, b);
#else
NCURSES_PUTP2("initialize_color",
- TPARM_4(initialize_color, color, r, g, b));
+ TIPARM_4(initialize_color, color, r, g, b));
#define max_direct_color(name) ((1 << work->bits.name) - 1)
#define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max
#define max_direct_color(name) ((1 << work->bits.name) - 1)
#define value_direct_color(max) (1000 * ((color >> bitoff) & max)) / max
- int max_r = max_direct_color(red);
- int max_g = max_direct_color(green);
- int max_b = max_direct_color(blue);
+ int max_r = max_direct_color(red);
+ int max_g = max_direct_color(green);
+ int max_b = max_direct_color(blue);
- } else {
- c_r = sp->_color_table[color].red;
- c_g = sp->_color_table[color].green;
- c_b = sp->_color_table[color].blue;
- }
+ } else {
+ c_r = sp->_color_table[color].red;
+ c_g = sp->_color_table[color].green;
+ c_b = sp->_color_table[color].blue;
+ }
+
+ if (r)
+ *r = c_r;
+ if (g)
+ *g = c_g;
+ if (b)
+ *b = c_b;
+ TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
+ color, c_r, c_g, c_b));
+ result = OK;
+ }
+ }
+ if (result != OK) {
- *b = c_b;
-
- TR(TRACE_ATTRS, ("...color_content(%d,%d,%d,%d)",
- color, c_r, c_g, c_b));
- result = OK;
free(SP_PARM->_color_pairs);
SP_PARM->_color_pairs = 0;
SP_PARM->_pair_alloc = 0;
free(SP_PARM->_color_pairs);
SP_PARM->_color_pairs = 0;
SP_PARM->_pair_alloc = 0;
clearok(CurScreen(SP_PARM), TRUE);
touchwin(StdScreen(SP_PARM));
}
clearok(CurScreen(SP_PARM), TRUE);
touchwin(StdScreen(SP_PARM));
}