Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmpdcurses/pdcurses/deleteln.c
3153 views
1
/* PDCurses */
2
3
#include <curspriv.h>
4
5
/*man-start**************************************************************
6
7
deleteln
8
--------
9
10
### Synopsis
11
12
int deleteln(void);
13
int wdeleteln(WINDOW *win);
14
int insdelln(int n);
15
int winsdelln(WINDOW *win, int n);
16
int insertln(void);
17
int winsertln(WINDOW *win);
18
19
int mvdeleteln(int y, int x);
20
int mvwdeleteln(WINDOW *win, int y, int x);
21
int mvinsertln(int y, int x);
22
int mvwinsertln(WINDOW *win, int y, int x);
23
24
### Description
25
26
With the deleteln() and wdeleteln() functions, the line under the
27
cursor in the window is deleted. All lines below the current line are
28
moved up one line. The bottom line of the window is cleared. The
29
cursor position does not change.
30
31
With the insertln() and winsertn() functions, a blank line is
32
inserted above the current line and the bottom line is lost.
33
34
mvdeleteln(), mvwdeleteln(), mvinsertln() and mvwinsertln() allow
35
moving the cursor and inserting/deleting in one call.
36
37
### Return Value
38
39
All functions return OK on success and ERR on error.
40
41
### Portability
42
X/Open ncurses NetBSD
43
deleteln Y Y Y
44
wdeleteln Y Y Y
45
mvdeleteln - - -
46
mvwdeleteln - - -
47
insdelln Y Y Y
48
winsdelln Y Y Y
49
insertln Y Y Y
50
winsertln Y Y Y
51
mvinsertln - - -
52
mvwinsertln - - -
53
54
**man-end****************************************************************/
55
56
int wdeleteln(WINDOW *win)
57
{
58
chtype blank, *temp, *ptr;
59
int y;
60
61
PDC_LOG(("wdeleteln() - called\n"));
62
63
if (!win)
64
return ERR;
65
66
/* wrs (4/10/93) account for window background */
67
68
blank = win->_bkgd;
69
70
temp = win->_y[win->_cury];
71
72
for (y = win->_cury; y < win->_bmarg; y++)
73
{
74
win->_y[y] = win->_y[y + 1];
75
win->_firstch[y] = 0;
76
win->_lastch[y] = win->_maxx - 1;
77
}
78
79
for (ptr = temp; (ptr - temp < win->_maxx); ptr++)
80
*ptr = blank; /* make a blank line */
81
82
if (win->_cury <= win->_bmarg)
83
{
84
win->_firstch[win->_bmarg] = 0;
85
win->_lastch[win->_bmarg] = win->_maxx - 1;
86
win->_y[win->_bmarg] = temp;
87
}
88
89
return OK;
90
}
91
92
int deleteln(void)
93
{
94
PDC_LOG(("deleteln() - called\n"));
95
96
return wdeleteln(stdscr);
97
}
98
99
int mvdeleteln(int y, int x)
100
{
101
PDC_LOG(("mvdeleteln() - called\n"));
102
103
if (move(y, x) == ERR)
104
return ERR;
105
106
return wdeleteln(stdscr);
107
}
108
109
int mvwdeleteln(WINDOW *win, int y, int x)
110
{
111
PDC_LOG(("mvwdeleteln() - called\n"));
112
113
if (wmove(win, y, x) == ERR)
114
return ERR;
115
116
return wdeleteln(win);
117
}
118
119
int winsdelln(WINDOW *win, int n)
120
{
121
int i;
122
123
PDC_LOG(("winsdelln() - called\n"));
124
125
if (!win)
126
return ERR;
127
128
if (n > 0)
129
{
130
for (i = 0; i < n; i++)
131
if (winsertln(win) == ERR)
132
return ERR;
133
}
134
else if (n < 0)
135
{
136
n = -n;
137
for (i = 0; i < n; i++)
138
if (wdeleteln(win) == ERR)
139
return ERR;
140
}
141
142
return OK;
143
}
144
145
int insdelln(int n)
146
{
147
PDC_LOG(("insdelln() - called\n"));
148
149
return winsdelln(stdscr, n);
150
}
151
152
int winsertln(WINDOW *win)
153
{
154
chtype blank, *temp, *end;
155
int y;
156
157
PDC_LOG(("winsertln() - called\n"));
158
159
if (!win)
160
return ERR;
161
162
/* wrs (4/10/93) account for window background */
163
164
blank = win->_bkgd;
165
166
temp = win->_y[win->_maxy - 1];
167
168
for (y = win->_maxy - 1; y > win->_cury; y--)
169
{
170
win->_y[y] = win->_y[y - 1];
171
win->_firstch[y] = 0;
172
win->_lastch[y] = win->_maxx - 1;
173
}
174
175
win->_y[win->_cury] = temp;
176
177
for (end = &temp[win->_maxx - 1]; temp <= end; temp++)
178
*temp = blank;
179
180
win->_firstch[win->_cury] = 0;
181
win->_lastch[win->_cury] = win->_maxx - 1;
182
183
return OK;
184
}
185
186
int insertln(void)
187
{
188
PDC_LOG(("insertln() - called\n"));
189
190
return winsertln(stdscr);
191
}
192
193
int mvinsertln(int y, int x)
194
{
195
PDC_LOG(("mvinsertln() - called\n"));
196
197
if (move(y, x) == ERR)
198
return ERR;
199
200
return winsertln(stdscr);
201
}
202
203
int mvwinsertln(WINDOW *win, int y, int x)
204
{
205
PDC_LOG(("mvwinsertln() - called\n"));
206
207
if (wmove(win, y, x) == ERR)
208
return ERR;
209
210
return winsertln(win);
211
}
212
213