/* PDCurses */12#include <curspriv.h>34/*man-start**************************************************************56clear7-----89### Synopsis1011int clear(void);12int wclear(WINDOW *win);13int erase(void);14int werase(WINDOW *win);15int clrtobot(void);16int wclrtobot(WINDOW *win);17int clrtoeol(void);18int wclrtoeol(WINDOW *win);1920### Description2122erase() and werase() copy blanks (i.e. the background chtype) to23every cell of the window.2425clear() and wclear() are similar to erase() and werase(), but they26also call clearok() to ensure that the the window is cleared on the27next wrefresh().2829clrtobot() and wclrtobot() clear the window from the current cursor30position to the end of the window.3132clrtoeol() and wclrtoeol() clear the window from the current cursor33position to the end of the current line.3435### Return Value3637All functions return OK on success and ERR on error.3839### Portability40X/Open ncurses NetBSD41clear Y Y Y42wclear Y Y Y43erase Y Y Y44werase Y Y Y45clrtobot Y Y Y46wclrtobot Y Y Y47clrtoeol Y Y Y48wclrtoeol Y Y Y4950**man-end****************************************************************/5152int wclrtoeol(WINDOW *win)53{54int x, y, minx;55chtype blank, *ptr;5657PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",58win->_cury, win->_curx));5960if (!win)61return ERR;6263y = win->_cury;64x = win->_curx;6566/* wrs (4/10/93) account for window background */6768blank = win->_bkgd;6970for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)71*ptr = blank;7273if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)74win->_firstch[y] = x;7576win->_lastch[y] = win->_maxx - 1;7778PDC_sync(win);79return OK;80}8182int clrtoeol(void)83{84PDC_LOG(("clrtoeol() - called\n"));8586return wclrtoeol(stdscr);87}8889int wclrtobot(WINDOW *win)90{91int savey, savex;9293PDC_LOG(("wclrtobot() - called\n"));9495if (!win)96return ERR;9798savey = win->_cury;99savex = win->_curx;100101/* should this involve scrolling region somehow ? */102103if (win->_cury + 1 < win->_maxy)104{105win->_curx = 0;106win->_cury++;107for (; win->_maxy > win->_cury; win->_cury++)108wclrtoeol(win);109win->_cury = savey;110win->_curx = savex;111}112wclrtoeol(win);113114PDC_sync(win);115return OK;116}117118int clrtobot(void)119{120PDC_LOG(("clrtobot() - called\n"));121122return wclrtobot(stdscr);123}124125int werase(WINDOW *win)126{127PDC_LOG(("werase() - called\n"));128129if (wmove(win, 0, 0) == ERR)130return ERR;131132return wclrtobot(win);133}134135int erase(void)136{137PDC_LOG(("erase() - called\n"));138139return werase(stdscr);140}141142int wclear(WINDOW *win)143{144PDC_LOG(("wclear() - called\n"));145146if (!win)147return ERR;148149win->_clear = TRUE;150return werase(win);151}152153int clear(void)154{155PDC_LOG(("clear() - called\n"));156157return wclear(stdscr);158}159160161