wvline_set(WINDOW *win, const cchar_t * ch, int n) { int code = ERR; NCURSES_SIZE_T row, col; NCURSES_SIZE_T end; T((T_CALLED("wvline(%p,%s,%d)"), win, _tracecchar_t(ch), n)); if (win) { NCURSES_CH_T wch; row = win->_cury; col = win->_curx; end = row + n - 1; if (end > win->_maxy) end = win->_maxy; if (ch == 0) wch = *WACS_VLINE; else wch = *ch; wch = _nc_render(win, wch); while (end >= row) { struct ldat *line = &(win->_line[end]); line->text[col] = wch; CHANGED_CELL(line, col); end--; } _nc_synchook(win); code = OK; } returnCode(code); }
wclrtobot(WINDOW *win) { int code = ERR; T((T_CALLED("wclrtobot(%p)"), (void *) win)); if (win) { NCURSES_SIZE_T y; NCURSES_SIZE_T startx = win->_curx; NCURSES_CH_T blank = win->_nc_bkgd; T(("clearing from y = %ld to y = %ld with maxx = %ld", (long) win->_cury, (long) win->_maxy, (long) win->_maxx)); for (y = win->_cury; y <= win->_maxy; y++) { struct ldat *line = &(win->_line[y]); NCURSES_CH_T *ptr = &(line->text[startx]); NCURSES_CH_T *end = &(line->text[win->_maxx]); CHANGED_TO_EOL(line, startx, win->_maxx); while (ptr <= end) *ptr++ = blank; startx = 0; } _nc_synchook(win); code = OK; } returnCode(code); }
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); }
int waddchnstr(WINDOW *win, const chtype *const astr, int n) { short y = win->_cury; short x = win->_curx; int code = OK; struct ldat *line; T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); if (!win) returnCode(ERR); if (n < 0) { const chtype *str; n = 0; for (str=(const chtype *)astr; *str!=0; str++) n++; } if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); line = &(win->_line[y]); memcpy(line->text+x, astr, n*sizeof(*astr)); CHANGED_RANGE(line, x, x+n-1); _nc_synchook(win); returnCode(code); }
whline_set(WINDOW *win, const cchar_t * ch, int n) { int code = ERR; NCURSES_SIZE_T start; NCURSES_SIZE_T end; T((T_CALLED("whline_set(%p,%s,%d)"), win, _tracecchar_t(ch), n)); if (win) { struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T wch; start = win->_curx; end = start + n - 1; if (end > win->_maxx) end = win->_maxx; CHANGED_RANGE(line, start, end); if (ch == 0) wch = *WACS_HLINE; else wch = *ch; wch = _nc_render(win, wch); while (end >= start) { line->text[end] = wch; end--; } _nc_synchook(win); code = OK; } returnCode(code); }
int werase(WINDOW *win) { int code = ERR; int y; chtype blank; chtype *sp, *end, *start; T((T_CALLED("werase(%p)"), win)); if (win) { blank = _nc_background(win); for (y = 0; y <= win->_maxy; y++) { start = win->_line[y].text; end = &start[win->_maxx]; for (sp = start; sp <= end; sp++) *sp = blank; win->_line[y].firstchar = 0; win->_line[y].lastchar = win->_maxx; } win->_curx = win->_cury = 0; win->_flags &= ~_WRAPPED; _nc_synchook(win); code = OK; } returnCode(code); }
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); }
static NCURSES_INLINE int #undef wbkgrnd #endif wbkgrnd(WINDOW *win, const ARG_CH_T ch) { int code = ERR; int x, y; NCURSES_CH_T new_bkgd = CHDEREF(ch); T((T_CALLED("wbkgd(%p,%s)"), (void *) win, _tracech_t(ch))); if (win) { NCURSES_CH_T old_bkgrnd; wgetbkgrnd(win, &old_bkgrnd); (void) wbkgrndset(win, CHREF(new_bkgd)); (void) wattrset(win, AttrOf(win->_nc_bkgd)); for (y = 0; y <= win->_maxy; y++) { for (x = 0; x <= win->_maxx; x++) { if (CharEq(win->_line[y].text[x], old_bkgrnd)) { win->_line[y].text[x] = win->_nc_bkgd; } else { NCURSES_CH_T wch = win->_line[y].text[x]; RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT))); win->_line[y].text[x] = _nc_render(win, wch); } } } touchwin(win); _nc_synchook(win); code = OK; } returnCode(code); }
int wclrtobot(WINDOW *win) { int code = ERR; T((T_CALLED("wclrtobot(%p)"), win)); if (win) { short y; short startx = win->_curx; chtype blank = _nc_background(win); T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx)); for (y = win->_cury; y <= win->_maxy; y++) { struct ldat *line = &(win->_line[y]); chtype *ptr = &(line->text[startx]); chtype *end = &(line->text[win->_maxx]); CHANGED_TO_EOL(line, startx, win->_maxx); while (ptr <= end) *ptr++ = blank; startx = 0; } _nc_synchook(win); code = OK; } returnCode(code); }
waddchnstr(WINDOW *win, const chtype *astr, int n) { NCURSES_SIZE_T y, x; int code = OK; int i; struct ldat *line; T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); if (!win) returnCode(ERR); y = win->_cury; x = win->_curx; if (n < 0) { const chtype *str; n = 0; for (str = (const chtype *) astr; *str != 0; str++) n++; } if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); line = &(win->_line[y]); for (i = 0; i < n && ChCharOf(astr[i]) != '\0'; ++i) { SetChar2(line->text[i + x], astr[i]); } CHANGED_RANGE(line, x, x + n - 1); _nc_synchook(win); returnCode(code); }
int wclrtobot(WINDOW *win) { int code = ERR; chtype blank; chtype *ptr, *end; short y, startx; T((T_CALLED("wclrtobot(%p)"), win)); if (win) { startx = win->_curx; T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx)); for (y = win->_cury; y <= win->_maxy; y++) { end = &win->_line[y].text[win->_maxx]; blank = _nc_background(win); for (ptr = &win->_line[y].text[startx]; ptr <= end; ptr++) *ptr = blank; if (win->_line[y].firstchar > startx || win->_line[y].firstchar == _NOCHANGE) win->_line[y].firstchar = startx; win->_line[y].lastchar = win->_maxx; startx = 0; } _nc_synchook(win); code = OK; } 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); }
whline(WINDOW *win, chtype ch, int n) { int code = ERR; NCURSES_SIZE_T start; NCURSES_SIZE_T end; T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n)); if (win) { struct ldat *line = &(win->_line[win->_cury]); start = win->_curx; end = start + n - 1; if (end > win->_maxx) end = win->_maxx; CHANGED_RANGE(line, start, end); if (ch == 0) ch = ACS_HLINE; ch = _nc_render(win, ch); while (end >= start) { line->text[end] = ch; end--; } _nc_synchook(win); code = OK; } returnCode(code); }
int wclrtoeol(WINDOW *win) { int code = ERR; chtype blank; chtype *ptr, *end; short y, x; T((T_CALLED("wclrtoeol(%p)"), win)); if (win) { y = win->_cury; x = win->_curx; /* * If we have just wrapped the cursor, the clear applies to the new * line, unless we are at the lower right corner. */ if (win->_flags & _WRAPPED && y < win->_maxy) { win->_flags &= ~_WRAPPED; } /* * There's no point in clearing if we're not on a legal position, * either. */ if (win->_flags & _WRAPPED || y > win->_maxy || x > win->_maxx) returnCode(ERR); blank = _nc_background(win); end = &win->_line[y].text[win->_maxx]; for (ptr = &win->_line[y].text[x]; ptr <= end; ptr++) *ptr = blank; if (win->_line[y].firstchar > win->_curx || win->_line[y].firstchar == _NOCHANGE) win->_line[y].firstchar = win->_curx; win->_line[y].lastchar = win->_maxx; _nc_synchook(win); code = OK; } returnCode(code); }
int waddch(WINDOW *win, const chtype ch) { int code = ERR; TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch))); if (win && (waddch_nosync(win, ch) != ERR)) { _nc_synchook(win); code = OK; } TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); return(code); }
wscrl(WINDOW *win, int n) { T((T_CALLED("wscrl(%p,%d)"), (void *) win, n)); if (!win || !win->_scroll) { TR(TRACE_MOVE, ("...scrollok is false")); returnCode(ERR); } if (n != 0) { _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd); _nc_synchook(win); } returnCode(OK); }
wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) { int code = ERR; NCURSES_SIZE_T oy; NCURSES_SIZE_T ox; const wchar_t *cp; T((T_CALLED("wins_nwstr(%p,%s,%d)"), (void *) win, _nc_viswbufn(wstr, n), n)); if (win != 0 && wstr != 0) { if (n < 1) n = (int) wcslen(wstr); code = OK; if (n > 0) { SCREEN *sp = _nc_screen_of(win); oy = win->_cury; ox = win->_curx; for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { int len = wcwidth(*cp); if ((len >= 0 && len != 1) || !is7bits(*cp)) { cchar_t tmp_cchar; wchar_t tmp_wchar = *cp; memset(&tmp_cchar, 0, sizeof(tmp_cchar)); (void) setcchar(&tmp_cchar, &tmp_wchar, WA_NORMAL, (short) 0, (void *) 0); code = _nc_insert_wch(win, &tmp_cchar); } else { /* tabs, other ASCII stuff */ code = _nc_insert_ch(sp, win, (chtype) (*cp)); } if (code != OK) break; } win->_curx = ox; win->_cury = oy; _nc_synchook(win); } } returnCode(code); }
werase(WINDOW *win) { int code = ERR; NCURSES_CH_T blank; NCURSES_CH_T *start; T((T_CALLED("werase(%p)"), (void *) win)); if (win) { NCURSES_CH_T *sp; int y; blank = win->_nc_bkgd; for (y = 0; y <= win->_maxy; y++) { NCURSES_CH_T *end; start = win->_line[y].text; end = &start[win->_maxx]; /* * If this is a derived window, we have to handle the case where * a multicolumn character extends into the window that we are * erasing. */ if_WIDEC({ if (isWidecExt(start[0])) { int x = (win->_parent != 0) ? (win->_begx) : 0; while (x-- > 0) { if (isWidecBase(start[-1])) { --start; break; } --start; } } }); for (sp = start; sp <= end; sp++) *sp = blank; win->_line[y].firstchar = 0; win->_line[y].lastchar = win->_maxx; } win->_curx = win->_cury = 0; win->_flags &= ~_WRAPPED; _nc_synchook(win); code = OK; }
wadd_wch(WINDOW *win, const cchar_t *wch) { int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), (void *) win, _tracecchar_t(wch))); if (win && (wadd_wch_nosync(win, *wch) != ERR)) { _nc_synchook(win); code = OK; } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
winsdelln(WINDOW *win, int n) { int code = ERR; T((T_CALLED("winsdelln(%p,%d)"), win, n)); if (win) { if (n != 0) { _nc_scroll_window(win, -n, win->_cury, win->_maxy, win->_nc_bkgd); _nc_synchook(win); } code = OK; } returnCode(code); }
wclrtoeol(WINDOW *win) { int code = ERR; T((T_CALLED("wclrtoeol(%p)"), (void *) win)); if (win) { NCURSES_CH_T blank; NCURSES_CH_T *ptr, *end; struct ldat *line; NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; /* * If we have just wrapped the cursor, the clear applies to the * new line, unless we are at the lower right corner. */ if ((win->_flags & _WRAPPED) != 0 && y < win->_maxy) { win->_flags &= ~_WRAPPED; } /* * There's no point in clearing if we're not on a legal * position, either. */ if ((win->_flags & _WRAPPED) != 0 || y > win->_maxy || x > win->_maxx) returnCode(ERR); blank = win->_nc_bkgd; line = &win->_line[y]; CHANGED_TO_EOL(line, x, win->_maxx); ptr = &(line->text[x]); end = &(line->text[win->_maxx]); while (ptr <= end) *ptr++ = blank; _nc_synchook(win); code = OK; } returnCode(code); }
int wechochar(WINDOW *win, const chtype ch) { int code = ERR; TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch))); if (win && (waddch_nosync(win, ch) != ERR)) { bool save_immed = win->_immed; win->_immed = TRUE; _nc_synchook(win); win->_immed = save_immed; code = OK; } TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); return(code); }
wins_wch(WINDOW *win, const cchar_t *wch) { NCURSES_SIZE_T oy; NCURSES_SIZE_T ox; int code = ERR; T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch))); if (win != 0) { oy = win->_cury; ox = win->_curx; code = _nc_insert_wch(win, wch); win->_curx = ox; win->_cury = oy; _nc_synchook(win); } returnCode(code); }
wins_nwstr(WINDOW *win, const wchar_t * wstr, int n) { int code = ERR; NCURSES_SIZE_T oy; NCURSES_SIZE_T ox; const wchar_t *cp; T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbufn(wstr,n), n)); if (win != 0 && wstr != 0 && wcwidth(*wstr) > 0) { code = OK; if (n < 1) n = wcslen(wstr); oy = win->_cury; ox = win->_curx; for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { NCURSES_CH_T wch; SetChar2(wch, *cp); if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') { _nc_waddch_nosync(win, wch); } else if (is7bits(*cp) && iscntrl(*cp)) { winsch(win, ' ' + (chtype) (*cp)); winsch(win, (chtype) '^'); win->_curx += 2; } else if (wins_wch(win, &wch) == ERR || win->_curx > win->_maxx) { break; } } win->_curx = ox; win->_cury = oy; _nc_synchook(win); code = OK; } returnCode(code); }
waddchnstr(WINDOW *win, const chtype *astr, int n) { NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; int code = OK; struct ldat *line; T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); if (!win) returnCode(ERR); if (n < 0) { const chtype *str; n = 0; for (str = (const chtype *) astr; *str != 0; str++) n++; } if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); line = &(win->_line[y]); #if USE_WIDEC_SUPPORT { int i; for (i = 0; i < n; ++i) SetChar(line->text[i + x], ChCharOf(astr[i]), ChAttrOf(astr[i])); } #else memcpy(line->text + x, astr, n * sizeof(*astr)); #endif CHANGED_RANGE(line, x, x + n - 1); _nc_synchook(win); returnCode(code); }
winsnstr(WINDOW *win, const char *s, int n) { int code = ERR; NCURSES_SIZE_T oy; NCURSES_SIZE_T ox; const unsigned char *str = (const unsigned char *) s; const unsigned char *cp; T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n)); if (win != 0 && str != 0) { oy = win->_cury; ox = win->_curx; for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { _nc_insert_ch(win, (chtype) UChar(*cp)); } win->_curx = ox; win->_cury = oy; _nc_synchook(win); code = OK; } returnCode(code); }
wdelch(WINDOW *win) { int code = ERR; T((T_CALLED("wdelch(%p)"), (void *) win)); if (win) { NCURSES_CH_T blank = win->_nc_bkgd; struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T *end = &(line->text[win->_maxx]); NCURSES_CH_T *temp2 = &(line->text[win->_curx + 1]); NCURSES_CH_T *temp1 = temp2 - 1; CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 < end) *temp1++ = *temp2++; *temp1 = blank; _nc_synchook(win); code = OK; } returnCode(code); }
static inline int #endif wborder_set(WINDOW *win, const ARG_CH_T ls, const ARG_CH_T rs, const ARG_CH_T ts, const ARG_CH_T bs, const ARG_CH_T tl, const ARG_CH_T tr, const ARG_CH_T bl, const ARG_CH_T br) { NCURSES_SIZE_T i; NCURSES_SIZE_T endx, endy; NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), win, _tracech_t2(1, ls), _tracech_t2(2, rs), _tracech_t2(3, ts), _tracech_t2(4, bs), _tracech_t2(5, tl), _tracech_t2(6, tr), _tracech_t2(7, bl), _tracech_t2(8, br))); if (!win) returnCode(ERR); #define RENDER_WITH_DEFAULT(ch,def) \ if (ch == 0) \ SetChar(w ## ch,ChCharOf(def),ChAttrOf(def)); \ else w ## ch = CHDEREF(ch); \ w ## ch = _nc_render(win, w ## ch) RENDER_WITH_DEFAULT(ls, ACS_VLINE); RENDER_WITH_DEFAULT(rs, ACS_VLINE); RENDER_WITH_DEFAULT(ts, ACS_HLINE); RENDER_WITH_DEFAULT(bs, ACS_HLINE); RENDER_WITH_DEFAULT(tl, ACS_ULCORNER); RENDER_WITH_DEFAULT(tr, ACS_URCORNER); RENDER_WITH_DEFAULT(bl, ACS_LLCORNER); RENDER_WITH_DEFAULT(br, ACS_LRCORNER); T(("using %s, %s, %s, %s, %s, %s, %s, %s", _tracech_t2(1, CHREF(wls)), _tracech_t2(2, CHREF(wrs)), _tracech_t2(3, CHREF(wts)), _tracech_t2(4, CHREF(wbs)), _tracech_t2(5, CHREF(wtl)), _tracech_t2(6, CHREF(wtr)), _tracech_t2(7, CHREF(wbl)), _tracech_t2(8, CHREF(wbr)))); endx = win->_maxx; endy = win->_maxy; for (i = 0; i <= endx; i++) { win->_line[0].text[i] = wts; win->_line[endy].text[i] = wbs; } win->_line[endy].firstchar = win->_line[0].firstchar = 0; win->_line[endy].lastchar = win->_line[0].lastchar = endx; for (i = 0; i <= endy; i++) { win->_line[i].text[0] = wls; win->_line[i].text[endx] = wrs; win->_line[i].firstchar = 0; win->_line[i].lastchar = endx; } win->_line[0].text[0] = wtl; win->_line[0].text[endx] = wtr; win->_line[endy].text[0] = wbl; win->_line[endy].text[endx] = wbr; _nc_synchook(win); returnCode(OK); }
wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { NCURSES_SIZE_T i; NCURSES_SIZE_T endx, endy; chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), (void *) win, _tracechtype2(1, ls), _tracechtype2(2, rs), _tracechtype2(3, ts), _tracechtype2(4, bs), _tracechtype2(5, tl), _tracechtype2(6, tr), _tracechtype2(7, bl), _tracechtype2(8, br))); if (!win) returnCode(ERR); RENDER_WITH_DEFAULT(ls, ACS_VLINE); RENDER_WITH_DEFAULT(rs, ACS_VLINE); RENDER_WITH_DEFAULT(ts, ACS_HLINE); RENDER_WITH_DEFAULT(bs, ACS_HLINE); RENDER_WITH_DEFAULT(tl, ACS_ULCORNER); RENDER_WITH_DEFAULT(tr, ACS_URCORNER); RENDER_WITH_DEFAULT(bl, ACS_LLCORNER); RENDER_WITH_DEFAULT(br, ACS_LRCORNER); T(("using %s, %s, %s, %s, %s, %s, %s, %s", _tracechtype2(1, wls), _tracechtype2(2, wrs), _tracechtype2(3, wts), _tracechtype2(4, wbs), _tracechtype2(5, wtl), _tracechtype2(6, wtr), _tracechtype2(7, wbl), _tracechtype2(8, wbr))); endx = win->_maxx; endy = win->_maxy; for (i = 0; i <= endx; i++) { SetChar2(win->_line[0].text[i], wts); SetChar2(win->_line[endy].text[i], wbs); } win->_line[endy].firstchar = win->_line[0].firstchar = 0; win->_line[endy].lastchar = win->_line[0].lastchar = endx; for (i = 0; i <= endy; i++) { SetChar2(win->_line[i].text[0], wls); SetChar2(win->_line[i].text[endx], wrs); win->_line[i].firstchar = 0; win->_line[i].lastchar = endx; } SetChar2(win->_line[0].text[0], wtl); SetChar2(win->_line[0].text[endx], wtr); SetChar2(win->_line[endy].text[0], wbl); SetChar2(win->_line[endy].text[endx], wbr); _nc_synchook(win); returnCode(OK); }
wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n) { NCURSES_CH_T blank = NewChar(BLANK_TEXT); NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; int code = OK; struct ldat *line; int i, j, start, len, end; T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n)); if (!win) returnCode(ERR); if (n < 0) { n = _nc_wchstrlen(astr); } if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); line = &(win->_line[y]); start = x; end = x + n - 1; /* * Reset orphaned cells of multi-column characters that extend up to the * new string's location to blanks. */ if (x > 0 && isWidecExt(line->text[x])) { for (i = 0; i <= x; ++i) { if (!isWidecExt(line->text[x - i])) { /* must be isWidecBase() */ start -= i; while (i > 0) { line->text[x - i--] = _nc_render(win, blank); } break; } } } /* * Copy the new string to the window. */ for (i = 0; i < n && x <= win->_maxx; ++i) { if (isWidecExt(astr[i])) continue; len = wcwidth(CharOf(astr[i])); if (x + len - 1 <= win->_maxx) { line->text[x] = _nc_render(win, astr[i]); if (len > 1) { for (j = 0; j < len; ++j) { if (j != 0) { line->text[x + j] = line->text[x]; } SetWidecExt(line->text[x + j], j); } } x += len; end += len - 1; } else { break; } } /* * Set orphaned cells of multi-column characters which lie after the new * string to blanks. */ while (x <= win->_maxx && isWidecExt(line->text[x])) { line->text[x] = _nc_render(win, blank); ++end; ++x; } CHANGED_RANGE(line, start, end); _nc_synchook(win); returnCode(code); }