field_just(const FIELD *field) { T((T_CALLED("field_just(%p)"), (const void *)field)); returnCode(Normalize_Field(field)->just); }
wnoutrefresh(WINDOW *win) { NCURSES_SIZE_T limit_x; NCURSES_SIZE_T src_row, src_col; NCURSES_SIZE_T begx; NCURSES_SIZE_T begy; NCURSES_SIZE_T dst_row, dst_col; #if USE_SCROLL_HINTS bool wide; #endif #if NCURSES_SP_FUNCS SCREEN *SP_PARM = _nc_screen_of(win); #endif T((T_CALLED("wnoutrefresh(%p)"), (void *) win)); #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { _tracedump("...win", win); _nc_unlock_global(tracef); } #endif /* TRACE */ /* * This function will break badly if we try to refresh a pad. */ if ((win == 0) || (win->_flags & _ISPAD)) returnCode(ERR); /* put them here so "win == 0" won't break our code */ begx = win->_begx; begy = win->_begy; NewScreen(SP_PARM)->_nc_bkgd = win->_nc_bkgd; WINDOW_ATTRS(NewScreen(SP_PARM)) = WINDOW_ATTRS(win); /* merge in change information from all subwindows of this window */ wsyncdown(win); #if USE_SCROLL_HINTS /* * For pure efficiency, we'd want to transfer scrolling information * from the window to newscr whenever the window is wide enough that * its update will dominate the cost of the update for the horizontal * band of newscr that it occupies. Unfortunately, this threshold * tends to be complex to estimate, and in any case scrolling the * whole band and rewriting the parts outside win's image would look * really ugly. So. What we do is consider the window "wide" if it * either (a) occupies the whole width of newscr, or (b) occupies * all but at most one column on either vertical edge of the screen * (this caters to fussy people who put boxes around full-screen * windows). Note that changing this formula will not break any code, * merely change the costs of various update cases. */ wide = (begx <= 1 && win->_maxx >= (NewScreen(SP_PARM)->_maxx - 1)); #endif win->_flags &= ~_HASMOVED; /* * Microtweaking alert! This double loop is one of the genuine * hot spots in the code. Even gcc doesn't seem to do enough * common-subexpression chunking to make it really tense, * so we'll force the issue. */ /* limit(dst_col) */ limit_x = win->_maxx; /* limit(src_col) */ if (limit_x > NewScreen(SP_PARM)->_maxx - begx) limit_x = NewScreen(SP_PARM)->_maxx - begx; for (src_row = 0, dst_row = begy + win->_yoffset; src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy; src_row++, dst_row++) { register struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]); register struct ldat *oline = &win->_line[src_row]; if (oline->firstchar != _NOCHANGE) { int last_src = oline->lastchar; if (last_src > limit_x) last_src = limit_x; src_col = oline->firstchar; dst_col = src_col + begx; if_WIDEC({ register int j; /* * Ensure that we will copy complete multi-column characters * on the left-boundary. */ if (isWidecExt(oline->text[src_col])) { j = 1 + dst_col - WidecExt(oline->text[src_col]); if (j < 0) j = 0; if (dst_col > j) { src_col -= (dst_col - j); dst_col = j; } } /* * Ensure that we will copy complete multi-column characters * on the right-boundary. */ j = last_src; if (WidecExt(oline->text[j])) { ++j; while (j <= limit_x) { if (isWidecBase(oline->text[j])) { break; } else { last_src = j; } ++j; } } }); if_WIDEC({ static cchar_t blank = BLANK; int last_dst = begx + ((last_src < win->_maxx) ? last_src : win->_maxx); int fix_left = dst_col; int fix_right = last_dst; register int j; /* * Check for boundary cases where we may overwrite part of a * multi-column character. For those, wipe the remainder of * the character to blanks. */ j = dst_col; if (isWidecExt(nline->text[j])) { /* * On the left, we only care about multi-column characters * that extend into the changed region. */ fix_left = 1 + j - WidecExt(nline->text[j]); if (fix_left < 0) fix_left = 0; /* only if cell is corrupt */ } j = last_dst; if (WidecExt(nline->text[j]) != 0) { /* * On the right, any multi-column character is a problem, * unless it happens to be contained in the change, and * ending at the right boundary of the change. The * computation for 'fix_left' accounts for the left-side of * this character. Find the end of the character. */ ++j; while (j <= NewScreen(SP_PARM)->_maxx && isWidecExt(nline->text[j])) { fix_right = j++; } } /* * The analysis is simpler if we do the clearing afterwards. * Do that now. */ if (fix_left < dst_col || fix_right > last_dst) { for (j = fix_left; j <= fix_right; ++j) { nline->text[j] = blank; CHANGED_CELL(nline, j); } } });
item_count(const MENU * menu) { T((T_CALLED("item_count(%p)"), menu)); returnCode(menu ? menu->nitems : -1); }
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); }