static NCURSES_INLINE NCURSES_CH_T render_char(WINDOW *win, NCURSES_CH_T ch) /* compute a rendition of the given char correct for the current context */ { attr_t a = WINDOW_ATTRS(win); int pair = GetPair(ch); if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL && pair == 0) { /* color/pair in attrs has precedence over bkgrnd */ ch = win->_nc_bkgd; SetAttr(ch, a | AttrOf(win->_nc_bkgd)); if ((pair = GET_WINDOW_PAIR(win)) == 0) pair = GetPair(win->_nc_bkgd); SetPair(ch, pair); } else { /* color in attrs has precedence over bkgrnd */ a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a); /* color in ch has precedence */ if (pair == 0) { if ((pair = GET_WINDOW_PAIR(win)) == 0) pair = GetPair(win->_nc_bkgd); } #if 0 if (pair > 255) { NCURSES_CH_T fixme = ch; SetPair(fixme, pair); } #endif AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); SetPair(ch, pair); } TR(TRACE_VIRTPUT, ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)", _tracech_t2(1, CHREF(win->_nc_bkgd)), GetPair(win->_nc_bkgd), _traceattr(WINDOW_ATTRS(win)), GET_WINDOW_PAIR(win), _tracech_t2(3, CHREF(ch)), GetPair(ch))); return (ch); }
static NCURSES_INLINE void #endif wbkgrndset(WINDOW *win, const ARG_CH_T ch) { T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracech_t(ch))); if (win) { attr_t off = AttrOf(win->_nc_bkgd); attr_t on = AttrOf(CHDEREF(ch)); toggle_attr_off(WINDOW_ATTRS(win), off); toggle_attr_on(WINDOW_ATTRS(win), on); #if NCURSES_EXT_COLORS { int pair; if ((pair = GetPair(win->_nc_bkgd)) != 0) SET_WINDOW_PAIR(win, 0); if ((pair = GetPair(CHDEREF(ch))) != 0) SET_WINDOW_PAIR(win, pair); } #endif if (CharOf(CHDEREF(ch)) == L('\0')) { SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch))); if_EXT_COLORS(SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)))); } else { win->_nc_bkgd = CHDEREF(ch); } #if USE_WIDEC_SUPPORT /* * If we're compiled for wide-character support, _bkgrnd is the * preferred location for the background information since it stores * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the * macro getbkgd() will work. */ { cchar_t wch; int tmp; (void) wgetbkgrnd(win, &wch); tmp = _nc_to_char((wint_t) CharOf(wch)); win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp) | (AttrOf(wch) & ALL_BUT_COLOR) | ColorPair(GET_WINDOW_PAIR(win))); } #endif } returnVoid; }
wcolor_set(WINDOW *win, short color_pair_number, void *opts) { T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number)); if (win && !opts && (color_pair_number >= 0) && (color_pair_number < COLOR_PAIRS)) { TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win))); SET_WINDOW_PAIR(win, color_pair_number); if_EXT_COLORS(win->_color = color_pair_number); returnCode(OK); } else returnCode(ERR); }
wcolor_set(WINDOW *win, short color_pair_number, void *opts) { int code = ERR; T((T_CALLED("wcolor_set(%p,%d)"), (void *) win, color_pair_number)); if (win && !opts && (SP != 0) && (color_pair_number >= 0) && (color_pair_number < SP->_pair_limit)) { TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win))); SET_WINDOW_PAIR(win, color_pair_number); if_EXT_COLORS(win->_color = color_pair_number); code = OK; } returnCode(code); }