int wattr_off(WINDOW *win, const attr_t at) { T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at))); if (win) { T(("... current %s", _traceattr(win->_attrs))); toggle_attr_off(win->_attrs,at); returnCode(OK); } else returnCode(ERR); }
int waddnstr(WINDOW *win, const char *const astr, int n) { unsigned const char *str = (unsigned const char *)astr; int code = ERR; T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n)); if (win && (str != 0)) { T(("... current %s", _traceattr(win->_attrs))); TR(TRACE_VIRTPUT, ("str is not null")); code = OK; if (n < 0) n = (int)strlen(astr); while((n-- > 0) && (*str != '\0')) { TR(TRACE_VIRTPUT, ("*str = %#x", *str)); if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); returnCode(code); }
NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx const attr_t attr, NCURSES_PAIRS_T pair_arg, void *opts) { int code = ERR; int color_pair = pair_arg; T((T_CALLED("slk_attr_set(%p,%s,%d)"), (void *) SP_PARM, _traceattr(attr), color_pair)); set_extended_pair(opts, color_pair); if (SP_PARM != 0 && SP_PARM->_slk != 0 && color_pair >= 0 && color_pair < SP_PARM->_pair_limit) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); SetAttr(SP_PARM->_slk->attr, attr); if (color_pair > 0) { SetPair(SP_PARM->_slk->attr, color_pair); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); code = OK; } returnCode(code); }
static inline int waddch_literal(WINDOW *win, chtype ch) { int x; struct ldat *line; x = win->_curx; CHECK_POSITION(win, x, win->_cury); /* * If we're trying to add a character at the lower-right corner more * than once, fail. (Moving the cursor will clear the flag). */ if (win->_flags & _WRAPPED) { if (x >= win->_maxx) return (ERR); win->_flags &= ~_WRAPPED; } ch = render_char(win, ch); TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs))); line = win->_line+win->_cury; if (line->firstchar == _NOCHANGE) line->firstchar = line->lastchar = x; else if (x < line->firstchar) line->firstchar = x; else if (x > line->lastchar) line->lastchar = x; line->text[x++] = ch; TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch))); if (x > win->_maxx) { /* * The _WRAPPED flag is useful only for telling an application * that we've just wrapped the cursor. We don't do anything * with this flag except set it when wrapping, and clear it * whenever we move the cursor. If we try to wrap at the * lower-right corner of a window, we cannot move the cursor * (since that wouldn't be legal). So we return an error * (which is what SVr4 does). Unlike SVr4, we can successfully * add a character to the lower-right corner. */ win->_flags |= _WRAPPED; if (++win->_cury > win->_regbottom) { win->_cury = win->_regbottom; win->_curx = win->_maxx; if (!win->_scroll) return (ERR); scroll(win); } win->_curx = 0; return (OK); } win->_curx = x; return OK; }
waddnstr(WINDOW *win, const char *astr, int n) { const char *str = astr; int code = ERR; T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) strlen(astr); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != '\0')) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str))); SetChar(ch, UChar(*str++), A_NORMAL); if (_nc_waddch_nosync(win, ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); returnCode(code); }
waddnwstr(WINDOW *win, const wchar_t *str, int n) { int code = ERR; T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbufn(str, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) wcslen(str); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != L('\0'))) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str)); SetChar(ch, *str++, A_NORMAL); if (wadd_wch(win, &ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnwstr returns %d", code)); returnCode(code); }
slk_attron(const chtype attr) { T((T_CALLED("slk_attron(%s)"), _traceattr(attr))); if (SP != 0 && SP->_slk != 0) { toggle_attr_on(SP->_slk->attr, attr); returnCode(OK); } else returnCode(ERR); }
slk_attrset(const chtype attr) { T((T_CALLED("slk_attrset(%s)"), _traceattr(attr))); if (SP != 0 && SP->_slk != 0) { SetAttr(SP->_slk->attr, attr); returnCode(OK); } else returnCode(ERR); }
NCURSES_SP_NAME(slk_attrset) (NCURSES_SP_DCLx const chtype attr) { T((T_CALLED("slk_attrset(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); if (SP_PARM != 0 && SP_PARM->_slk != 0) { SetAttr(SP_PARM->_slk->attr, attr); returnCode(OK); } else returnCode(ERR); }
slk_attr_set (const attr_t attr, short color_pair_number, void *opts) { T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number)); if (SP != 0 && SP->_slk != 0 && !opts && color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) { SP->_slk->attr = attr; toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number)); returnCode(OK); } else returnCode(ERR); }
NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr) { T((T_CALLED("slk_attron(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); if (SP_PARM != 0 && SP_PARM->_slk != 0) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); AddAttr(SP_PARM->_slk->attr, attr); if ((attr & A_COLOR) != 0) { SetPair(SP_PARM->_slk->attr, PAIR_NUMBER(attr)); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); returnCode(OK); } else returnCode(ERR); }
slk_attroff(const chtype attr) { T((T_CALLED("slk_attroff(%s)"), _traceattr(attr))); if (SP != 0 && SP->_slk != 0) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr)))); RemAttr(SP->_slk->attr, attr); if ((attr & A_COLOR) != 0) { SetPair(SP->_slk->attr, 0); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr)))); returnCode(OK); } else returnCode(ERR); }
slk_attr_set(const attr_t attr, short color_pair_number, void *opts) { T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number)); if (SP != 0 && SP->_slk != 0 && !opts && color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr)))); SetAttr(SP->_slk->attr, attr); if (color_pair_number > 0) { SetPair(SP->_slk->attr, color_pair_number); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr)))); returnCode(OK); } else returnCode(ERR); }
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); }
NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx const attr_t attr, short color_pair_number, void *opts) { int code = ERR; T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number)); if (SP_PARM != 0 && SP_PARM->_slk != 0 && !opts && color_pair_number >= 0 && color_pair_number < SP_PARM->_pair_limit) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); SetAttr(SP_PARM->_slk->attr, attr); if (color_pair_number > 0) { SetPair(SP_PARM->_slk->attr, color_pair_number); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); code = OK; } returnCode(code); }
mvcur(int yold, int xold, int ynew, int xnew) /* optimized cursor move from (yold, xold) to (ynew, xnew) */ { NCURSES_CH_T oldattr; int code; TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"), yold, xold, ynew, xnew)); if (SP == 0) { code = ERR; } else if (yold == ynew && xold == xnew) { code = OK; } else { /* * Most work here is rounding for terminal boundaries getting the * column position implied by wraparound or the lack thereof and * rolling up the screen to get ynew on the screen. */ if (xnew >= screen_columns) { ynew += xnew / screen_columns; xnew %= screen_columns; } /* * Force restore even if msgr is on when we're in an alternate * character set -- these have a strong tendency to screw up the CR & * LF used for local character motions! */ oldattr = SCREEN_ATTRS(SP); if ((AttrOf(oldattr) & A_ALTCHARSET) || (AttrOf(oldattr) && !move_standout_mode)) { TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move", (unsigned long) AttrOf(oldattr), _traceattr(AttrOf(oldattr)))); (void) VIDATTR(A_NORMAL, 0); } if (xold >= screen_columns) { int l; if (SP->_nl) { l = (xold + 1) / screen_columns; yold += l; if (yold >= screen_lines) l -= (yold - screen_lines - 1); if (l > 0) { if (carriage_return) { TPUTS_TRACE("carriage_return"); putp(carriage_return); } else _nc_outch('\r'); xold = 0; while (l > 0) { if (newline) { TPUTS_TRACE("newline"); putp(newline); } else _nc_outch('\n'); l--; } } } else { /* * If caller set nonl(), we cannot really use newlines to * position to the next row. */ xold = -1; yold = -1; } } if (yold > screen_lines - 1) yold = screen_lines - 1; if (ynew > screen_lines - 1) ynew = screen_lines - 1; /* destination location is on screen now */ code = onscreen_mvcur(yold, xold, ynew, xnew, TRUE); /* * Restore attributes if we disabled them before moving. */ if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) { TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move", (unsigned long) AttrOf(oldattr), _traceattr(AttrOf(oldattr)))); (void) VIDATTR(AttrOf(oldattr), GetPair(oldattr)); } } returnCode(code); }
****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <*****@*****.**> 1992,1995 * * and: Eric S. Raymond <*****@*****.**> * ****************************************************************************/ /* ** lib_wattron.c ** ** The routines wattr_on(). ** */ #include <curses.priv.h> #include <ctype.h> MODULE_ID("$Id: lib_wattron.c,v 1.1 2004/01/08 13:43:24 rahtz Exp $") NCURSES_EXPORT(int) wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED) { T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at))); if (win) { T(("... current %s", _traceattr(win->_attrs))); toggle_attr_on(win->_attrs, at); returnCode(OK); } else returnCode(ERR); }
_nc_retrace_attr_t(attr_t code) { T((T_RETURN("%s"), _traceattr(code))); return code; }
** lib_chgat.c ** ** The routine wchgat(). ** */ #include <curses.priv.h> MODULE_ID("$Id: lib_chgat.c,v 1.7 2006/07/15 22:07:11 tom Exp $") NCURSES_EXPORT(int) wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED) { int i; T((T_CALLED("wchgat(%p,%d,%s,%d)"), win, n, _traceattr(attr), color)); if (win) { struct ldat *line = &(win->_line[win->_cury]); toggle_attr_on(attr, COLOR_PAIR(color)); for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) { SetAttr(line->text[i], attr); SetPair(line->text[i], color); CHANGED_CELL(line, i); } returnCode(OK); } else returnCode(ERR);
vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int)) { #if NCURSES_EXT_COLORS static attr_t previous_attr = A_NORMAL; static int previous_pair = 0; attr_t turn_on, turn_off; bool reverse = FALSE; bool can_color = (SP == 0 || SP->_coloron); #if NCURSES_EXT_FUNCS bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color); #else #define fix_pair0 FALSE #endif T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair)); /* this allows us to go on whether or not newterm() has been called */ if (SP) { previous_attr = AttrOf(SCREEN_ATTRS(SP)); previous_pair = GetPair(SCREEN_ATTRS(SP)); } TR(TRACE_ATTRS, ("previous attribute was %s, %d", _traceattr(previous_attr), previous_pair)); #if !USE_XMC_SUPPORT if ((SP != 0) && (magic_cookie_glitch > 0)) newmode &= ~(SP->_xmc_suppress); #endif
MODULE_ID("$Id: lib_chgat.c,v 1.12 2017/03/16 23:45:20 tom Exp $") NCURSES_EXPORT(int) wchgat(WINDOW *win, int n, attr_t attr, NCURSES_PAIRS_T pair_arg, const void *opts GCC_UNUSED) { int code = ERR; int color_pair = pair_arg; T((T_CALLED("wchgat(%p,%d,%s,%d)"), (void *) win, n, _traceattr(attr), color_pair)); set_extended_pair(opts, color_pair); if (win) { struct ldat *line = &(win->_line[win->_cury]); int i; toggle_attr_on(attr, ColorPair(color_pair)); for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) { SetAttr(line->text[i], attr); SetPair(line->text[i], color_pair); CHANGED_CELL(line, i); }