Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmpdcurses/pdcurses/clear.c
3153 views
1
/* PDCurses */
2
3
#include <curspriv.h>
4
5
/*man-start**************************************************************
6
7
clear
8
-----
9
10
### Synopsis
11
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);
20
21
### Description
22
23
erase() and werase() copy blanks (i.e. the background chtype) to
24
every cell of the window.
25
26
clear() and wclear() are similar to erase() and werase(), but they
27
also call clearok() to ensure that the the window is cleared on the
28
next wrefresh().
29
30
clrtobot() and wclrtobot() clear the window from the current cursor
31
position to the end of the window.
32
33
clrtoeol() and wclrtoeol() clear the window from the current cursor
34
position to the end of the current line.
35
36
### Return Value
37
38
All functions return OK on success and ERR on error.
39
40
### Portability
41
X/Open ncurses NetBSD
42
clear Y Y Y
43
wclear Y Y Y
44
erase Y Y Y
45
werase Y Y Y
46
clrtobot Y Y Y
47
wclrtobot Y Y Y
48
clrtoeol Y Y Y
49
wclrtoeol Y Y Y
50
51
**man-end****************************************************************/
52
53
int wclrtoeol(WINDOW *win)
54
{
55
int x, y, minx;
56
chtype blank, *ptr;
57
58
PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
59
win->_cury, win->_curx));
60
61
if (!win)
62
return ERR;
63
64
y = win->_cury;
65
x = win->_curx;
66
67
/* wrs (4/10/93) account for window background */
68
69
blank = win->_bkgd;
70
71
for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
72
*ptr = blank;
73
74
if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
75
win->_firstch[y] = x;
76
77
win->_lastch[y] = win->_maxx - 1;
78
79
PDC_sync(win);
80
return OK;
81
}
82
83
int clrtoeol(void)
84
{
85
PDC_LOG(("clrtoeol() - called\n"));
86
87
return wclrtoeol(stdscr);
88
}
89
90
int wclrtobot(WINDOW *win)
91
{
92
int savey, savex;
93
94
PDC_LOG(("wclrtobot() - called\n"));
95
96
if (!win)
97
return ERR;
98
99
savey = win->_cury;
100
savex = win->_curx;
101
102
/* should this involve scrolling region somehow ? */
103
104
if (win->_cury + 1 < win->_maxy)
105
{
106
win->_curx = 0;
107
win->_cury++;
108
for (; win->_maxy > win->_cury; win->_cury++)
109
wclrtoeol(win);
110
win->_cury = savey;
111
win->_curx = savex;
112
}
113
wclrtoeol(win);
114
115
PDC_sync(win);
116
return OK;
117
}
118
119
int clrtobot(void)
120
{
121
PDC_LOG(("clrtobot() - called\n"));
122
123
return wclrtobot(stdscr);
124
}
125
126
int werase(WINDOW *win)
127
{
128
PDC_LOG(("werase() - called\n"));
129
130
if (wmove(win, 0, 0) == ERR)
131
return ERR;
132
133
return wclrtobot(win);
134
}
135
136
int erase(void)
137
{
138
PDC_LOG(("erase() - called\n"));
139
140
return werase(stdscr);
141
}
142
143
int wclear(WINDOW *win)
144
{
145
PDC_LOG(("wclear() - called\n"));
146
147
if (!win)
148
return ERR;
149
150
win->_clear = TRUE;
151
return werase(win);
152
}
153
154
int clear(void)
155
{
156
PDC_LOG(("clear() - called\n"));
157
158
return wclear(stdscr);
159
}
160
161