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 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); }
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); }
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 winsdelln(WINDOW *win, int n) { int code = ERR; T((T_CALLED("winsdel(%p,%d)"), win, n)); if (win) { if (n != 0) { _nc_scroll_window(win, -n, win->_cury, win->_maxy, _nc_background(win)); _nc_synchook(win); } code = OK; } returnCode(code); }
int wresize(WINDOW *win, int ToLines, int ToCols) { register int row; int size_x, size_y; struct ldat *pline; chtype blank; #ifdef TRACE T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols)); if (win) { TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)", win->_begy, win->_begx, win->_maxy, win->_maxx, win->_regtop, win->_regbottom)); if (_nc_tracing & TRACE_UPDATE) _tracedump("...before", win); } #endif if (!win || --ToLines < 0 || --ToCols < 0) returnCode(ERR); size_x = win->_maxx; size_y = win->_maxy; if (ToLines == size_y && ToCols == size_x) returnCode(OK); pline = (win->_flags & _SUBWIN) ? win->_parent->_line : 0; /* * If the number of lines has changed, adjust the size of the overall * vector: */ if (ToLines != size_y) { if (! (win->_flags & _SUBWIN)) { for (row = ToLines+1; row <= size_y; row++) free((char *)(win->_line[row].text)); } win->_line = ld_ALLOC(win->_line, ToLines+1); if (win->_line == 0) returnCode(ERR); for (row = size_y+1; row <= ToLines; row++) { win->_line[row].text = 0; win->_line[row].firstchar = 0; win->_line[row].lastchar = ToCols; if ((win->_flags & _SUBWIN)) { win->_line[row].text = &pline[win->_begy + row].text[win->_begx]; } } } /* * Adjust the width of the columns: */ blank = _nc_background(win); for (row = 0; row <= ToLines; row++) { chtype *s = win->_line[row].text; int begin = (s == 0) ? 0 : size_x + 1; int end = ToCols; if_USE_SCROLL_HINTS(win->_line[row].oldindex = row); if (ToCols != size_x || s == 0) { if (! (win->_flags & _SUBWIN)) { win->_line[row].text = s = c_ALLOC(s, ToCols+1); if (win->_line[row].text == 0) returnCode(ERR); } else if (s == 0) { win->_line[row].text = s = &pline[win->_begy + row].text[win->_begx]; } if (end >= begin) { /* growing */ if (win->_line[row].firstchar < begin) win->_line[row].firstchar = begin; win->_line[row].lastchar = ToCols; do { s[end] = blank; } while (--end >= begin); } else { /* shrinking */ win->_line[row].firstchar = 0; win->_line[row].lastchar = ToCols; } } } /* * Finally, adjust the parameters showing screen size and cursor * position: */ win->_maxx = ToCols; win->_maxy = ToLines; if (win->_regtop > win->_maxy) win->_regtop = win->_maxy; if (win->_regbottom > win->_maxy || win->_regbottom == size_y) win->_regbottom = win->_maxy; if (win->_curx > win->_maxx) win->_curx = win->_maxx; if (win->_cury > win->_maxy) win->_cury = win->_maxy; #ifdef TRACE TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)", win->_begy, win->_begx, win->_maxy, win->_maxx, win->_regtop, win->_regbottom)); if (_nc_tracing & TRACE_UPDATE) _tracedump("...after:", win); #endif returnCode(OK); }