aboutsummaryrefslogtreecommitdiff
path: root/scripts/kconfig/libcurses/pad.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/libcurses/pad.c')
-rw-r--r--scripts/kconfig/libcurses/pad.c66
1 files changed, 31 insertions, 35 deletions
diff --git a/scripts/kconfig/libcurses/pad.c b/scripts/kconfig/libcurses/pad.c
index 5003ecbb4..3dfdfe5d6 100644
--- a/scripts/kconfig/libcurses/pad.c
+++ b/scripts/kconfig/libcurses/pad.c
@@ -75,11 +75,6 @@ pad
75 75
76#include <string.h> 76#include <string.h>
77 77
78/* save values for pechochar() */
79
80static int save_pminrow, save_pmincol;
81static int save_sminrow, save_smincol, save_smaxrow, save_smaxcol;
82
83WINDOW *newpad(int nlines, int ncols) 78WINDOW *newpad(int nlines, int ncols)
84{ 79{
85 WINDOW *win; 80 WINDOW *win;
@@ -96,16 +91,12 @@ WINDOW *newpad(int nlines, int ncols)
96 werase(win); 91 werase(win);
97 92
98 win->_flags = _PAD; 93 win->_flags = _PAD;
99 94 win->_pad._pad_y = 0;
100 /* save default values in case pechochar() is the first call to 95 win->_pad._pad_x = 0;
101 prefresh(). */ 96 win->_pad._pad_top = 0;
102 97 win->_pad._pad_left = 0;
103 save_pminrow = 0; 98 win->_pad._pad_bottom = min(LINES, nlines) - 1;
104 save_pmincol = 0; 99 win->_pad._pad_right = min(COLS, ncols) - 1;
105 save_sminrow = 0;
106 save_smincol = 0;
107 save_smaxrow = min(LINES, nlines) - 1;
108 save_smaxcol = min(COLS, ncols) - 1;
109 100
110 return win; 101 return win;
111} 102}
@@ -151,16 +142,12 @@ WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
151 win->_y[i] = orig->_y[begy + i] + begx; 142 win->_y[i] = orig->_y[begy + i] + begx;
152 143
153 win->_flags = _SUBPAD; 144 win->_flags = _SUBPAD;
154 145 win->_pad._pad_y = 0;
155 /* save default values in case pechochar() is the first call 146 win->_pad._pad_x = 0;
156 to prefresh(). */ 147 win->_pad._pad_top = 0;
157 148 win->_pad._pad_left = 0;
158 save_pminrow = 0; 149 win->_pad._pad_bottom = min(LINES, nlines) - 1;
159 save_pmincol = 0; 150 win->_pad._pad_right = min(COLS, ncols) - 1;
160 save_sminrow = 0;
161 save_smincol = 0;
162 save_smaxrow = min(LINES, nlines) - 1;
163 save_smaxcol = min(COLS, ncols) - 1;
164 151
165 return win; 152 return win;
166} 153}
@@ -179,14 +166,11 @@ int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2)
179int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) 166int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
180{ 167{
181 int num_cols; 168 int num_cols;
182 int sline = sy1; 169 int sline;
183 int pline = py; 170 int pline;
184 171
185 PDC_LOG(("pnoutrefresh() - called\n")); 172 PDC_LOG(("pnoutrefresh() - called\n"));
186 173
187 if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sx2 >= COLS))
188 return ERR;
189
190 if (py < 0) 174 if (py < 0)
191 py = 0; 175 py = 0;
192 if (px < 0) 176 if (px < 0)
@@ -196,9 +180,14 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
196 if (sx1 < 0) 180 if (sx1 < 0)
197 sx1 = 0; 181 sx1 = 0;
198 182
199 if (sy2 < sy1 || sx2 < sx1) 183 if ((!w || !(w->_flags & (_PAD|_SUBPAD)) ||
184 (sy2 >= LINES) || (sx2 >= COLS)) ||
185 (sy2 < sy1) || (sx2 < sx1))
200 return ERR; 186 return ERR;
201 187
188 sline = sy1;
189 pline = py;
190
202 num_cols = min((sx2 - sx1 + 1), (w->_maxx - px)); 191 num_cols = min((sx2 - sx1 + 1), (w->_maxx - px));
203 192
204 while (sline <= sy2) 193 while (sline <= sy2)
@@ -240,6 +229,13 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
240 curscr->_curx = (w->_curx - px) + sx1; 229 curscr->_curx = (w->_curx - px) + sx1;
241 } 230 }
242 231
232 w->_pad._pad_y = py;
233 w->_pad._pad_x = px;
234 w->_pad._pad_top = sy1;
235 w->_pad._pad_left = sx1;
236 w->_pad._pad_bottom = sy2;
237 w->_pad._pad_right = sx2;
238
243 return OK; 239 return OK;
244} 240}
245 241
@@ -250,8 +246,8 @@ int pechochar(WINDOW *pad, chtype ch)
250 if (waddch(pad, ch) == ERR) 246 if (waddch(pad, ch) == ERR)
251 return ERR; 247 return ERR;
252 248
253 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow, 249 return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top,
254 save_smincol, save_smaxrow, save_smaxcol); 250 pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right);
255} 251}
256 252
257#ifdef PDC_WIDE 253#ifdef PDC_WIDE
@@ -262,8 +258,8 @@ int pecho_wchar(WINDOW *pad, const cchar_t *wch)
262 if (!wch || (waddch(pad, *wch) == ERR)) 258 if (!wch || (waddch(pad, *wch) == ERR))
263 return ERR; 259 return ERR;
264 260
265 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow, 261 return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top,
266 save_smincol, save_smaxrow, save_smaxcol); 262 pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right);
267} 263}
268#endif 264#endif
269 265