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