| 1 |
|
| 2 |
|
| 3 |
#include <curspriv.h> |
| 4 |
|
| 5 |
RCSID("$Id: deleteln.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $") |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
int wdeleteln(WINDOW *win) |
| 54 |
{ |
| 55 |
chtype blank, *temp, *ptr; |
| 56 |
int y; |
| 57 |
|
| 58 |
PDC_LOG(("wdeleteln() - called\n")); |
| 59 |
|
| 60 |
if (!win) |
| 61 |
return ERR; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
blank = win->_bkgd; |
| 66 |
|
| 67 |
temp = win->_y[win->_cury]; |
| 68 |
|
| 69 |
for (y = win->_cury; y < win->_bmarg; y++) |
| 70 |
{ |
| 71 |
win->_y[y] = win->_y[y + 1]; |
| 72 |
win->_firstch[y] = 0; |
| 73 |
win->_lastch[y] = win->_maxx - 1; |
| 74 |
} |
| 75 |
|
| 76 |
for (ptr = temp; (ptr - temp < win->_maxx); ptr++) |
| 77 |
*ptr = blank; |
| 78 |
|
| 79 |
if (win->_cury <= win->_bmarg) |
| 80 |
{ |
| 81 |
win->_firstch[win->_bmarg] = 0; |
| 82 |
win->_lastch[win->_bmarg] = win->_maxx - 1; |
| 83 |
win->_y[win->_bmarg] = temp; |
| 84 |
} |
| 85 |
|
| 86 |
return OK; |
| 87 |
} |
| 88 |
|
| 89 |
int deleteln(void) |
| 90 |
{ |
| 91 |
PDC_LOG(("deleteln() - called\n")); |
| 92 |
|
| 93 |
return wdeleteln(stdscr); |
| 94 |
} |
| 95 |
|
| 96 |
int mvdeleteln(int y, int x) |
| 97 |
{ |
| 98 |
PDC_LOG(("mvdeleteln() - called\n")); |
| 99 |
|
| 100 |
if (move(y, x) == ERR) |
| 101 |
return ERR; |
| 102 |
|
| 103 |
return wdeleteln(stdscr); |
| 104 |
} |
| 105 |
|
| 106 |
int mvwdeleteln(WINDOW *win, int y, int x) |
| 107 |
{ |
| 108 |
PDC_LOG(("mvwdeleteln() - called\n")); |
| 109 |
|
| 110 |
if (wmove(win, y, x) == ERR) |
| 111 |
return ERR; |
| 112 |
|
| 113 |
return wdeleteln(win); |
| 114 |
} |
| 115 |
|
| 116 |
int winsdelln(WINDOW *win, int n) |
| 117 |
{ |
| 118 |
int i; |
| 119 |
|
| 120 |
PDC_LOG(("winsdelln() - called\n")); |
| 121 |
|
| 122 |
if (!win) |
| 123 |
return ERR; |
| 124 |
|
| 125 |
if (n > 0) |
| 126 |
{ |
| 127 |
for (i = 0; i < n; i++) |
| 128 |
if (winsertln(win) == ERR) |
| 129 |
return ERR; |
| 130 |
} |
| 131 |
else if (n < 0) |
| 132 |
{ |
| 133 |
n = -n; |
| 134 |
for (i = 0; i < n; i++) |
| 135 |
if (wdeleteln(win) == ERR) |
| 136 |
return ERR; |
| 137 |
} |
| 138 |
|
| 139 |
return OK; |
| 140 |
} |
| 141 |
|
| 142 |
int insdelln(int n) |
| 143 |
{ |
| 144 |
PDC_LOG(("insdelln() - called\n")); |
| 145 |
|
| 146 |
return winsdelln(stdscr, n); |
| 147 |
} |
| 148 |
|
| 149 |
int winsertln(WINDOW *win) |
| 150 |
{ |
| 151 |
chtype blank, *temp, *end; |
| 152 |
int y; |
| 153 |
|
| 154 |
PDC_LOG(("winsertln() - called\n")); |
| 155 |
|
| 156 |
if (!win) |
| 157 |
return ERR; |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
blank = win->_bkgd; |
| 162 |
|
| 163 |
temp = win->_y[win->_maxy - 1]; |
| 164 |
|
| 165 |
for (y = win->_maxy - 1; y > win->_cury; y--) |
| 166 |
{ |
| 167 |
win->_y[y] = win->_y[y - 1]; |
| 168 |
win->_firstch[y] = 0; |
| 169 |
win->_lastch[y] = win->_maxx - 1; |
| 170 |
} |
| 171 |
|
| 172 |
win->_y[win->_cury] = temp; |
| 173 |
|
| 174 |
for (end = &temp[win->_maxx - 1]; temp <= end; temp++) |
| 175 |
*temp = blank; |
| 176 |
|
| 177 |
win->_firstch[win->_cury] = 0; |
| 178 |
win->_lastch[win->_cury] = win->_maxx - 1; |
| 179 |
|
| 180 |
return OK; |
| 181 |
} |
| 182 |
|
| 183 |
int insertln(void) |
| 184 |
{ |
| 185 |
PDC_LOG(("insertln() - called\n")); |
| 186 |
|
| 187 |
return winsertln(stdscr); |
| 188 |
} |
| 189 |
|
| 190 |
int mvinsertln(int y, int x) |
| 191 |
{ |
| 192 |
PDC_LOG(("mvinsertln() - called\n")); |
| 193 |
|
| 194 |
if (move(y, x) == ERR) |
| 195 |
return ERR; |
| 196 |
|
| 197 |
return winsertln(stdscr); |
| 198 |
} |
| 199 |
|
| 200 |
int mvwinsertln(WINDOW *win, int y, int x) |
| 201 |
{ |
| 202 |
PDC_LOG(("mvwinsertln() - called\n")); |
| 203 |
|
| 204 |
if (wmove(win, y, x) == ERR) |
| 205 |
return ERR; |
| 206 |
|
| 207 |
return winsertln(win); |
| 208 |
} |