diff options
Diffstat (limited to 'scripts/kconfig/libcurses/border.c')
-rw-r--r-- | scripts/kconfig/libcurses/border.c | 414 |
1 files changed, 414 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/border.c b/scripts/kconfig/libcurses/border.c new file mode 100644 index 000000000..302c46ea2 --- /dev/null +++ b/scripts/kconfig/libcurses/border.c | |||
@@ -0,0 +1,414 @@ | |||
1 | /* PDCurses */ | ||
2 | |||
3 | #include "curspriv.h" | ||
4 | |||
5 | /*man-start************************************************************** | ||
6 | |||
7 | border | ||
8 | ------ | ||
9 | |||
10 | ### Synopsis | ||
11 | |||
12 | int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, | ||
13 | chtype tr, chtype bl, chtype br); | ||
14 | int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, | ||
15 | chtype bs, chtype tl, chtype tr, chtype bl, chtype br); | ||
16 | int box(WINDOW *win, chtype verch, chtype horch); | ||
17 | int hline(chtype ch, int n); | ||
18 | int vline(chtype ch, int n); | ||
19 | int whline(WINDOW *win, chtype ch, int n); | ||
20 | int wvline(WINDOW *win, chtype ch, int n); | ||
21 | int mvhline(int y, int x, chtype ch, int n); | ||
22 | int mvvline(int y, int x, chtype ch, int n); | ||
23 | int mvwhline(WINDOW *win, int y, int x, chtype ch, int n); | ||
24 | int mvwvline(WINDOW *win, int y, int x, chtype ch, int n); | ||
25 | |||
26 | int border_set(const cchar_t *ls, const cchar_t *rs, | ||
27 | const cchar_t *ts, const cchar_t *bs, | ||
28 | const cchar_t *tl, const cchar_t *tr, | ||
29 | const cchar_t *bl, const cchar_t *br); | ||
30 | int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs, | ||
31 | const cchar_t *ts, const cchar_t *bs, | ||
32 | const cchar_t *tl, const cchar_t *tr, | ||
33 | const cchar_t *bl, const cchar_t *br); | ||
34 | int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch); | ||
35 | int hline_set(const cchar_t *wch, int n); | ||
36 | int vline_set(const cchar_t *wch, int n); | ||
37 | int whline_set(WINDOW *win, const cchar_t *wch, int n); | ||
38 | int wvline_set(WINDOW *win, const cchar_t *wch, int n); | ||
39 | int mvhline_set(int y, int x, const cchar_t *wch, int n); | ||
40 | int mvvline_set(int y, int x, const cchar_t *wch, int n); | ||
41 | int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n); | ||
42 | int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n); | ||
43 | |||
44 | ### Description | ||
45 | |||
46 | border(), wborder(), and box() draw a border around the edge of the | ||
47 | window. If any argument is zero, an appropriate default is used: | ||
48 | |||
49 | ls left side of border ACS_VLINE | ||
50 | rs right side of border ACS_VLINE | ||
51 | ts top side of border ACS_HLINE | ||
52 | bs bottom side of border ACS_HLINE | ||
53 | tl top left corner of border ACS_ULCORNER | ||
54 | tr top right corner of border ACS_URCORNER | ||
55 | bl bottom left corner of border ACS_LLCORNER | ||
56 | br bottom right corner of border ACS_LRCORNER | ||
57 | |||
58 | hline() and whline() draw a horizontal line, using ch, starting from | ||
59 | the current cursor position. The cursor position does not change. The | ||
60 | line is at most n characters long, or as many as will fit in the | ||
61 | window. | ||
62 | |||
63 | vline() and wvline() draw a vertical line, using ch, starting from | ||
64 | the current cursor position. The cursor position does not change. The | ||
65 | line is at most n characters long, or as many as will fit in the | ||
66 | window. | ||
67 | |||
68 | The *_set functions are the "wide-character" versions, taking | ||
69 | pointers to cchar_t instead of chtype. Note that in PDCurses, chtype | ||
70 | and cchar_t are the same. | ||
71 | |||
72 | ### Return Value | ||
73 | |||
74 | These functions return OK on success and ERR on error. | ||
75 | |||
76 | ### Portability | ||
77 | X/Open ncurses NetBSD | ||
78 | border Y Y Y | ||
79 | wborder Y Y Y | ||
80 | box Y Y Y | ||
81 | hline Y Y Y | ||
82 | vline Y Y Y | ||
83 | whline Y Y Y | ||
84 | wvline Y Y Y | ||
85 | mvhline Y Y Y | ||
86 | mvvline Y Y Y | ||
87 | mvwhline Y Y Y | ||
88 | mvwvline Y Y Y | ||
89 | border_set Y Y Y | ||
90 | wborder_set Y Y Y | ||
91 | box_set Y Y Y | ||
92 | hline_set Y Y Y | ||
93 | vline_set Y Y Y | ||
94 | whline_set Y Y Y | ||
95 | wvline_set Y Y Y | ||
96 | mvhline_set Y Y Y | ||
97 | mvvline_set Y Y Y | ||
98 | mvwhline_set Y Y Y | ||
99 | mvwvline_set Y Y Y | ||
100 | |||
101 | **man-end****************************************************************/ | ||
102 | |||
103 | /* _attr_passthru() -- Takes a single chtype 'ch' and checks if the | ||
104 | current attribute of window 'win', as set by wattrset(), and/or the | ||
105 | current background of win, as set by wbkgd(), should by combined with | ||
106 | it. Attributes set explicitly in ch take precedence. */ | ||
107 | |||
108 | static chtype _attr_passthru(WINDOW *win, chtype ch) | ||
109 | { | ||
110 | chtype attr; | ||
111 | |||
112 | /* If the incoming character doesn't have its own attribute, then | ||
113 | use the current attributes for the window. If the incoming | ||
114 | character has attributes, but not a color component, OR the | ||
115 | attributes to the current attributes for the window. If the | ||
116 | incoming character has a color component, use only the attributes | ||
117 | from the incoming character. */ | ||
118 | |||
119 | attr = ch & A_ATTRIBUTES; | ||
120 | if (!(attr & A_COLOR)) | ||
121 | attr |= win->_attrs; | ||
122 | |||
123 | /* wrs (4/10/93) -- Apply the same sort of logic for the window | ||
124 | background, in that it only takes precedence if other color | ||
125 | attributes are not there. */ | ||
126 | |||
127 | if (!(attr & A_COLOR)) | ||
128 | attr |= win->_bkgd & A_ATTRIBUTES; | ||
129 | else | ||
130 | attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR); | ||
131 | |||
132 | ch = (ch & A_CHARTEXT) | attr; | ||
133 | |||
134 | return ch; | ||
135 | } | ||
136 | |||
137 | int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, | ||
138 | chtype tl, chtype tr, chtype bl, chtype br) | ||
139 | { | ||
140 | int i, ymax, xmax; | ||
141 | |||
142 | PDC_LOG(("wborder() - called\n")); | ||
143 | |||
144 | if (!win) | ||
145 | return ERR; | ||
146 | |||
147 | ymax = win->_maxy - 1; | ||
148 | xmax = win->_maxx - 1; | ||
149 | |||
150 | ls = _attr_passthru(win, ls ? ls : ACS_VLINE); | ||
151 | rs = _attr_passthru(win, rs ? rs : ACS_VLINE); | ||
152 | ts = _attr_passthru(win, ts ? ts : ACS_HLINE); | ||
153 | bs = _attr_passthru(win, bs ? bs : ACS_HLINE); | ||
154 | tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER); | ||
155 | tr = _attr_passthru(win, tr ? tr : ACS_URCORNER); | ||
156 | bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER); | ||
157 | br = _attr_passthru(win, br ? br : ACS_LRCORNER); | ||
158 | |||
159 | for (i = 1; i < xmax; i++) | ||
160 | { | ||
161 | win->_y[0][i] = ts; | ||
162 | win->_y[ymax][i] = bs; | ||
163 | } | ||
164 | |||
165 | for (i = 1; i < ymax; i++) | ||
166 | { | ||
167 | win->_y[i][0] = ls; | ||
168 | win->_y[i][xmax] = rs; | ||
169 | } | ||
170 | |||
171 | win->_y[0][0] = tl; | ||
172 | win->_y[0][xmax] = tr; | ||
173 | win->_y[ymax][0] = bl; | ||
174 | win->_y[ymax][xmax] = br; | ||
175 | |||
176 | for (i = 0; i <= ymax; i++) | ||
177 | { | ||
178 | win->_firstch[i] = 0; | ||
179 | win->_lastch[i] = xmax; | ||
180 | } | ||
181 | |||
182 | PDC_sync(win); | ||
183 | |||
184 | return OK; | ||
185 | } | ||
186 | |||
187 | int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, | ||
188 | chtype tr, chtype bl, chtype br) | ||
189 | { | ||
190 | PDC_LOG(("border() - called\n")); | ||
191 | |||
192 | return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br); | ||
193 | } | ||
194 | |||
195 | int box(WINDOW *win, chtype verch, chtype horch) | ||
196 | { | ||
197 | PDC_LOG(("box() - called\n")); | ||
198 | |||
199 | return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0); | ||
200 | } | ||
201 | |||
202 | int whline(WINDOW *win, chtype ch, int n) | ||
203 | { | ||
204 | chtype *dest; | ||
205 | int startpos, endpos; | ||
206 | |||
207 | PDC_LOG(("whline() - called\n")); | ||
208 | |||
209 | if (!win || n < 1) | ||
210 | return ERR; | ||
211 | |||
212 | startpos = win->_curx; | ||
213 | endpos = min(startpos + n, win->_maxx) - 1; | ||
214 | dest = win->_y[win->_cury]; | ||
215 | ch = _attr_passthru(win, ch ? ch : ACS_HLINE); | ||
216 | |||
217 | for (n = startpos; n <= endpos; n++) | ||
218 | dest[n] = ch; | ||
219 | |||
220 | n = win->_cury; | ||
221 | |||
222 | if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE) | ||
223 | win->_firstch[n] = startpos; | ||
224 | |||
225 | if (endpos > win->_lastch[n]) | ||
226 | win->_lastch[n] = endpos; | ||
227 | |||
228 | PDC_sync(win); | ||
229 | |||
230 | return OK; | ||
231 | } | ||
232 | |||
233 | int hline(chtype ch, int n) | ||
234 | { | ||
235 | PDC_LOG(("hline() - called\n")); | ||
236 | |||
237 | return whline(stdscr, ch, n); | ||
238 | } | ||
239 | |||
240 | int mvhline(int y, int x, chtype ch, int n) | ||
241 | { | ||
242 | PDC_LOG(("mvhline() - called\n")); | ||
243 | |||
244 | if (move(y, x) == ERR) | ||
245 | return ERR; | ||
246 | |||
247 | return whline(stdscr, ch, n); | ||
248 | } | ||
249 | |||
250 | int mvwhline(WINDOW *win, int y, int x, chtype ch, int n) | ||
251 | { | ||
252 | PDC_LOG(("mvwhline() - called\n")); | ||
253 | |||
254 | if (wmove(win, y, x) == ERR) | ||
255 | return ERR; | ||
256 | |||
257 | return whline(win, ch, n); | ||
258 | } | ||
259 | |||
260 | int wvline(WINDOW *win, chtype ch, int n) | ||
261 | { | ||
262 | int endpos, x; | ||
263 | |||
264 | PDC_LOG(("wvline() - called\n")); | ||
265 | |||
266 | if (!win || n < 1) | ||
267 | return ERR; | ||
268 | |||
269 | endpos = min(win->_cury + n, win->_maxy); | ||
270 | x = win->_curx; | ||
271 | |||
272 | ch = _attr_passthru(win, ch ? ch : ACS_VLINE); | ||
273 | |||
274 | for (n = win->_cury; n < endpos; n++) | ||
275 | { | ||
276 | win->_y[n][x] = ch; | ||
277 | |||
278 | if (x < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE) | ||
279 | win->_firstch[n] = x; | ||
280 | |||
281 | if (x > win->_lastch[n]) | ||
282 | win->_lastch[n] = x; | ||
283 | } | ||
284 | |||
285 | PDC_sync(win); | ||
286 | |||
287 | return OK; | ||
288 | } | ||
289 | |||
290 | int vline(chtype ch, int n) | ||
291 | { | ||
292 | PDC_LOG(("vline() - called\n")); | ||
293 | |||
294 | return wvline(stdscr, ch, n); | ||
295 | } | ||
296 | |||
297 | int mvvline(int y, int x, chtype ch, int n) | ||
298 | { | ||
299 | PDC_LOG(("mvvline() - called\n")); | ||
300 | |||
301 | if (move(y, x) == ERR) | ||
302 | return ERR; | ||
303 | |||
304 | return wvline(stdscr, ch, n); | ||
305 | } | ||
306 | |||
307 | int mvwvline(WINDOW *win, int y, int x, chtype ch, int n) | ||
308 | { | ||
309 | PDC_LOG(("mvwvline() - called\n")); | ||
310 | |||
311 | if (wmove(win, y, x) == ERR) | ||
312 | return ERR; | ||
313 | |||
314 | return wvline(win, ch, n); | ||
315 | } | ||
316 | |||
317 | #ifdef PDC_WIDE | ||
318 | int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs, | ||
319 | const cchar_t *ts, const cchar_t *bs, const cchar_t *tl, | ||
320 | const cchar_t *tr, const cchar_t *bl, const cchar_t *br) | ||
321 | { | ||
322 | PDC_LOG(("wborder_set() - called\n")); | ||
323 | |||
324 | return wborder(win, ls ? *ls : 0, rs ? *rs : 0, ts ? *ts : 0, | ||
325 | bs ? *bs : 0, tl ? *tl : 0, tr ? *tr : 0, | ||
326 | bl ? *bl : 0, br ? *br : 0); | ||
327 | } | ||
328 | |||
329 | int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts, | ||
330 | const cchar_t *bs, const cchar_t *tl, const cchar_t *tr, | ||
331 | const cchar_t *bl, const cchar_t *br) | ||
332 | { | ||
333 | PDC_LOG(("border_set() - called\n")); | ||
334 | |||
335 | return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br); | ||
336 | } | ||
337 | |||
338 | int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch) | ||
339 | { | ||
340 | PDC_LOG(("box_set() - called\n")); | ||
341 | |||
342 | return wborder_set(win, verch, verch, horch, horch, | ||
343 | (const cchar_t *)NULL, (const cchar_t *)NULL, | ||
344 | (const cchar_t *)NULL, (const cchar_t *)NULL); | ||
345 | } | ||
346 | |||
347 | int whline_set(WINDOW *win, const cchar_t *wch, int n) | ||
348 | { | ||
349 | PDC_LOG(("whline_set() - called\n")); | ||
350 | |||
351 | return wch ? whline(win, *wch, n) : ERR; | ||
352 | } | ||
353 | |||
354 | int hline_set(const cchar_t *wch, int n) | ||
355 | { | ||
356 | PDC_LOG(("hline_set() - called\n")); | ||
357 | |||
358 | return whline_set(stdscr, wch, n); | ||
359 | } | ||
360 | |||
361 | int mvhline_set(int y, int x, const cchar_t *wch, int n) | ||
362 | { | ||
363 | PDC_LOG(("mvhline_set() - called\n")); | ||
364 | |||
365 | if (move(y, x) == ERR) | ||
366 | return ERR; | ||
367 | |||
368 | return whline_set(stdscr, wch, n); | ||
369 | } | ||
370 | |||
371 | int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) | ||
372 | { | ||
373 | PDC_LOG(("mvwhline_set() - called\n")); | ||
374 | |||
375 | if (wmove(win, y, x) == ERR) | ||
376 | return ERR; | ||
377 | |||
378 | return whline_set(win, wch, n); | ||
379 | } | ||
380 | |||
381 | int wvline_set(WINDOW *win, const cchar_t *wch, int n) | ||
382 | { | ||
383 | PDC_LOG(("wvline_set() - called\n")); | ||
384 | |||
385 | return wch ? wvline(win, *wch, n) : ERR; | ||
386 | } | ||
387 | |||
388 | int vline_set(const cchar_t *wch, int n) | ||
389 | { | ||
390 | PDC_LOG(("vline_set() - called\n")); | ||
391 | |||
392 | return wvline_set(stdscr, wch, n); | ||
393 | } | ||
394 | |||
395 | int mvvline_set(int y, int x, const cchar_t *wch, int n) | ||
396 | { | ||
397 | PDC_LOG(("mvvline_set() - called\n")); | ||
398 | |||
399 | if (move(y, x) == ERR) | ||
400 | return ERR; | ||
401 | |||
402 | return wvline_set(stdscr, wch, n); | ||
403 | } | ||
404 | |||
405 | int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n) | ||
406 | { | ||
407 | PDC_LOG(("mvwvline_set() - called\n")); | ||
408 | |||
409 | if (wmove(win, y, x) == ERR) | ||
410 | return ERR; | ||
411 | |||
412 | return wvline_set(win, wch, n); | ||
413 | } | ||
414 | #endif | ||