NCURSES_SP_NAME(mvcur) (SCREEN *sp, int yold, int xold, int ynew, int xnew) { int code = ERR; TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%p,%d,%d,%d,%d)"), (void *) sp, yold, xold, ynew, xnew)); if (HasTerminal(sp)) { code = CallDriver_4(sp, hwcur, yold, xold, ynew, xnew); } returnCode(code); }
NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx NCURSES_COLOR_T color, NCURSES_COLOR_T r, NCURSES_COLOR_T g, NCURSES_COLOR_T b) { int result = ERR; int maxcolors; T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), (void *) SP_PARM, color, r, g, b)); if (SP_PARM == 0) returnCode(result); maxcolors = MaxColors; if (InitColor && SP_PARM->_coloron && (color >= 0 && OkColorHi(color)) && (okRGB(r) && okRGB(g) && okRGB(b))) { SP_PARM->_color_table[color].init = 1; SP_PARM->_color_table[color].r = r; SP_PARM->_color_table[color].g = g; SP_PARM->_color_table[color].b = b; if (UseHlsPalette) { rgb2hls(r, g, b, &SP_PARM->_color_table[color].red, &SP_PARM->_color_table[color].green, &SP_PARM->_color_table[color].blue); } else { SP_PARM->_color_table[color].red = r; SP_PARM->_color_table[color].green = g; SP_PARM->_color_table[color].blue = b; } #ifdef USE_TERM_DRIVER CallDriver_4(SP_PARM, td_initcolor, color, r, g, b); #else NCURSES_PUTP2("initialize_color", TPARM_4(initialize_color, color, r, g, b)); #endif SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs); result = OK; } returnCode(result); }
NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx int old_pair, int pair, int reverse, NCURSES_SP_OUTC outc) { #ifdef USE_TERM_DRIVER CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc); #else NCURSES_COLOR_T fg = COLOR_DEFAULT; NCURSES_COLOR_T bg = COLOR_DEFAULT; NCURSES_COLOR_T old_fg = -1; NCURSES_COLOR_T old_bg = -1; if (!ValidPair(pair)) { return; } else if (pair != 0) { if (set_color_pair) { TPUTS_TRACE("set_color_pair"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx TPARM_1(set_color_pair, pair), 1, outc); return; } else if (SP_PARM != 0) { if (pair_content((NCURSES_COLOR_T) pair, &fg, &bg) == ERR) return; } } if (old_pair >= 0 && SP_PARM != 0 && pair_content((NCURSES_COLOR_T) old_pair, &old_fg, &old_bg) != ERR) { if ((isDefaultColor(fg) && !isDefaultColor(old_fg)) || (isDefaultColor(bg) && !isDefaultColor(old_bg))) { #if NCURSES_EXT_FUNCS /* * A minor optimization - but extension. If "AX" is specified in * 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_PARM->_has_sgr_39_49 && isDefaultColor(old_bg) && !isDefaultColor(old_fg)) { 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)) { NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc); } else #endif reset_color_pair(NCURSES_SP_ARG); } } else { reset_color_pair(NCURSES_SP_ARG); } #if NCURSES_EXT_FUNCS if (isDefaultColor(fg)) fg = (NCURSES_COLOR_T) default_fg(NCURSES_SP_ARG); if (isDefaultColor(bg)) bg = (NCURSES_COLOR_T) default_bg(NCURSES_SP_ARG); #endif if (reverse) { NCURSES_COLOR_T xx = fg; fg = bg; bg = xx; } TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg)); if (!isDefaultColor(fg)) { set_foreground_color(NCURSES_SP_ARGx fg, outc); } if (!isDefaultColor(bg)) { set_background_color(NCURSES_SP_ARGx bg, outc); } #endif }