]> ncurses.scripts.mit.edu Git - ncurses.git/blob - c++/cursesw.h
ncurses 6.1 - patch 20190518
[ncurses.git] / c++ / cursesw.h
1 // * This makes emacs happy -*-Mode: C++;-*-
2 // vile:cppmode
3 /****************************************************************************
4  * Copyright (c) 1998-2014,2017 Free Software Foundation, Inc.              *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30
31 #ifndef NCURSES_CURSESW_H_incl
32 #define NCURSES_CURSESW_H_incl 1
33
34 // $Id: cursesw.h,v 1.53 2017/11/21 00:37:23 tom Exp $
35
36 extern "C" {
37 #  include   <curses.h>
38 }
39
40 #include <etip.h>
41
42 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
43    Undefine it here, because NCursesWindow uses lines as a method.  */
44 #undef lines
45
46 /* "Convert" macros to inlines. We'll define it as another symbol to avoid
47  * conflict with library symbols.
48  */
49 #undef UNDEF
50 #define UNDEF(name) CUR_ ##name
51
52 #ifdef addch
53 inline int UNDEF(addch)(chtype ch)  { return addch(ch); }
54 #undef addch
55 #define addch UNDEF(addch)
56 #endif
57
58 #ifdef addchstr
59 inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
60 #undef addchstr
61 #define addchstr UNDEF(addchstr)
62 #endif
63
64 #ifdef addnstr
65 inline int UNDEF(addnstr)(const char *str, int n)
66 { return addnstr(str, n); }
67 #undef addnstr
68 #define addnstr UNDEF(addnstr)
69 #endif
70
71 #ifdef addstr
72 inline int UNDEF(addstr)(const char * str)  { return addstr(str); }
73 #undef addstr
74 #define addstr UNDEF(addstr)
75 #endif
76
77 #ifdef attroff
78 inline int UNDEF(attroff)(chtype at) { return attroff(at); }
79 #undef attroff
80 #define attroff UNDEF(attroff)
81 #endif
82
83 #ifdef attron
84 inline int UNDEF(attron)(chtype at) { return attron(at); }
85 #undef attron
86 #define attron UNDEF(attron)
87 #endif
88
89 #ifdef attrset
90 inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
91 #undef attrset
92 #define attrset UNDEF(attrset)
93 #endif
94
95 #ifdef bkgd
96 inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
97 #undef bkgd
98 #define bkgd UNDEF(bkgd)
99 #endif
100
101 #ifdef bkgdset
102 inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
103 #undef bkgdset
104 #define bkgdset UNDEF(bkgdset)
105 #endif
106
107 #ifdef border
108 inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
109 { return border(ls, rs, ts, bs, tl, tr, bl, br); }
110 #undef border
111 #define border UNDEF(border)
112 #endif
113
114 #ifdef box
115 inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
116 #undef box
117 #define box UNDEF(box)
118 #endif
119
120 #ifdef chgat
121 inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
122   return chgat(n, attr, color, opts); }
123 #undef chgat
124 #define chgat UNDEF(chgat)
125 #endif
126
127 #ifdef clear
128 inline int UNDEF(clear)()  { return clear(); }
129 #undef clear
130 #define clear UNDEF(clear)
131 #endif
132
133 #ifdef clearok
134 inline int UNDEF(clearok)(WINDOW* win, bool bf)  { return clearok(win, bf); }
135 #undef clearok
136 #define clearok UNDEF(clearok)
137 #else
138 extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
139 #endif
140
141 #ifdef clrtobot
142 inline int UNDEF(clrtobot)()  { return clrtobot(); }
143 #undef clrtobot
144 #define clrtobot UNDEF(clrtobot)
145 #endif
146
147 #ifdef clrtoeol
148 inline int UNDEF(clrtoeol)()  { return clrtoeol(); }
149 #undef clrtoeol
150 #define clrtoeol UNDEF(clrtoeol)
151 #endif
152
153 #ifdef color_set
154 inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
155 #undef color_set
156 #define color_set UNDEF(color_set)
157 #endif
158
159 #ifdef crmode
160 inline int UNDEF(crmode)(void) { return crmode(); }
161 #undef crmode
162 #define crmode UNDEF(crmode)
163 #endif
164
165 #ifdef delch
166 inline int UNDEF(delch)()  { return delch(); }
167 #undef delch
168 #define delch UNDEF(delch)
169 #endif
170
171 #ifdef deleteln
172 inline int UNDEF(deleteln)()  { return deleteln(); }
173 #undef deleteln
174 #define deleteln UNDEF(deleteln)
175 #endif
176
177 #ifdef echochar
178 inline int UNDEF(echochar)(chtype ch)  { return echochar(ch); }
179 #undef echochar
180 #define echochar UNDEF(echochar)
181 #endif
182
183 #ifdef erase
184 inline int UNDEF(erase)()  { return erase(); }
185 #undef erase
186 #define erase UNDEF(erase)
187 #endif
188
189 #ifdef fixterm
190 inline int UNDEF(fixterm)(void) { return fixterm(); }
191 #undef fixterm
192 #define fixterm UNDEF(fixterm)
193 #endif
194
195 #ifdef flushok
196 inline int UNDEF(flushok)(WINDOW* _win, bool _bf)  {
197   return flushok(_win, _bf); }
198 #undef flushok
199 #define flushok UNDEF(flushok)
200 #else
201 #define _no_flushok
202 #endif
203
204 #ifdef getattrs
205 inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
206 #undef getattrs
207 #define getattrs UNDEF(getattrs)
208 #endif
209
210 #ifdef getbegyx
211 inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
212 #undef getbegyx
213 #define getbegyx UNDEF(getbegyx)
214 #endif
215
216 #ifdef getbkgd
217 inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
218 #undef getbkgd
219 #define getbkgd UNDEF(getbkgd)
220 #endif
221
222 #ifdef getch
223 inline int UNDEF(getch)()  { return getch(); }
224 #undef getch
225 #define getch UNDEF(getch)
226 #endif
227
228 #ifdef getmaxyx
229 inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
230 #undef getmaxyx
231 #define getmaxyx UNDEF(getmaxyx)
232 #endif
233
234 #ifdef getnstr
235 inline int UNDEF(getnstr)(char *_str, int n)  { return getnstr(_str, n); }
236 #undef getnstr
237 #define getnstr UNDEF(getnstr)
238 #endif
239
240 #ifdef getparyx
241 inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
242 #undef getparyx
243 #define getparyx UNDEF(getparyx)
244 #endif
245
246 #ifdef getstr
247 inline int UNDEF(getstr)(char *_str)  { return getstr(_str); }
248 #undef getstr
249 #define getstr UNDEF(getstr)
250 #endif
251
252 #ifdef getyx
253 inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
254   getyx(win, y, x); }
255 #undef getyx
256 #define getyx UNDEF(getyx)
257 #endif
258
259 #ifdef hline
260 inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
261 #undef hline
262 #define hline UNDEF(hline)
263 #endif
264
265 #ifdef inch
266 inline chtype UNDEF(inch)()  { return inch(); }
267 #undef inch
268 #define inch UNDEF(inch)
269 #endif
270
271 #ifdef inchstr
272 inline int UNDEF(inchstr)(chtype *str)  { return inchstr(str); }
273 #undef inchstr
274 #define inchstr UNDEF(inchstr)
275 #endif
276
277 #ifdef innstr
278 inline int UNDEF(innstr)(char *_str, int n)  { return innstr(_str, n); }
279 #undef innstr
280 #define innstr UNDEF(innstr)
281 #endif
282
283 #ifdef insch
284 inline int UNDEF(insch)(chtype c)  { return insch(c); }
285 #undef insch
286 #define insch UNDEF(insch)
287 #endif
288
289 #ifdef insdelln
290 inline int UNDEF(insdelln)(int n)  { return insdelln(n); }
291 #undef insdelln
292 #define insdelln UNDEF(insdelln)
293 #endif
294
295 #ifdef insertln
296 inline int UNDEF(insertln)()  { return insertln(); }
297 #undef insertln
298 #define insertln UNDEF(insertln)
299 #endif
300
301 #ifdef insnstr
302 inline int UNDEF(insnstr)(const char *_str, int n)  {
303   return insnstr(_str, n); }
304 #undef insnstr
305 #define insnstr UNDEF(insnstr)
306 #endif
307
308 #ifdef insstr
309 inline int UNDEF(insstr)(const char *_str)  {
310   return insstr(_str); }
311 #undef insstr
312 #define insstr UNDEF(insstr)
313 #endif
314
315 #ifdef instr
316 inline int UNDEF(instr)(char *_str)  { return instr(_str); }
317 #undef instr
318 #define instr UNDEF(instr)
319 #endif
320
321 #ifdef intrflush
322 inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
323 #undef intrflush
324 #define intrflush UNDEF(intrflush)
325 #endif
326
327 #ifdef is_linetouched
328 inline int UNDEF(is_linetouched)(WINDOW *w, int l)  { return is_linetouched(w,l); }
329 #undef is_linetouched
330 #define is_linetouched UNDEF(is_linetouched)
331 #endif
332
333 #ifdef leaveok
334 inline int UNDEF(leaveok)(WINDOW* win, bool bf)  { return leaveok(win, bf); }
335 #undef leaveok
336 #define leaveok UNDEF(leaveok)
337 #else
338 extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
339 #endif
340
341 #ifdef move
342 inline int UNDEF(move)(int x, int y)  { return move(x, y); }
343 #undef move
344 #define move UNDEF(move)
345 #endif
346
347 #ifdef mvaddch
348 inline int UNDEF(mvaddch)(int y, int x, chtype ch)
349 { return mvaddch(y, x, ch); }
350 #undef mvaddch
351 #define mvaddch UNDEF(mvaddch)
352 #endif
353
354 #ifdef mvaddnstr
355 inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
356 { return mvaddnstr(y, x, str, n); }
357 #undef mvaddnstr
358 #define mvaddnstr UNDEF(mvaddnstr)
359 #endif
360
361 #ifdef mvaddstr
362 inline int UNDEF(mvaddstr)(int y, int x, const char * str)
363 { return mvaddstr(y, x, str); }
364 #undef mvaddstr
365 #define mvaddstr UNDEF(mvaddstr)
366 #endif
367
368 #ifdef mvchgat
369 inline int UNDEF(mvchgat)(int y, int x, int n,
370                           attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
371   return mvchgat(y, x, n, attr, color, opts); }
372 #undef mvchgat
373 #define mvchgat UNDEF(mvchgat)
374 #endif
375
376 #ifdef mvdelch
377 inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
378 #undef mvdelch
379 #define mvdelch UNDEF(mvdelch)
380 #endif
381
382 #ifdef mvgetch
383 inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
384 #undef mvgetch
385 #define mvgetch UNDEF(mvgetch)
386 #endif
387
388 #ifdef mvgetnstr
389 inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
390   return mvgetnstr(y, x, str, n);}
391 #undef mvgetnstr
392 #define mvgetnstr UNDEF(mvgetnstr)
393 #endif
394
395 #ifdef mvgetstr
396 inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
397 #undef mvgetstr
398 #define mvgetstr UNDEF(mvgetstr)
399 #endif
400
401 #ifdef mvinch
402 inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
403 #undef mvinch
404 #define mvinch UNDEF(mvinch)
405 #endif
406
407 #ifdef mvinnstr
408 inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
409   return mvinnstr(y, x, _str, n); }
410 #undef mvinnstr
411 #define mvinnstr UNDEF(mvinnstr)
412 #endif
413
414 #ifdef mvinsch
415 inline int UNDEF(mvinsch)(int y, int x, chtype c)
416 { return mvinsch(y, x, c); }
417 #undef mvinsch
418 #define mvinsch UNDEF(mvinsch)
419 #endif
420
421 #ifdef mvinsnstr
422 inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
423   return mvinsnstr(y, x, _str, n); }
424 #undef mvinsnstr
425 #define mvinsnstr UNDEF(mvinsnstr)
426 #endif
427
428 #ifdef mvinsstr
429 inline int UNDEF(mvinsstr)(int y, int x, const char *_str)  {
430   return mvinsstr(y, x, _str); }
431 #undef mvinsstr
432 #define mvinsstr UNDEF(mvinsstr)
433 #endif
434
435 #ifdef mvwaddch
436 inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
437 { return mvwaddch(win, y, x, ch); }
438 #undef mvwaddch
439 #define mvwaddch UNDEF(mvwaddch)
440 #endif
441
442 #ifdef mvwaddchnstr
443 inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
444 { return mvwaddchnstr(win, y, x, str, n); }
445 #undef mvwaddchnstr
446 #define mvwaddchnstr UNDEF(mvwaddchnstr)
447 #endif
448
449 #ifdef mvwaddchstr
450 inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
451 { return mvwaddchstr(win, y, x, str); }
452 #undef mvwaddchstr
453 #define mvwaddchstr UNDEF(mvwaddchstr)
454 #endif
455
456 #ifdef mvwaddnstr
457 inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
458 { return mvwaddnstr(win, y, x, str, n); }
459 #undef mvwaddnstr
460 #define mvwaddnstr UNDEF(mvwaddnstr)
461 #endif
462
463 #ifdef mvwaddstr
464 inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
465 { return mvwaddstr(win, y, x, str); }
466 #undef mvwaddstr
467 #define mvwaddstr UNDEF(mvwaddstr)
468 #endif
469
470 #ifdef mvwchgat
471 inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
472                            attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
473   return mvwchgat(win, y, x, n, attr, color, opts); }
474 #undef mvwchgat
475 #define mvwchgat UNDEF(mvwchgat)
476 #endif
477
478 #ifdef mvwdelch
479 inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
480 { return mvwdelch(win, y, x); }
481 #undef mvwdelch
482 #define mvwdelch UNDEF(mvwdelch)
483 #endif
484
485 #ifdef mvwgetch
486 inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
487 #undef mvwgetch
488 #define mvwgetch UNDEF(mvwgetch)
489 #endif
490
491 #ifdef mvwgetnstr
492 inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
493 {return mvwgetnstr(win, y, x, str, n);}
494 #undef mvwgetnstr
495 #define mvwgetnstr UNDEF(mvwgetnstr)
496 #endif
497
498 #ifdef mvwgetstr
499 inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
500 {return mvwgetstr(win, y, x, str);}
501 #undef mvwgetstr
502 #define mvwgetstr UNDEF(mvwgetstr)
503 #endif
504
505 #ifdef mvwhline
506 inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
507   return mvwhline(win, y, x, c, n); }
508 #undef mvwhline
509 #define mvwhline UNDEF(mvwhline)
510 #endif
511
512 #ifdef mvwinch
513 inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
514   return mvwinch(win, y, x);}
515 #undef mvwinch
516 #define mvwinch UNDEF(mvwinch)
517 #endif
518
519 #ifdef mvwinchnstr
520 inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n)  { return mvwinchnstr(win, y, x, str, n); }
521 #undef mvwinchnstr
522 #define mvwinchnstr UNDEF(mvwinchnstr)
523 #endif
524
525 #ifdef mvwinchstr
526 inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str)  { return mvwinchstr(win, y, x, str); }
527 #undef mvwinchstr
528 #define mvwinchstr UNDEF(mvwinchstr)
529 #endif
530
531 #ifdef mvwinnstr
532 inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
533   return mvwinnstr(win, y, x, _str, n); }
534 #undef mvwinnstr
535 #define mvwinnstr UNDEF(mvwinnstr)
536 #endif
537
538 #ifdef mvwinsch
539 inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
540 { return mvwinsch(win, y, x, c); }
541 #undef mvwinsch
542 #define mvwinsch UNDEF(mvwinsch)
543 #endif
544
545 #ifdef mvwinsnstr
546 inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
547   return mvwinsnstr(w, y, x, _str, n); }
548 #undef mvwinsnstr
549 #define mvwinsnstr UNDEF(mvwinsnstr)
550 #endif
551
552 #ifdef mvwinsstr
553 inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x,  const char *_str)  {
554   return mvwinsstr(w, y, x, _str); }
555 #undef mvwinsstr
556 #define mvwinsstr UNDEF(mvwinsstr)
557 #endif
558
559 #ifdef mvwvline
560 inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
561   return mvwvline(win, y, x, c, n); }
562 #undef mvwvline
563 #define mvwvline UNDEF(mvwvline)
564 #endif
565
566 #ifdef napms
567 inline void UNDEF(napms)(unsigned long x) { napms(x); }
568 #undef napms
569 #define napms UNDEF(napms)
570 #endif
571
572 #ifdef nocrmode
573 inline int UNDEF(nocrmode)(void) { return nocrmode(); }
574 #undef nocrmode
575 #define nocrmode UNDEF(nocrmode)
576 #endif
577
578 #ifdef nodelay
579 inline void UNDEF(nodelay)() { nodelay(); }
580 #undef nodelay
581 #define nodelay UNDEF(nodelay)
582 #endif
583
584 #ifdef redrawwin
585 inline int UNDEF(redrawwin)(WINDOW *win)  { return redrawwin(win); }
586 #undef redrawwin
587 #define redrawwin UNDEF(redrawwin)
588 #endif
589
590 #ifdef refresh
591 inline int UNDEF(refresh)()  { return refresh(); }
592 #undef refresh
593 #define refresh UNDEF(refresh)
594 #endif
595
596 #ifdef resetterm
597 inline int UNDEF(resetterm)(void) { return resetterm(); }
598 #undef resetterm
599 #define resetterm UNDEF(resetterm)
600 #endif
601
602 #ifdef saveterm
603 inline int UNDEF(saveterm)(void) { return saveterm(); }
604 #undef saveterm
605 #define saveterm UNDEF(saveterm)
606 #endif
607
608 #ifdef scrl
609 inline int UNDEF(scrl)(int l) { return scrl(l); }
610 #undef scrl
611 #define scrl UNDEF(scrl)
612 #endif
613
614 #ifdef scroll
615 inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
616 #undef scroll
617 #define scroll UNDEF(scroll)
618 #endif
619
620 #ifdef scrollok
621 inline int UNDEF(scrollok)(WINDOW* win, bool bf)  { return scrollok(win, bf); }
622 #undef scrollok
623 #define scrollok UNDEF(scrollok)
624 #else
625 #if     defined(__NCURSES_H)
626 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
627 #else
628 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
629 #endif
630 #endif
631
632 #ifdef setscrreg
633 inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
634 #undef setscrreg
635 #define setscrreg UNDEF(setscrreg)
636 #endif
637
638 #ifdef standend
639 inline int UNDEF(standend)()  { return standend(); }
640 #undef standend
641 #define standend UNDEF(standend)
642 #endif
643
644 #ifdef standout
645 inline int UNDEF(standout)()  { return standout(); }
646 #undef standout
647 #define standout UNDEF(standout)
648 #endif
649
650 #ifdef subpad
651 inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
652 { return derwin(p, l, c, y, x); }
653 #undef subpad
654 #define subpad UNDEF(subpad)
655 #endif
656
657 #ifdef timeout
658 inline void UNDEF(timeout)(int delay) { timeout(delay); }
659 #undef timeout
660 #define timeout UNDEF(timeout)
661 #endif
662
663 #ifdef touchline
664 inline int UNDEF(touchline)(WINDOW *win, int s, int c)
665 { return touchline(win, s, c); }
666 #undef touchline
667 #define touchline UNDEF(touchline)
668 #endif
669
670 #ifdef touchwin
671 inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
672 #undef touchwin
673 #define touchwin UNDEF(touchwin)
674 #endif
675
676 #ifdef untouchwin
677 inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
678 #undef untouchwin
679 #define untouchwin UNDEF(untouchwin)
680 #endif
681
682 #ifdef vline
683 inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
684 #undef vline
685 #define vline UNDEF(vline)
686 #endif
687
688 #ifdef waddchstr
689 inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
690 #undef waddchstr
691 #define waddchstr UNDEF(waddchstr)
692 #endif
693
694 #ifdef waddstr
695 inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
696 #undef waddstr
697 #define waddstr UNDEF(waddstr)
698 #endif
699
700 #ifdef wattroff
701 inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
702 #undef wattroff
703 #define wattroff UNDEF(wattroff)
704 #endif
705
706 #ifdef wattrset
707 inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
708 #undef wattrset
709 #define wattrset UNDEF(wattrset)
710 #endif
711
712 #ifdef winch
713 inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
714 #undef winch
715 #define winch UNDEF(winch)
716 #endif
717
718 #ifdef winchnstr
719 inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n)  { return winchnstr(win, str, n); }
720 #undef winchnstr
721 #define winchnstr UNDEF(winchnstr)
722 #endif
723
724 #ifdef winchstr
725 inline int UNDEF(winchstr)(WINDOW *win, chtype *str)  { return winchstr(win, str); }
726 #undef winchstr
727 #define winchstr UNDEF(winchstr)
728 #endif
729
730 #ifdef winsstr
731 inline int UNDEF(winsstr)(WINDOW *w, const char *_str)  {
732   return winsstr(w, _str); }
733 #undef winsstr
734 #define winsstr UNDEF(winsstr)
735 #endif
736
737 #ifdef wstandend
738 inline int UNDEF(wstandend)(WINDOW *win)  { return wstandend(win); }
739 #undef wstandend
740 #define wstandend UNDEF(wstandend)
741 #endif
742
743 #ifdef wstandout
744 inline int UNDEF(wstandout)(WINDOW *win)  { return wstandout(win); }
745 #undef wstandout
746 #define wstandout UNDEF(wstandout)
747 #endif
748
749 /*
750  *
751  * C++ class for windows.
752  *
753  */
754
755 extern "C" int     _nc_ripoffline(int, int (*init)(WINDOW*, int));
756 extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
757 extern "C" int     _nc_has_mouse(void);
758
759 class NCURSES_IMPEXP NCursesWindow
760 {
761   friend class NCursesMenu;
762   friend class NCursesForm;
763
764 private:
765   static bool    b_initialized;
766   static void    initialize();
767   void           constructing();
768   friend int     _nc_xx_ripoff_init(WINDOW *, int);
769
770   void           set_keyboard();
771
772   NCURSES_COLOR_T getcolor(int getback) const;
773   NCURSES_PAIRS_T getPair() const;
774
775   static int     setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
776   static int     colorInitialized;
777
778   // This private constructor is only used during the initialization
779   // of windows generated by ripoffline() calls.
780   NCursesWindow(WINDOW* win, int ncols);
781
782 protected:
783   virtual void   err_handler(const char *) const THROWS(NCursesException);
784   // Signal an error with the given message text.
785
786   static long count;        // count of all active windows:
787   //   We rely on the c++ promise that
788   //   all otherwise uninitialized
789   //   static class vars are set to 0
790
791   WINDOW*        w;                // the curses WINDOW
792
793   bool           alloced;          // TRUE if we own the WINDOW
794
795   NCursesWindow* par;              // parent, if subwindow
796   NCursesWindow* subwins;          // head of subwindows list
797   NCursesWindow* sib;              // next subwindow of parent
798
799   void           kill_subwindows(); // disable all subwindows
800   // Destroy all subwindows.
801
802   /* Only for use by derived classes. They are then in charge to
803      fill the member variables correctly. */
804   NCursesWindow();
805
806 public:
807   NCursesWindow(WINDOW* window);   // useful only for stdscr
808
809   NCursesWindow(int nlines,        // number of lines
810                 int ncols,         // number of columns
811                 int begin_y,       // line origin
812                 int begin_x);      // col origin
813
814   NCursesWindow(NCursesWindow& par,// parent window
815                 int nlines,        // number of lines
816                 int ncols,         // number of columns
817                 int begin_y,       // absolute or relative
818                 int begin_x,       //   origins:
819                 char absrel = 'a');// if `a', begin_y & begin_x are
820   // absolute screen pos, else if `r', they are relative to par origin
821
822   NCursesWindow(NCursesWindow& par,// parent window
823                 bool do_box = TRUE);
824   // this is the very common case that we want to create the subwindow that
825   // is two lines and two columns smaller and begins at (1,1).
826   // We may automatically request the box around it.
827
828   NCursesWindow& operator=(const NCursesWindow& rhs)
829   {
830     if (this != &rhs)
831       *this = rhs;
832     return *this;
833   }
834
835   NCursesWindow(const NCursesWindow& rhs)
836     : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
837   {
838   }
839
840   virtual ~NCursesWindow();
841
842   NCursesWindow Clone();
843   // Make an exact copy of the window.
844
845   // Initialization.
846   static void    useColors(void);
847   // Call this routine very early if you want to have colors.
848
849   static int ripoffline(int ripoff_lines,
850                         int (*init)(NCursesWindow& win));
851   // This function is used to generate a window of ripped-of lines.
852   // If the argument is positive, lines are removed from the top, if it
853   // is negative lines are removed from the bottom. This enhances the
854   // lowlevel ripoffline() function because it uses the internal
855   // implementation that allows to remove more than just a single line.
856   // This function must be called before any other ncurses function. The
857   // creation of the window is deferred until ncurses gets initialized.
858   // The initialization function is then called.
859
860   // -------------------------------------------------------------------------
861   // terminal status
862   // -------------------------------------------------------------------------
863   int            lines() const { initialize(); return LINES; }
864   // Number of lines on terminal, *not* window
865
866   int            cols() const { initialize(); return COLS; }
867   // Number of cols  on terminal, *not* window
868
869   int            tabsize() const { initialize(); return TABSIZE; }
870   // Size of a tab on terminal, *not* window
871
872   static int     NumberOfColors();
873   // Number of available colors
874
875   int            colors() const { return NumberOfColors(); }
876   // Number of available colors
877
878   // -------------------------------------------------------------------------
879   // window status
880   // -------------------------------------------------------------------------
881   int            height() const { return maxy() + 1; }
882   // Number of lines in this window
883
884   int            width() const { return maxx() + 1; }
885   // Number of columns in this window
886
887   int            begx() const { return getbegx(w); }
888   // Column of top left corner relative to stdscr
889
890   int            begy() const { return getbegy(w); }
891   // Line of top left corner relative to stdscr
892
893   int            curx() const { return getcurx(w); }
894   // Column of top left corner relative to stdscr
895
896   int            cury() const { return getcury(w); }
897   // Line of top left corner relative to stdscr
898
899   int            maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
900   // Largest x coord in window
901
902   int            maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
903   // Largest y coord in window
904
905   NCURSES_PAIRS_T getcolor() const;
906   // Actual color pair
907
908   NCURSES_COLOR_T foreground() const { return getcolor(0); }
909   // Actual foreground color
910
911   NCURSES_COLOR_T background() const { return getcolor(1); }
912   // Actual background color
913
914   int            setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
915   // Set color palette entry
916
917   int            setcolor(NCURSES_PAIRS_T pair);
918   // Set actually used palette entry
919
920   // -------------------------------------------------------------------------
921   // window positioning
922   // -------------------------------------------------------------------------
923   virtual int    mvwin(int begin_y, int begin_x) {
924     return ::mvwin(w, begin_y, begin_x); }
925   // Move window to new position with the new position as top left corner.
926   // This is virtual because it is redefined in NCursesPanel.
927
928   // -------------------------------------------------------------------------
929   // coordinate positioning
930   // -------------------------------------------------------------------------
931   int            move(int y, int x) { return ::wmove(w, y, x); }
932   // Move cursor the this position
933
934   void           getyx(int& y, int& x) const { ::getyx(w, y, x); }
935   // Get current position of the cursor
936
937   void           getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
938   // Get beginning of the window
939
940   void           getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
941   // Get size of the window
942
943   void           getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
944   // Get parent's beginning of the window
945
946   int            mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
947     return ::mvcur(oldrow, oldcol, newrow, newcol); }
948   // Perform lowlevel cursor motion that takes effect immediately.
949
950   // -------------------------------------------------------------------------
951   // input
952   // -------------------------------------------------------------------------
953   int            getch() { return ::wgetch(w); }
954   // Get a keystroke from the window.
955
956   int            getch(int y, int x) { return ::mvwgetch(w, y, x); }
957   // Move cursor to position and get a keystroke from the window
958
959   int            getstr(char* str, int n=-1) {
960     return ::wgetnstr(w, str, n); }
961   // Read a series of characters into str until a newline or carriage return
962   // is received. Read at most n characters. If n is negative, the limit is
963   // ignored.
964
965   int            getstr(int y, int x, char* str, int n=-1) {
966     return ::mvwgetnstr(w, y, x, str, n); }
967   // Move the cursor to the requested position and then perform the getstr()
968   // as described above.
969
970   int            instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
971   // Get a string of characters from the window into the buffer s. Retrieve
972   // at most n characters, if n is negative retrieve all characters up to the
973   // end of the current line. Attributes are stripped from the characters.
974
975   int            instr(int y, int x, char *s, int n=-1) {
976     return ::mvwinnstr(w, y, x, s, n); }
977   // Move the cursor to the requested position and then perform the instr()
978   // as described above.
979
980   int            scanw(const char* fmt, ...)
981     // Perform a scanw function from the window.
982 #if __GNUG__ >= 2
983     __attribute__ ((format (scanf, 2, 3)));
984 #else
985   ;
986 #endif
987
988   int            scanw(const char*, va_list);
989     // Perform a scanw function from the window.
990
991   int            scanw(int y, int x, const char* fmt, ...)
992     // Move the cursor to the requested position and then perform a scanw
993     // from the window.
994 #if __GNUG__ >= 2
995     __attribute__ ((format (scanf, 4, 5)));
996 #else
997   ;
998 #endif
999
1000   int            scanw(int y, int x, const char* fmt, va_list);
1001     // Move the cursor to the requested position and then perform a scanw
1002     // from the window.
1003
1004   // -------------------------------------------------------------------------
1005   // output
1006   // -------------------------------------------------------------------------
1007   int            addch(const chtype ch) { return ::waddch(w, ch); }
1008   // Put attributed character to the window.
1009
1010   int            addch(int y, int x, const chtype ch) {
1011     return ::mvwaddch(w, y, x, ch); }
1012   // Move cursor to the requested position and then put attributed character
1013   // to the window.
1014
1015   int            echochar(const chtype ch) { return ::wechochar(w, ch); }
1016   // Put attributed character to the window and refresh it immediately.
1017
1018   int            addstr(const char* str, int n=-1) {
1019     return ::waddnstr(w, str, n); }
1020   // Write the string str to the window, stop writing if the terminating
1021   // NUL or the limit n is reached. If n is negative, it is ignored.
1022
1023   int            addstr(int y, int x, const char * str, int n=-1) {
1024     return ::mvwaddnstr(w, y, x, str, n); }
1025   // Move the cursor to the requested position and then perform the addchstr
1026   // as described above.
1027
1028   int            addchstr(const chtype* str, int n=-1) {
1029     return ::waddchnstr(w, str, n); }
1030   // Write the string str to the window, stop writing if the terminating
1031   // NUL or the limit n is reached. If n is negative, it is ignored.
1032
1033   int            addchstr(int y, int x, const chtype * str, int n=-1) {
1034     return ::mvwaddchnstr(w, y, x, str, n); }
1035   // Move the cursor to the requested position and then perform the addchstr
1036   // as described above.
1037
1038   int            printw(const char* fmt, ...)
1039     // Do a formatted print to the window.
1040 #if (__GNUG__ >= 2) && !defined(printf)
1041     __attribute__ ((format (printf, 2, 3)));
1042 #else
1043   ;
1044 #endif
1045
1046   int            printw(int y, int x, const char * fmt, ...)
1047     // Move the cursor and then do a formatted print to the window.
1048 #if (__GNUG__ >= 2) && !defined(printf)
1049     __attribute__ ((format (printf, 4, 5)));
1050 #else
1051   ;
1052 #endif
1053
1054   int            printw(const char* fmt, va_list args);
1055     // Do a formatted print to the window.
1056
1057   int            printw(int y, int x, const char * fmt, va_list args);
1058     // Move the cursor and then do a formatted print to the window.
1059
1060   chtype         inch() const { return ::winch(w); }
1061   // Retrieve attributed character under the current cursor position.
1062
1063   chtype         inch(int y, int x) { return ::mvwinch(w, y, x); }
1064   // Move cursor to requested position and then retrieve attributed character
1065   // at this position.
1066
1067   int            inchstr(chtype* str, int n=-1) {
1068     return ::winchnstr(w, str, n); }
1069   // Read the string str from the window, stop reading if the terminating
1070   // NUL or the limit n is reached. If n is negative, it is ignored.
1071
1072   int            inchstr(int y, int x, chtype * str, int n=-1) {
1073     return ::mvwinchnstr(w, y, x, str, n); }
1074   // Move the cursor to the requested position and then perform the inchstr
1075   // as described above.
1076
1077   int            insch(chtype ch) { return ::winsch(w, ch); }
1078   // Insert attributed character into the window before current cursor
1079   // position.
1080
1081   int            insch(int y, int x, chtype ch) {
1082     return ::mvwinsch(w, y, x, ch); }
1083   // Move cursor to requested position and then insert the attributed
1084   // character before that position.
1085
1086   int            insertln() { return ::winsdelln(w, 1); }
1087   // Insert an empty line above the current line.
1088
1089   int            insdelln(int n=1) { return ::winsdelln(w, n); }
1090   // If n>0 insert that many lines above the current line. If n<0 delete
1091   // that many lines beginning with the current line.
1092
1093   int            insstr(const char *s, int n=-1) {
1094     return ::winsnstr(w, s, n); }
1095   // Insert the string into the window before the current cursor position.
1096   // Insert stops at end of string or when the limit n is reached. If n is
1097   // negative, it is ignored.
1098
1099   int            insstr(int y, int x, const char *s, int n=-1) {
1100     return ::mvwinsnstr(w, y, x, s, n); }
1101   // Move the cursor to the requested position and then perform the insstr()
1102   // as described above.
1103
1104   int            attron (chtype at) { return ::wattron (w, at); }
1105   // Switch on the window attributes;
1106
1107   int            attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
1108   // Switch off the window attributes;
1109
1110   int            attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
1111   // Set the window attributes;
1112
1113   chtype         attrget() { return ::getattrs(w); }
1114   // Get the window attributes;
1115
1116   int            color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
1117     return ::wcolor_set(w, color_pair_number, opts); }
1118   // Set the window color attribute;
1119
1120   int            chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
1121     return ::wchgat(w, n, attr, color, opts); }
1122   // Change the attributes of the next n characters in the current line. If
1123   // n is negative or greater than the number of remaining characters in the
1124   // line, the attributes will be changed up to the end of the line.
1125
1126   int            chgat(int y, int x,
1127                        int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
1128     return ::mvwchgat(w, y, x, n, attr, color, opts); }
1129   // Move the cursor to the requested position and then perform chgat() as
1130   // described above.
1131
1132   // -------------------------------------------------------------------------
1133   // background
1134   // -------------------------------------------------------------------------
1135   chtype         getbkgd() const { return ::getbkgd(w); }
1136   // Get current background setting.
1137
1138   int            bkgd(const chtype ch) { return ::wbkgd(w, ch); }
1139   // Set the background property and apply it to the window.
1140
1141   void           bkgdset(chtype ch) { ::wbkgdset(w, ch); }
1142   // Set the background property.
1143
1144   // -------------------------------------------------------------------------
1145   // borders
1146   // -------------------------------------------------------------------------
1147   int            box(chtype vert=0, chtype  hor=0) {
1148     return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
1149   // Draw a box around the window with the given vertical and horizontal
1150   // drawing characters. If you specify a zero as character, curses will try
1151   // to find a "nice" character.
1152
1153   int            border(chtype left=0, chtype right=0,
1154                         chtype top =0, chtype bottom=0,
1155                         chtype top_left =0, chtype top_right=0,
1156                         chtype bottom_left =0, chtype bottom_right=0) {
1157     return ::wborder(w, left, right, top, bottom, top_left, top_right,
1158                      bottom_left, bottom_right); }
1159   // Draw a border around the window with the given characters for the
1160   // various parts of the border. If you pass zero for a character, curses
1161   // will try to find "nice" characters.
1162
1163   // -------------------------------------------------------------------------
1164   // lines and boxes
1165   // -------------------------------------------------------------------------
1166   int            hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
1167   // Draw a horizontal line of len characters with the given character. If
1168   // you pass zero for the character, curses will try to find a "nice" one.
1169
1170   int            hline(int y, int x, int len, chtype ch=0) {
1171     return ::mvwhline(w, y, x, ch, len); }
1172   // Move the cursor to the requested position and then draw a horizontal line.
1173
1174   int            vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
1175   // Draw a vertical line of len characters with the given character. If
1176   // you pass zero for the character, curses will try to find a "nice" one.
1177
1178   int            vline(int y, int x, int len, chtype ch=0) {
1179     return ::mvwvline(w, y, x, ch, len); }
1180   // Move the cursor to the requested position and then draw a vertical line.
1181
1182   // -------------------------------------------------------------------------
1183   // erasure
1184   // -------------------------------------------------------------------------
1185   int            erase() { return ::werase(w); }
1186   // Erase the window.
1187
1188   int            clear() { return ::wclear(w); }
1189   // Clear the window.
1190
1191   int            clearok(bool bf) { return ::clearok(w, bf); }
1192   // Set/Reset the clear flag. If set, the next refresh() will clear the
1193   // screen.
1194
1195   int            clrtobot() { return ::wclrtobot(w); }
1196   // Clear to the end of the window.
1197
1198   int            clrtoeol() { return ::wclrtoeol(w); }
1199   // Clear to the end of the line.
1200
1201   int            delch() { return ::wdelch(w); }
1202   // Delete character under the cursor.
1203
1204   int            delch(int y, int x) { return ::mvwdelch(w, y, x); }
1205   // Move cursor to requested position and delete the character under the
1206   // cursor.
1207
1208   int            deleteln() { return ::winsdelln(w, -1); }
1209   // Delete the current line.
1210
1211   // -------------------------------------------------------------------------
1212   // screen control
1213   // -------------------------------------------------------------------------
1214   int            scroll(int amount=1) { return ::wscrl(w, amount); }
1215   // Scroll amount lines. If amount is positive, scroll up, otherwise
1216   // scroll down.
1217
1218   int            scrollok(bool bf) { return ::scrollok(w, bf); }
1219   // If bf is TRUE, window scrolls if cursor is moved off the bottom
1220   // edge of the window or a scrolling region, otherwise the cursor is left
1221   // at the bottom line.
1222
1223   int            setscrreg(int from, int to) {
1224     return ::wsetscrreg(w, from, to); }
1225   // Define a soft scrolling region.
1226
1227   int            idlok(bool bf) { return ::idlok(w, bf); }
1228   // If bf is TRUE, use insert/delete line hardware support if possible.
1229   // Otherwise do it in software.
1230
1231   void           idcok(bool bf) { ::idcok(w, bf); }
1232   // If bf is TRUE, use insert/delete character hardware support if possible.
1233   // Otherwise do it in software.
1234
1235   int            touchline(int s, int c) { return ::touchline(w, s, c); }
1236   // Mark the given lines as modified.
1237
1238   int            touchwin()   { return ::wtouchln(w, 0, height(), 1); }
1239   // Mark the whole window as modified.
1240
1241   int            untouchwin() { return ::wtouchln(w, 0, height(), 0); }
1242   // Mark the whole window as unmodified.
1243
1244   int            touchln(int s, int cnt, bool changed=TRUE) {
1245     return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
1246   // Mark cnt lines beginning from line s as changed or unchanged, depending
1247   // on the value of the changed flag.
1248
1249   bool           is_linetouched(int line) const {
1250     return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
1251   // Return TRUE if line is marked as changed, FALSE otherwise
1252
1253   bool           is_wintouched() const {
1254     return (::is_wintouched(w) ? TRUE:FALSE); }
1255   // Return TRUE if window is marked as changed, FALSE otherwise
1256
1257   int            leaveok(bool bf) { return ::leaveok(w, bf); }
1258   // If bf is TRUE, curses will leave the cursor after an update whereever
1259   // it is after the update.
1260
1261   int            redrawln(int from, int n) { return ::wredrawln(w, from, n); }
1262   // Redraw n lines starting from the requested line
1263
1264   int            redrawwin() { return ::wredrawln(w, 0, height()); }
1265   // Redraw the whole window
1266
1267   int            doupdate()  { return ::doupdate(); }
1268   // Do all outputs to make the physical screen looking like the virtual one
1269
1270   void           syncdown()  { ::wsyncdown(w); }
1271   // Propagate the changes down to all descendant windows
1272
1273   void           syncup()    { ::wsyncup(w); }
1274   // Propagate the changes up in the hierarchy
1275
1276   void           cursyncup() { ::wcursyncup(w); }
1277   // Position the cursor in all ancestor windows corresponding to our setting
1278
1279   int            syncok(bool bf) { return ::syncok(w, bf); }
1280   // If called with bf=TRUE, syncup() is called whenever the window is changed
1281
1282 #ifndef _no_flushok
1283   int            flushok(bool bf) { return ::flushok(w, bf); }
1284 #endif
1285
1286   void           immedok(bool bf) { ::immedok(w, bf); }
1287   // If called with bf=TRUE, any change in the window will cause an
1288   // automatic immediate refresh()
1289
1290   int            intrflush(bool bf) { return ::intrflush(w, bf); }
1291
1292   int            keypad(bool bf) { return ::keypad(w, bf); }
1293   // If called with bf=TRUE, the application will interpret function keys.
1294
1295   int            nodelay(bool bf) { return ::nodelay(w, bf); }
1296
1297   int            meta(bool bf) { return ::meta(w, bf); }
1298   // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
1299   // 7-Bit characters are generated.
1300
1301   int            standout() { return ::wstandout(w); }
1302   // Enable "standout" attributes
1303
1304   int            standend() { return ::wstandend(w); }
1305   // Disable "standout" attributes
1306
1307   // -------------------------------------------------------------------------
1308   // The next two are virtual, because we redefine them in the
1309   // NCursesPanel class.
1310   // -------------------------------------------------------------------------
1311   virtual int    refresh() { return ::wrefresh(w); }
1312   // Propagate the changes in this window to the virtual screen and call
1313   // doupdate(). This is redefined in NCursesPanel.
1314
1315   virtual int    noutrefresh() { return ::wnoutrefresh(w); }
1316   // Propagate the changes in this window to the virtual screen. This is
1317   // redefined in NCursesPanel.
1318
1319   // -------------------------------------------------------------------------
1320   // multiple window control
1321   // -------------------------------------------------------------------------
1322   int            overlay(NCursesWindow& win) {
1323     return ::overlay(w, win.w); }
1324   // Overlay this window over win.
1325
1326   int            overwrite(NCursesWindow& win) {
1327     return ::overwrite(w, win.w); }
1328   // Overwrite win with this window.
1329
1330   int            copywin(NCursesWindow& win,
1331                          int sminrow, int smincol,
1332                          int dminrow, int dmincol,
1333                          int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
1334     return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
1335                      dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
1336   // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
1337   // dmaxrow,dmaxcol with the rectangle in this window beginning at
1338   // sminrow,smincol.
1339
1340   // -------------------------------------------------------------------------
1341   // Extended functions
1342   // -------------------------------------------------------------------------
1343 #if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
1344   int            wresize(int newLines, int newColumns) {
1345     return ::wresize(w, newLines, newColumns); }
1346 #endif
1347
1348   // -------------------------------------------------------------------------
1349   // Mouse related
1350   // -------------------------------------------------------------------------
1351   bool has_mouse() const;
1352   // Return TRUE if terminal supports a mouse, FALSE otherwise
1353
1354   // -------------------------------------------------------------------------
1355   // traversal support
1356   // -------------------------------------------------------------------------
1357   NCursesWindow*  child() { return subwins; }
1358   // Get the first child window.
1359
1360   NCursesWindow*  sibling() { return sib; }
1361   // Get the next child of my parent.
1362
1363   NCursesWindow*  parent() { return par; }
1364   // Get my parent.
1365
1366   bool isDescendant(NCursesWindow& win);
1367   // Return TRUE if win is a descendant of this.
1368 };
1369
1370 // -------------------------------------------------------------------------
1371 // We leave this here for compatibility reasons.
1372 // -------------------------------------------------------------------------
1373 class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
1374 {
1375 public:
1376   NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
1377     : NCursesWindow(window) {
1378       useColors(); }
1379
1380   NCursesColorWindow(int nlines,        // number of lines
1381                      int ncols,         // number of columns
1382                      int begin_y,       // line origin
1383                      int begin_x)       // col origin
1384     : NCursesWindow(nlines, ncols, begin_y, begin_x) {
1385       useColors(); }
1386
1387   NCursesColorWindow(NCursesWindow& parentWin,// parent window
1388                      int nlines,        // number of lines
1389                      int ncols,         // number of columns
1390                      int begin_y,       // absolute or relative
1391                      int begin_x,       //   origins:
1392                      char absrel = 'a') // if `a', by & bx are
1393     : NCursesWindow(parentWin,
1394                     nlines, ncols,      // absolute screen pos,
1395                     begin_y, begin_x,   // else if `r', they are
1396                     absrel ) {          // relative to par origin
1397       useColors(); }
1398 };
1399
1400 // These enum definitions really belong inside the NCursesPad class, but only
1401 // recent compilers support that feature.
1402
1403   typedef enum {
1404     REQ_PAD_REFRESH = KEY_MAX + 1,
1405     REQ_PAD_UP,
1406     REQ_PAD_DOWN,
1407     REQ_PAD_LEFT,
1408     REQ_PAD_RIGHT,
1409     REQ_PAD_EXIT
1410   } Pad_Request;
1411
1412   const Pad_Request PAD_LOW  = REQ_PAD_REFRESH;   // lowest  op-code
1413   const Pad_Request PAD_HIGH = REQ_PAD_EXIT;      // highest op-code
1414
1415 // -------------------------------------------------------------------------
1416 // Pad Support. We allow an association of a pad with a "real" window
1417 // through which the pad may be viewed.
1418 // -------------------------------------------------------------------------
1419 class NCURSES_IMPEXP NCursesPad : public NCursesWindow
1420 {
1421 private:
1422   NCursesWindow* viewWin;       // the "viewport" window
1423   NCursesWindow* viewSub;       // the "viewport" subwindow
1424
1425   int h_gridsize, v_gridsize;
1426
1427 protected:
1428   int min_row, min_col;         // top left row/col of the pads display area
1429
1430   NCursesWindow* Win(void) const {
1431     // Get the window into which the pad should be copied (if any)
1432     return (viewSub?viewSub:(viewWin?viewWin:0));
1433   }
1434
1435   NCursesWindow* getWindow(void) const {
1436     return viewWin;
1437   }
1438
1439   NCursesWindow* getSubWindow(void) const {
1440     return viewSub;
1441   }
1442
1443   virtual int driver (int key);      // Virtualize keystroke key
1444   // The driver translates the keystroke c into an Pad_Request
1445
1446   virtual void OnUnknownOperation(int pad_req) {
1447     (void) pad_req;
1448     ::beep();
1449   }
1450   // This is called if the driver returns an unknown op-code
1451
1452   virtual void OnNavigationError(int pad_req) {
1453     (void) pad_req;
1454     ::beep();
1455   }
1456   // This is called if a navigation request couldn't be satisfied
1457
1458   virtual void OnOperation(int pad_req) {
1459     (void) pad_req;
1460   };
1461   // OnOperation is called if a Pad_Operation was executed and just before
1462   // the refresh() operation is done.
1463
1464 public:
1465   NCursesPad(int nlines, int ncols);
1466   // create a pad with the given size
1467
1468   NCursesPad& operator=(const NCursesPad& rhs)
1469   {
1470     if (this != &rhs) {
1471       *this = rhs;
1472       NCursesWindow::operator=(rhs);
1473     }
1474     return *this;
1475   }
1476
1477   NCursesPad(const NCursesPad& rhs)
1478     : NCursesWindow(rhs),
1479       viewWin(rhs.viewWin),
1480       viewSub(rhs.viewSub),
1481       h_gridsize(rhs.h_gridsize),
1482       v_gridsize(rhs.v_gridsize),
1483       min_row(rhs.min_row),
1484       min_col(rhs.min_col)
1485   {
1486   }
1487
1488   virtual ~NCursesPad() {}
1489
1490   int echochar(const chtype ch) { return ::pechochar(w, ch); }
1491   // Put the attributed character onto the pad and immediately do a
1492   // prefresh().
1493
1494   int refresh();
1495   // If a viewport is defined the pad is displayed in this window, otherwise
1496   // this is a noop.
1497
1498   int refresh(int pminrow, int pmincol,
1499               int sminrow, int smincol,
1500               int smaxrow, int smaxcol) {
1501     return ::prefresh(w, pminrow, pmincol,
1502                       sminrow, smincol, smaxrow, smaxcol);
1503   }
1504   // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
1505   // on the screen. <b>refresh</b> copies a rectangle of this size beginning
1506   // with top left corner pminrow,pmincol onto the screen and calls doupdate().
1507
1508   int noutrefresh();
1509   // If a viewport is defined the pad is displayed in this window, otherwise
1510   // this is a noop.
1511
1512   int noutrefresh(int pminrow, int pmincol,
1513                   int sminrow, int smincol,
1514                   int smaxrow, int smaxcol) {
1515     return ::pnoutrefresh(w, pminrow, pmincol,
1516                           sminrow, smincol, smaxrow, smaxcol);
1517   }
1518   // Does the same as refresh() but without calling doupdate().
1519
1520   virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
1521   // Add the window "view" as viewing window to the pad.
1522
1523   virtual void setSubWindow(NCursesWindow& sub);
1524   // Use the subwindow "sub" of the viewport window for the actual viewing.
1525   // The full viewport window is usually used to provide some decorations
1526   // like frames, titles etc.
1527
1528   virtual void operator() (void);
1529   // Perform Pad's operation
1530 };
1531
1532 // A FramedPad is constructed always with a viewport window. This viewport
1533 // will be framed (by a box() command) and the interior of the box is the
1534 // viewport subwindow. On the frame we display scrollbar sliders.
1535 class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
1536 {
1537 protected:
1538   virtual void OnOperation(int pad_req);
1539
1540 public:
1541   NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
1542                    int v_grid = 1, int h_grid = 1)
1543     : NCursesPad(nlines, ncols) {
1544     NCursesPad::setWindow(win, v_grid, h_grid);
1545     NCursesPad::setSubWindow(*(new NCursesWindow(win)));
1546   }
1547   // Construct the FramedPad with the given Window win as viewport.
1548
1549   virtual ~NCursesFramedPad() {
1550     delete getSubWindow();
1551   }
1552
1553   void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
1554     (void) view;
1555     (void) v_grid;
1556     (void) h_grid;
1557     err_handler("Operation not allowed");
1558   }
1559   // Disable this call; the viewport is already defined
1560
1561   void setSubWindow(NCursesWindow& sub) {
1562     (void) sub;
1563     err_handler("Operation not allowed");
1564   }
1565   // Disable this call; the viewport subwindow is already defined
1566
1567 };
1568
1569 #endif /* NCURSES_CURSESW_H_incl */