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