soc/intel/xeon_sp/util: Enhance lock_pam0123
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / clear.c
blob11295e34d7608893ea33a45fb6e4fc16669b7ede
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: clear.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: clear
11 Synopsis:
12 int clear(void);
13 int wclear(WINDOW *win);
14 int erase(void);
15 int werase(WINDOW *win);
16 int clrtobot(void);
17 int wclrtobot(WINDOW *win);
18 int clrtoeol(void);
19 int wclrtoeol(WINDOW *win);
21 Description:
22 erase() and werase() copy blanks (i.e. the background chtype) to
23 every cell of the window.
25 clear() and wclear() are similar to erase() and werase(), but
26 they also call clearok() to ensure that the window is
27 cleared on the next wrefresh().
29 clrtobot() and wclrtobot() clear the window from the current
30 cursor position to the end of the window.
32 clrtoeol() and wclrtoeol() clear the window from the current
33 cursor position to the end of the current line.
35 Return Value:
36 All functions return OK on success and ERR on error.
38 Portability X/Open BSD SYS V
39 clear Y Y Y
40 wclear Y Y Y
41 erase Y Y Y
42 werase Y Y Y
43 clrtobot Y Y Y
44 wclrtobot Y Y Y
45 clrtoeol Y Y Y
46 wclrtoeol Y Y Y
48 **man-end****************************************************************/
50 int wclrtoeol(WINDOW *win)
52 int x, y, minx;
53 chtype blank, *ptr;
55 PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
56 win->_cury, win->_curx));
58 if (!win)
59 return ERR;
61 y = win->_cury;
62 x = win->_curx;
64 /* wrs (4/10/93) account for window background */
66 blank = win->_bkgd;
68 for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
69 *ptr = blank;
71 if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
72 win->_firstch[y] = x;
74 win->_lastch[y] = win->_maxx - 1;
76 PDC_sync(win);
77 return OK;
80 int clrtoeol(void)
82 PDC_LOG(("clrtoeol() - called\n"));
84 return wclrtoeol(stdscr);
87 int wclrtobot(WINDOW *win)
89 PDC_LOG(("wclrtobot() - called\n"));
91 if (!win)
92 return ERR;
94 int savey = win->_cury;
95 int savex = win->_curx;
97 /* should this involve scrolling region somehow ? */
99 if (win->_cury + 1 < win->_maxy)
101 win->_curx = 0;
102 win->_cury++;
103 for (; win->_maxy > win->_cury; win->_cury++)
104 wclrtoeol(win);
105 win->_cury = savey;
106 win->_curx = savex;
108 wclrtoeol(win);
110 PDC_sync(win);
111 return OK;
114 int clrtobot(void)
116 PDC_LOG(("clrtobot() - called\n"));
118 return wclrtobot(stdscr);
121 int werase(WINDOW *win)
123 PDC_LOG(("werase() - called\n"));
125 if (wmove(win, 0, 0) == ERR)
126 return ERR;
128 return wclrtobot(win);
131 int erase(void)
133 PDC_LOG(("erase() - called\n"));
135 return werase(stdscr);
138 int wclear(WINDOW *win)
140 PDC_LOG(("wclear() - called\n"));
142 if (!win)
143 return ERR;
145 win->_clear = TRUE;
146 return werase(win);
149 int clear(void)
151 PDC_LOG(("clear() - called\n"));
153 return wclear(stdscr);