#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.88 2009/02/15 00:33:02 tom Exp $")
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+MODULE_ID("$Id: lib_color.c,v 1.92 2009/06/06 20:26:16 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
}
static void
-set_background_color(int bg, int (*outc) (int))
+set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)
{
if (set_a_background) {
TPUTS_TRACE("set_a_background");
- tputs(TPARM_1(set_a_background, bg), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_1(set_a_background, bg),
+ 1, outc);
} else {
TPUTS_TRACE("set_background");
- tputs(TPARM_1(set_background, toggled_colors(bg)), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_1(set_background, toggled_colors(bg)),
+ 1, outc);
}
}
static void
-set_foreground_color(int fg, int (*outc) (int))
+set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc)
{
if (set_a_foreground) {
TPUTS_TRACE("set_a_foreground");
- tputs(TPARM_1(set_a_foreground, fg), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_1(set_a_foreground, fg),
+ 1, outc);
} else {
TPUTS_TRACE("set_foreground");
- tputs(TPARM_1(set_foreground, toggled_colors(fg)), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_1(set_foreground, toggled_colors(fg)),
+ 1, outc);
}
}
static void
-init_color_table(void)
+init_color_table(NCURSES_SP_DCL0)
{
const color_t *tp;
int n;
tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
for (n = 0; n < COLORS; n++) {
if (InPalette(n)) {
- SP->_color_table[n] = tp[n];
+ SP_PARM->_color_table[n] = tp[n];
} else {
- SP->_color_table[n] = tp[n % MAX_PALETTE];
+ SP_PARM->_color_table[n] = tp[n % MAX_PALETTE];
if (hue_lightness_saturation) {
- SP->_color_table[n].green = 100;
+ SP_PARM->_color_table[n].green = 100;
} else {
- if (SP->_color_table[n].red)
- SP->_color_table[n].red = 1000;
- if (SP->_color_table[n].green)
- SP->_color_table[n].green = 1000;
- if (SP->_color_table[n].blue)
- SP->_color_table[n].blue = 1000;
+ if (SP_PARM->_color_table[n].red)
+ SP_PARM->_color_table[n].red = 1000;
+ if (SP_PARM->_color_table[n].green)
+ SP_PARM->_color_table[n].green = 1000;
+ if (SP_PARM->_color_table[n].blue)
+ SP_PARM->_color_table[n].blue = 1000;
}
}
}
* Reset the color pair, e.g., to whatever color pair 0 is.
*/
static bool
-reset_color_pair(void)
+reset_color_pair(NCURSES_SP_DCL0)
{
bool result = FALSE;
* someone has changed the color definitions.
*/
bool
-_nc_reset_colors(void)
-{
+NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) {
int result = FALSE;
T((T_CALLED("_nc_reset_colors()")));
- if (SP->_color_defs > 0)
- SP->_color_defs = -(SP->_color_defs);
+ if (SP_PARM->_color_defs > 0)
+ SP_PARM->_color_defs = -(SP_PARM->_color_defs);
- if (reset_color_pair())
+ if (reset_color_pair(NCURSES_SP_ARG))
result = TRUE;
if (orig_colors != 0) {
TPUTS_TRACE("orig_colors");
returnBool(result);
}
+#if NCURSES_SP_FUNCS
+bool
+_nc_reset_colors(void)
+{
+ return NCURSES_SP_NAME(_nc_reset_colors) (CURRENT_SCREEN);
+}
+#endif
+
NCURSES_EXPORT(int)
NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
{
result = OK;
} else {
- if (reset_color_pair() != TRUE) {
- set_foreground_color(default_fg(), _nc_outch);
- set_background_color(default_bg(), _nc_outch);
+ if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
+ set_foreground_color(NCURSES_SP_ARGx
+ default_fg(),
+ NCURSES_SP_NAME(_nc_outch));
+ set_background_color(NCURSES_SP_ARGx
+ default_bg(),
+ NCURSES_SP_NAME(_nc_outch));
}
if (max_pairs > 0 && max_colors > 0) {
if (SP_PARM->_color_table != 0) {
SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(),
default_bg());
- init_color_table();
+ init_color_table(NCURSES_SP_ARG);
T(("started color: COLORS = %d, COLOR_PAIRS = %d",
COLORS, COLOR_PAIRS));
#endif
NCURSES_EXPORT(void)
-_nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int))
+NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
+ short old_pair,
+ short pair,
+ bool reverse,
+ NCURSES_SP_OUTC outc)
{
NCURSES_COLOR_T fg = COLOR_DEFAULT;
NCURSES_COLOR_T bg = COLOR_DEFAULT;
} else if (pair != 0) {
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
- tputs(TPARM_1(set_color_pair, pair), 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
+ TPARM_1(set_color_pair, pair),
+ 1, outc);
return;
- } else if (SP != 0) {
+ } else if (SP_PARM != 0) {
pair_content((short) pair, &fg, &bg);
}
}
if (old_pair >= 0
- && SP != 0
+ && SP_PARM != 0
&& pair_content(old_pair, &old_fg, &old_bg) != ERR) {
if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
|| (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
* the terminal description, treat it as screen's indicator of ECMA
* SGR 39 and SGR 49, and assume the two sequences are independent.
*/
- if (SP->_has_sgr_39_49
+ if (SP_PARM->_has_sgr_39_49
&& isDefaultColor(old_bg)
&& !isDefaultColor(old_fg)) {
- tputs("\033[39m", 1, outc);
- } else if (SP->_has_sgr_39_49
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc);
+ } else if (SP_PARM->_has_sgr_39_49
&& isDefaultColor(old_fg)
&& !isDefaultColor(old_bg)) {
- tputs("\033[49m", 1, outc);
+ NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc);
} else
#endif
- reset_color_pair();
+ reset_color_pair(NCURSES_SP_ARG);
}
} else {
- reset_color_pair();
+ reset_color_pair(NCURSES_SP_ARG);
if (old_pair < 0)
return;
}
fg, bg));
if (!isDefaultColor(fg)) {
- set_foreground_color(fg, outc);
+ set_foreground_color(NCURSES_SP_ARGx fg, outc);
}
if (!isDefaultColor(bg)) {
- set_background_color(bg, outc);
+ set_background_color(NCURSES_SP_ARGx bg, outc);
}
}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(void)
+_nc_do_color(short old_pair, short pair, bool reverse, NCURSES_OUTC outc)
+{
+ SetSafeOutcWrapper(outc);
+ NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN,
+ old_pair,
+ pair,
+ reverse,
+ _nc_outc_wrapper);
+}
+#endif