int whline(WINDOW *win, chtype ch, int n) { int code = ERR; short start; short 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--; } code = OK; } 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); }
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); }
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]); 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) SetChar(wch, ChCharOf(ACS_HLINE), ChAttrOf(ACS_HLINE)); else SetChar(wch, ChCharOf(ch), ChAttrOf(ch)); wch = _nc_render(win, wch); while (end >= start) { line->text[end] = wch; end--; } _nc_synchook(win); code = OK; } returnCode(code); }
_nc_insert_wch(WINDOW *win, const cchar_t *wch) { int cells = wcwidth(CharOf(CHDEREF(wch))); int cell; int code = OK; if (cells < 0) { code = winsch(win, (chtype) CharOf(CHDEREF(wch))); } else { if (cells == 0) cells = 1; if (win->_curx <= win->_maxx) { struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T *end = &(line->text[win->_curx]); NCURSES_CH_T *temp1 = &(line->text[win->_maxx]); NCURSES_CH_T *temp2 = temp1 - cells; CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 > end) *temp1-- = *temp2--; *temp1 = _nc_render(win, *wch); for (cell = 1; cell < cells; ++cell) { SetWidecExt(temp1[cell], cell); } win->_curx = (NCURSES_SIZE_T) (win->_curx + cells); } } return code; }
int winsch(WINDOW *win, chtype c) { int code = ERR; chtype *temp1, *temp2; chtype *end; T((T_CALLED("winsch(%p, %s)"), win, _tracechtype(c))); if (win) { end = &win->_line[win->_cury].text[win->_curx]; temp1 = &win->_line[win->_cury].text[win->_maxx]; temp2 = temp1 - 1; while (temp1 > end) *temp1-- = *temp2--; *temp1 = _nc_render(win, c); win->_line[win->_cury].lastchar = win->_maxx; if (win->_line[win->_cury].firstchar == _NOCHANGE || win->_line[win->_cury].firstchar > win->_curx) win->_line[win->_cury].firstchar = win->_curx; code = OK; } returnCode(code); }
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); }
/* * Insert the given character, updating the current location to simplify * inserting a string. */ static int _nc_insert_wch(WINDOW *win, const cchar_t *wch) { int cells = wcwidth(CharOf(CHDEREF(wch))); int cell; if (cells <= 0) cells = 1; if (win->_curx <= win->_maxx) { struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T *end = &(line->text[win->_curx]); NCURSES_CH_T *temp1 = &(line->text[win->_maxx]); NCURSES_CH_T *temp2 = temp1 - cells; CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 > end) *temp1-- = *temp2--; *temp1 = _nc_render(win, *wch); for (cell = 1; cell < cells; ++cell) { SetWidecExt(temp1[cell], cell); } win->_curx++; } return OK; }
static NCURSES_INLINE chtype _my_render(WINDOW *win, chtype ch) { NCURSES_CH_T wch; SetChar2(wch, ch); wch = _nc_render(win, wch); return CharOf(wch) | AttrOf(wch); }
int winsch(WINDOW *win, chtype c) { int code = ERR; T((T_CALLED("winsch(%p, %s)"), win, _tracechtype(c))); if (win) { struct ldat *line = &(win->_line[win->_cury]); chtype *end = &(line->text[win->_curx]); chtype *temp1 = &(line->text[win->_maxx]); chtype *temp2 = temp1 - 1; CHANGED_TO_EOL(line, win->_curx, win->_maxx); while (temp1 > end) *temp1-- = *temp2--; *temp1 = _nc_render(win, c); code = OK; } returnCode(code); }
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); }
int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { short i; short endx, endy; T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"), 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); if (ls == 0) ls = ACS_VLINE; if (rs == 0) rs = ACS_VLINE; if (ts == 0) ts = ACS_HLINE; if (bs == 0) bs = ACS_HLINE; if (tl == 0) tl = ACS_ULCORNER; if (tr == 0) tr = ACS_URCORNER; if (bl == 0) bl = ACS_LLCORNER; if (br == 0) br = ACS_LRCORNER; ls = _nc_render(win, ls); rs = _nc_render(win, rs); ts = _nc_render(win, ts); bs = _nc_render(win, bs); tl = _nc_render(win, tl); tr = _nc_render(win, tr); bl = _nc_render(win, bl); br = _nc_render(win, br); T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br)); endx = win->_maxx; endy = win->_maxy; for (i = 0; i <= endx; i++) { win->_line[0].text[i] = ts; win->_line[endy].text[i] = bs; } 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] = ls; win->_line[i].text[endx] = rs; win->_line[i].firstchar = 0; win->_line[i].lastchar = endx; } win->_line[0].text[0] = tl; win->_line[0].text[endx] = tr; win->_line[endy].text[0] = bl; win->_line[endy].text[endx] = br; _nc_synchook(win); returnCode(OK); }