soc/intel/xeon_sp/util: Enhance lock_pam0123
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / touch.c
blobc808058b81c95d5b7f9809b6ae0fccc1f3b0e0d7
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: touch.c,v 1.29 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: touch
11 Synopsis:
12 int touchwin(WINDOW *win);
13 int touchline(WINDOW *win, int start, int count);
14 int untouchwin(WINDOW *win);
15 int wtouchln(WINDOW *win, int y, int n, int changed);
16 bool is_linetouched(WINDOW *win, int line);
17 bool is_wintouched(WINDOW *win);
19 Description:
20 touchwin() and touchline() throw away all information about
21 which parts of the window have been touched, pretending that the
22 entire window has been drawn on. This is sometimes necessary
23 when using overlapping windows, since a change to one window
24 will affect the other window, but the records of which lines
25 have been changed in the other window will not reflect the
26 change.
28 untouchwin() marks all lines in the window as unchanged since
29 the last call to wrefresh().
31 wtouchln() makes n lines in the window, starting at line y, look
32 as if they have (changed == 1) or have not (changed == 0) been
33 changed since the last call to wrefresh().
35 is_linetouched() returns TRUE if the specified line in the
36 specified window has been changed since the last call to
37 wrefresh().
39 is_wintouched() returns TRUE if the specified window
40 has been changed since the last call to wrefresh().
42 Return Value:
43 All functions return OK on success and ERR on error except
44 is_wintouched() and is_linetouched().
46 Portability X/Open BSD SYS V
47 touchwin Y Y Y
48 touchline Y - 3.0
49 untouchwin Y - 4.0
50 wtouchln Y Y Y
51 is_linetouched Y - 4.0
52 is_wintouched Y - 4.0
54 **man-end****************************************************************/
56 int touchwin(WINDOW *win)
58 int i;
60 PDC_LOG(("touchwin() - called: Win=%x\n", win));
62 if (!win)
63 return ERR;
65 for (i = 0; i < win->_maxy; i++)
67 win->_firstch[i] = 0;
68 win->_lastch[i] = win->_maxx - 1;
71 return OK;
74 int touchline(WINDOW *win, int start, int count)
76 int i;
78 PDC_LOG(("touchline() - called: win=%p start %d count %d\n",
79 win, start, count));
81 if (!win || start > win->_maxy || start + count > win->_maxy)
82 return ERR;
84 for (i = start; i < start + count; i++)
86 win->_firstch[i] = 0;
87 win->_lastch[i] = win->_maxx - 1;
90 return OK;
93 int untouchwin(WINDOW *win)
95 int i;
97 PDC_LOG(("untouchwin() - called: win=%p", win));
99 if (!win)
100 return ERR;
102 for (i = 0; i < win->_maxy; i++)
104 win->_firstch[i] = _NO_CHANGE;
105 win->_lastch[i] = _NO_CHANGE;
108 return OK;
111 int wtouchln(WINDOW *win, int y, int n, int changed)
113 int i;
115 PDC_LOG(("wtouchln() - called: win=%p y=%d n=%d changed=%d\n",
116 win, y, n, changed));
118 if (!win || y > win->_maxy || y + n > win->_maxy)
119 return ERR;
121 for (i = y; i < y + n; i++)
123 if (changed)
125 win->_firstch[i] = 0;
126 win->_lastch[i] = win->_maxx - 1;
128 else
130 win->_firstch[i] = _NO_CHANGE;
131 win->_lastch[i] = _NO_CHANGE;
135 return OK;
138 bool is_linetouched(WINDOW *win, int line)
140 PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line));
142 if (!win || line > win->_maxy || line < 0)
143 return FALSE;
145 return (win->_firstch[line] != _NO_CHANGE) ? TRUE : FALSE;
148 bool is_wintouched(WINDOW *win)
150 int i;
152 PDC_LOG(("is_wintouched() - called: win=%p\n", win));
154 if (win)
155 for (i = 0; i < win->_maxy; i++)
156 if (win->_firstch[i] != _NO_CHANGE)
157 return TRUE;
159 return FALSE;