libyui-ncurses  2.44.1
 All Classes Functions Variables
ncursesw.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: ncursesw.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef _CURSESW_H
26 #define _CURSESW_H
27 
28 #include <iosfwd>
29 
30 #include <ncursesw/etip.h>
31 #include <cstdio>
32 #include <cstdarg>
33 #include <climits>
34 #include "position.h"
35 
36 #include <ncursesw/curses.h>
37 
38 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
39  Undefine it here, because NCursesWindow uses lines as a method. */
40 #undef lines
41 
42 /* "Convert" macros to inlines. We'll define it as another symbol to avoid
43  * conflict with library symbols.
44  */
45 #undef UNDEF
46 #define UNDEF(name) CUR_ ##name
47 
48 #ifdef addch
49 inline int UNDEF( addch )( chtype ch ) { return addch( ch ); }
50 
51 #undef addch
52 #define addch UNDEF(addch)
53 #endif
54 
55 #ifdef add_wch
56 inline int UNDEF( add_wch )( cchar_t * cch ) { return add_wch( cch ); }
57 
58 #undef add_wch
59 #define add_wch UNDEF(add_wch)
60 #endif
61 
62 #ifdef echochar
63 inline int UNDEF( echochar )( chtype ch ) { return echochar( ch ); }
64 
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 
72 #undef insdelln
73 #define insdelln UNDEF(insdelln)
74 #endif
75 
76 #ifdef addstr
77 /* The (char*) cast is to hack around missing const's */
78 inline int UNDEF( addstr )( const char * str ) { return addstr(( char* )str ); }
79 
80 #undef addstr
81 #define addstr UNDEF(addstr)
82 #endif
83 
84 #ifdef addwstr
85 /* The (wchar*_t) cast is to hack around missing const's */
86 inline int UNDEF( addwstr )( const wchar_t * str ) { return addwstr(( wchar_t* )str ); }
87 
88 #undef addwstr
89 #define addwstr UNDEF(addwstr)
90 #endif
91 
92 #ifdef attron
93 inline int UNDEF( attron )( chtype at ) { return attron( at ); }
94 
95 #undef attron
96 #define attron UNDEF(attron)
97 #endif
98 
99 #ifdef attroff
100 inline int UNDEF( attroff )( chtype at ) { return attroff( at ); }
101 
102 #undef attroff
103 #define attroff UNDEF(attroff)
104 #endif
105 
106 #ifdef attrset
107 inline chtype UNDEF( attrset )( chtype at ) { return attrset( at ); }
108 
109 #undef attrset
110 #define attrset UNDEF(attrset)
111 #endif
112 
113 #ifdef border
114 inline int UNDEF( border )( chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br )
115 { return border( ls, rs, ts, bs, tl, tr, bl, br ); }
116 
117 #undef border
118 #define border UNDEF(border)
119 #endif
120 
121 #ifdef box
122 inline int UNDEF( box )( WINDOW *win, int v, int h ) { return box( win, v, h ); }
123 
124 #undef box
125 #define box UNDEF(box)
126 #endif
127 
128 #ifdef mvwhline
129 inline int UNDEF( mvwhline )( WINDOW *win, int y, int x, chtype c, int n )
130 {
131  return mvwhline( win, y, x, c, n );
132 }
133 
134 #undef mvwhline
135 #define mvwhline UNDEF(mvwhline)
136 #endif
137 
138 #ifdef mvwvline
139 inline int UNDEF( mvwvline )( WINDOW *win, int y, int x, chtype c, int n )
140 {
141  return mvwvline( win, y, x, c, n );
142 }
143 
144 #undef mvwvline
145 #define mvwvline UNDEF(mvwvline)
146 #endif
147 
148 #ifdef clear
149 inline int UNDEF( clear )() { return clear(); }
150 
151 #undef clear
152 #define clear UNDEF(clear)
153 #endif
154 
155 #ifdef clearok
156 inline int UNDEF( clearok )( WINDOW* win, bool bf ) { return clearok( win, bf ); }
157 
158 #undef clearok
159 #define clearok UNDEF(clearok)
160 #else
161 extern "C" int clearok( WINDOW*, bool );
162 #endif
163 
164 #ifdef clrtobot
165 inline int UNDEF( clrtobot )() { return clrtobot(); }
166 
167 #undef clrtobot
168 #define clrtobot UNDEF(clrtobot)
169 #endif
170 
171 #ifdef clrtoeol
172 inline int UNDEF( clrtoeol )() { return clrtoeol(); }
173 
174 #undef clrtoeol
175 #define clrtoeol UNDEF(clrtoeol)
176 #endif
177 
178 #ifdef delch
179 inline int UNDEF( delch )() { return delch(); }
180 
181 #undef delch
182 #define delch UNDEF(delch)
183 #endif
184 
185 #ifdef deleteln
186 inline int UNDEF( deleteln )() { return deleteln(); }
187 
188 #undef deleteln
189 #define deleteln UNDEF(deleteln)
190 #endif
191 
192 #ifdef erase
193 inline int UNDEF( erase )() { return erase(); }
194 
195 #undef erase
196 #define erase UNDEF(erase)
197 #endif
198 
199 #ifdef flushok
200 inline int UNDEF( flushok )( WINDOW* _win, bool _bf )
201 {
202  return flushok( _win, _bf );
203 }
204 
205 #undef flushok
206 #define flushok UNDEF(flushok)
207 #else
208 #define _no_flushok
209 #endif
210 
211 #ifdef getch
212 inline int UNDEF( getch )() { return getch(); }
213 
214 #undef getch
215 #define getch UNDEF(getch)
216 #endif
217 
218 #ifdef getstr
219 inline int UNDEF( getstr )( char *_str ) { return getstr( _str ); }
220 
221 #undef getstr
222 #define getstr UNDEF(getstr)
223 #endif
224 
225 #ifdef instr
226 inline int UNDEF( instr )( char *_str ) { return instr( _str ); }
227 
228 #undef instr
229 #define instr UNDEF(instr)
230 #endif
231 
232 #ifdef innstr
233 inline int UNDEF( innstr )( char *_str, int n ) { return innstr( _str, n ); }
234 
235 #undef innstr
236 #define innstr UNDEF(innstr)
237 #endif
238 
239 #ifdef mvwinnstr
240 inline int UNDEF( mvwinnstr )( WINDOW *win, int y, int x, char *_str, int n )
241 {
242  return mvwinnstr( win, y, x, _str, n );
243 }
244 
245 #undef mvwinnstr
246 #define mvwinnstr UNDEF(mvwinnstr)
247 #endif
248 
249 #ifdef mvinnstr
250 inline int UNDEF( mvinnstr )( int y, int x, char *_str, int n )
251 {
252  return mvinnstr( y, x, _str, n );
253 }
254 
255 #undef mvinnstr
256 #define mvinnstr UNDEF(mvinnstr)
257 #endif
258 
259 #ifdef winsstr
260 inline int UNDEF( winsstr )( WINDOW *w, const char *_str )
261 {
262  return winsstr( w, _str );
263 }
264 
265 #undef winsstr
266 #define winsstr UNDEF(winsstr)
267 #endif
268 
269 #ifdef mvwinsstr
270 inline int UNDEF( mvwinsstr )( WINDOW *w, int y, int x, const char *_str )
271 {
272  return mvwinsstr( w, y, x, _str );
273 }
274 
275 #undef mvwinsstr
276 #define mvwinsstr UNDEF(mvwinsstr)
277 #endif
278 
279 #ifdef insstr
280 inline int UNDEF( insstr )( const char *_str )
281 {
282  return insstr( _str );
283 }
284 
285 #undef insstr
286 #define insstr UNDEF(insstr)
287 #endif
288 
289 #ifdef mvinsstr
290 inline int UNDEF( mvinsstr )( int y, int x, const char *_str )
291 {
292  return mvinsstr( y, x, _str );
293 }
294 
295 #undef mvinsstr
296 #define mvinsstr UNDEF(mvinsstr)
297 #endif
298 
299 #ifdef insnstr
300 inline int UNDEF( insnstr )( const char *_str, int n )
301 {
302  return insnstr( _str, n );
303 }
304 
305 #undef insnstr
306 #define insnstr UNDEF(insnstr)
307 #endif
308 
309 #ifdef mvwinsnstr
310 inline int UNDEF( mvwinsnstr )( WINDOW *w, int y, int x, const char *_str, int n )
311 {
312  return mvwinsnstr( w, y, x, _str, n );
313 }
314 
315 #undef mvwinsnstr
316 #define mvwinsnstr UNDEF(mvwinsnstr)
317 #endif
318 
319 #ifdef mvinsnstr
320 inline int UNDEF( mvinsnstr )( int y, int x, const char *_str, int n )
321 {
322  return mvinsnstr( y, x, _str, n );
323 }
324 
325 #undef mvinsnstr
326 #define mvinsnstr UNDEF(mvinsnstr)
327 #endif
328 
329 #ifdef getnstr
330 inline int UNDEF( getnstr )( char *_str, int n ) { return getnstr( _str, n ); }
331 
332 #undef getnstr
333 #define getnstr UNDEF(getnstr)
334 #endif
335 
336 #ifdef getyx
337 inline void UNDEF( getyx )( const WINDOW* win, int& y, int& x )
338 {
339  getyx( win, y, x );
340 }
341 
342 #undef getyx
343 #define getyx UNDEF(getyx)
344 #endif
345 
346 #ifdef getbegyx
347 inline void UNDEF( getbegyx )( WINDOW* win, int& y, int& x ) { getbegyx( win, y, x ); }
348 
349 #undef getbegyx
350 #define getbegyx UNDEF(getbegyx)
351 #endif
352 
353 #ifdef getmaxyx
354 inline void UNDEF( getmaxyx )( WINDOW* win, int& y, int& x ) { getmaxyx( win, y, x ); }
355 
356 #undef getmaxyx
357 #define getmaxyx UNDEF(getmaxyx)
358 #endif
359 
360 #ifdef hline
361 inline int UNDEF( hline )( chtype ch, int n ) { return hline( ch, n ); }
362 
363 #undef hline
364 #define hline UNDEF(hline)
365 #endif
366 
367 #ifdef inch
368 inline chtype UNDEF( inch )() { return inch(); }
369 
370 #undef inch
371 #define inch UNDEF(inch)
372 #endif
373 
374 #ifdef in_wch
375 inline int UNDEF( in_wch )( cchar_t * cch ) { return in_wch( cch ); }
376 
377 #undef in_wch
378 #define in_wch UNDEF(in_wch)
379 #endif
380 
381 #ifdef insch
382 inline int UNDEF( insch )( char c ) { return insch( c ); }
383 
384 #undef insch
385 #define insch UNDEF(insch)
386 #endif
387 
388 #ifdef ins_wch
389 inline int UNDEF( ins_wch )( const cchar_t *c ) { return ins_wch( c ); }
390 
391 #undef ins_wch
392 #define ins_wch UNDEF(ins_wch)
393 #endif
394 
395 #ifdef mvwins_wch
396 inline int UNDEF( mvwins_wch )( WINDOW *w, int y, int x, const cchar_t *cchar ) { return mvwins_wch( w, y, x, cchar ); }
397 
398 #undef mvwins_wch
399 #define mvwins_wch UNDEF(mvwins_wch)
400 #endif
401 
402 #ifdef insertln
403 inline int UNDEF( insertln )() { return insertln(); }
404 
405 #undef insertln
406 #define insertln UNDEF(insertln)
407 #endif
408 
409 #ifdef leaveok
410 inline int UNDEF( leaveok )( WINDOW* win, bool bf ) { return leaveok( win, bf ); }
411 
412 #undef leaveok
413 #define leaveok UNDEF(leaveok)
414 #else
415 extern "C" int leaveok( WINDOW* win, bool bf );
416 #endif
417 
418 #ifdef move
419 inline int UNDEF( move )( int x, int y ) { return move( x, y ); }
420 
421 #undef move
422 #define move UNDEF(move)
423 #endif
424 
425 #ifdef refresh
426 inline int UNDEF( refresh )() { return refresh(); }
427 
428 #undef refresh
429 #define refresh UNDEF(refresh)
430 #endif
431 
432 #ifdef redrawwin
433 inline int UNDEF( redrawwin )( WINDOW *win ) { return redrawwin( win ); }
434 
435 #undef redrawwin
436 #define redrawwin UNDEF(redrawwin)
437 #endif
438 
439 #ifdef scrl
440 inline int UNDEF( scrl )( int l ) { return scrl( l ); }
441 
442 #undef scrl
443 #define scrl UNDEF(scrl)
444 #endif
445 
446 #ifdef scroll
447 inline int UNDEF( scroll )( WINDOW *win ) { return scroll( win ); }
448 
449 #undef scroll
450 #define scroll UNDEF(scroll)
451 #endif
452 
453 #ifdef scrollok
454 inline int UNDEF( scrollok )( WINDOW* win, bool bf ) { return scrollok( win, bf ); }
455 
456 #undef scrollok
457 #define scrollok UNDEF(scrollok)
458 #else
459 #if defined(__NCURSES_H)
460 extern "C" int scrollok( WINDOW*, bool );
461 #else
462 extern "C" int scrollok( WINDOW*, char );
463 #endif
464 #endif
465 
466 #ifdef setscrreg
467 inline int UNDEF( setscrreg )( int t, int b ) { return setscrreg( t, b ); }
468 
469 #undef setscrreg
470 #define setscrreg UNDEF(setscrreg)
471 #endif
472 
473 #ifdef standend
474 inline int UNDEF( standend )() { return standend(); }
475 
476 #undef standend
477 #define standend UNDEF(standend)
478 #endif
479 
480 #ifdef standout
481 inline int UNDEF( standout )() { return standout(); }
482 
483 #undef standout
484 #define standout UNDEF(standout)
485 #endif
486 
487 #ifdef subpad
488 inline WINDOW *UNDEF( subpad )( WINDOW *p, int l, int c, int y, int x )
489 { return derwin( p, l, c, y, x ); }
490 
491 #undef subpad
492 #define subpad UNDEF(subpad)
493 #endif
494 
495 #ifdef timeout
496 #if NCURSES_VERSION_MAJOR < 5
497 inline int UNDEF( timeout )( int delay ) { return timeout( delay ); }
498 
499 #else
500 inline void UNDEF( timeout )( int delay ) { timeout( delay ); }
501 
502 #endif
503 #undef timeout
504 #define timeout UNDEF(timeout)
505 #endif
506 
507 #ifdef touchline
508 inline int UNDEF( touchline )( WINDOW *win, int s, int c )
509 { return touchline( win, s, c ); }
510 
511 #undef touchline
512 #define touchline UNDEF(touchline)
513 #endif
514 
515 #ifdef touchwin
516 inline int UNDEF( touchwin )( WINDOW *win ) { return touchwin( win ); }
517 
518 #undef touchwin
519 #define touchwin UNDEF(touchwin)
520 #endif
521 
522 #ifdef untouchwin
523 inline int UNDEF( untouchwin )( WINDOW *win ) { return untouchwin( win ); }
524 
525 #undef untouchwin
526 #define untouchwin UNDEF(untouchwin)
527 #endif
528 
529 #ifdef vline
530 inline int UNDEF( vline )( chtype ch, int n ) { return vline( ch, n ); }
531 
532 #undef vline
533 #define vline UNDEF(vline)
534 #endif
535 
536 #ifdef waddstr
537 inline int UNDEF( waddstr )( WINDOW *win, char *str ) { return waddstr( win, str ); }
538 
539 #undef waddstr
540 #define waddstr UNDEF(waddstr)
541 #endif
542 
543 #ifdef waddwstr
544 inline int UNDEF( waddwstr )( WINDOW *win, wchar_t *str ) { return waddwstr( win, str ); }
545 
546 #undef waddwstr
547 #define waddwstr UNDEF(waddwstr)
548 #endif
549 
550 #ifdef mvwaddwstr
551 inline int UNDEF( mvwaddwstr )( WINDOW *win, int y, int x, wchar_t *str )
552 { return mvwaddwstr( win, y, x, str ); }
553 
554 #undef mvwaddwstr
555 #define mvwaddwstr UNDEF(mvwaddwstr)
556 #endif
557 
558 #ifdef waddchstr
559 inline int UNDEF( waddchstr )( WINDOW *win, chtype *at ) { return waddchstr( win, at ); }
560 
561 #undef waddchstr
562 #define waddchstr UNDEF(waddchstr)
563 #endif
564 
565 #ifdef wstandend
566 inline int UNDEF( wstandend )( WINDOW *win ) { return wstandend( win ); }
567 
568 #undef wstandend
569 #define wstandend UNDEF(wstandend)
570 #endif
571 
572 #ifdef wstandout
573 inline int UNDEF( wstandout )( WINDOW *win ) { return wstandout( win ); }
574 
575 #undef wstandout
576 #define wstandout UNDEF(wstandout)
577 #endif
578 
579 
580 #ifdef wattroff
581 inline int UNDEF( wattroff )( WINDOW *win, int att ) { return wattroff( win, att ); }
582 
583 #undef wattroff
584 #define wattroff UNDEF(wattroff)
585 #endif
586 
587 #ifdef chgat
588 inline int UNDEF( chgat )( int n, attr_t attr, short color, const void *opts )
589 {
590  return chgat( n, attr, color, opts );
591 }
592 
593 #undef chgat
594 #define chgat UNDEF(chgat)
595 #endif
596 
597 #ifdef mvchgat
598 inline int UNDEF( mvchgat )( int y, int x, int n,
599  attr_t attr, short color, const void *opts )
600 {
601  return mvchgat( y, x, n, attr, color, opts );
602 }
603 
604 #undef mvchgat
605 #define mvchgat UNDEF(mvchgat)
606 #endif
607 
608 #ifdef mvwchgat
609 inline int UNDEF( mvwchgat )( WINDOW *win, int y, int x, int n,
610  attr_t attr, short color, const void *opts )
611 {
612  return mvwchgat( win, y, x, n, attr, color, opts );
613 }
614 
615 #undef mvwchgat
616 #define mvwchgat UNDEF(mvwchgat)
617 #endif
618 
619 #ifdef wattrset
620 inline int UNDEF( wattrset )( WINDOW *win, int att ) { return wattrset( win, att ); }
621 
622 #undef wattrset
623 #define wattrset UNDEF(wattrset)
624 #endif
625 
626 #ifdef winch
627 inline chtype UNDEF( winch )( const WINDOW* win ) { return winch( win ); }
628 
629 #undef winch
630 #define winch UNDEF(winch)
631 #endif
632 
633 #ifdef mvwaddch
634 inline int UNDEF( mvwaddch )( WINDOW *win, int y, int x, const chtype ch )
635 { return mvwaddch( win, y, x, ch ); }
636 
637 #undef mvwaddch
638 #define mvwaddch UNDEF(mvwaddch)
639 #endif
640 
641 #ifdef mvwaddchnstr
642 inline int UNDEF( mvwaddchnstr )( WINDOW *win, int y, int x, chtype *str, int n )
643 { return mvwaddchnstr( win, y, x, str, n ); }
644 
645 #undef mvwaddchnstr
646 #define mvwaddchnstr UNDEF(mvwaddchnstr)
647 #endif
648 
649 #ifdef mvwaddchstr
650 inline int UNDEF( mvwaddchstr )( WINDOW *win, int y, int x, chtype *str )
651 { return mvwaddchstr( win, y, x, str ); }
652 
653 #undef mvwaddchstr
654 #define mvwaddchstr UNDEF(mvwaddchstr)
655 #endif
656 
657 #ifdef addnstr
658 inline int UNDEF( addnstr )( const char *str, int n )
659 { return addnstr(( char* )str, n ); }
660 
661 #undef addnstr
662 #define addnstr UNDEF(addnstr)
663 #endif
664 
665 #ifdef addnwstr
666 inline int UNDEF( addnwstr )( const wchar_t *str, int n )
667 { return addnwstr(( wchar_t* )str, n ); }
668 
669 #undef addnwstr
670 #define addnwstr UNDEF(addnwstr)
671 #endif
672 
673 #ifdef mvwaddnstr
674 inline int UNDEF( mvwaddnstr )( WINDOW *win, int y, int x, const char *str, int n )
675 { return mvwaddnstr( win, y, x, ( char* )str, n ); }
676 
677 #undef mvwaddnstr
678 #define mvwaddnstr UNDEF(mvwaddnstr)
679 #endif
680 
681 #ifdef mvwaddnwstr
682 inline int UNDEF( mvwaddnwstr )( WINDOW *win, int y, int x, const wchar_t *str, int n )
683 { return mvwaddnwstr( win, y, x, ( wchar_t* )str, n ); }
684 
685 #undef mvwaddnwstr
686 #define mvwaddnwstr UNDEF(mvwaddnwstr)
687 #endif
688 
689 #ifdef mvwaddstr
690 inline int UNDEF( mvwaddstr )( WINDOW *win, int y, int x, const char * str )
691 { return mvwaddstr( win, y, x, ( char* )str ); }
692 
693 #undef mvwaddstr
694 #define mvwaddstr UNDEF(mvwaddstr)
695 #endif
696 
697 #ifdef mvwdelch
698 inline int UNDEF( mvwdelch )( WINDOW *win, int y, int x )
699 { return mvwdelch( win, y, x ); }
700 
701 #undef mvwdelch
702 #define mvwdelch UNDEF(mvwdelch)
703 #endif
704 
705 #ifdef mvwgetch
706 inline int UNDEF( mvwgetch )( WINDOW *win, int y, int x ) { return mvwgetch( win, y, x );}
707 
708 #undef mvwgetch
709 #define mvwgetch UNDEF(mvwgetch)
710 #endif
711 
712 #ifdef mvwgetstr
713 inline int UNDEF( mvwgetstr )( WINDOW *win, int y, int x, char *str )
714 {return mvwgetstr( win, y, x, str );}
715 
716 #undef mvwgetstr
717 #define mvwgetstr UNDEF(mvwgetstr)
718 #endif
719 
720 #ifdef mvwgetnstr
721 inline int UNDEF( mvwgetnstr )( WINDOW *win, int y, int x, char *str, int n )
722 {return mvwgetnstr( win, y, x, str, n );}
723 
724 #undef mvwgetnstr
725 #define mvwgetnstr UNDEF(mvwgetnstr)
726 #endif
727 
728 #ifdef mvwinch
729 inline chtype UNDEF( mvwinch )( WINDOW *win, int y, int x )
730 {
731  return mvwinch( win, y, x );
732 }
733 
734 #undef mvwinch
735 #define mvwinch UNDEF(mvwinch)
736 #endif
737 
738 #ifdef mvwin_wch
739 inline int UNDEF( mvwin_wch )( WINDOW *win, int y, int x, cchar_t * cch )
740 {
741  return mvwin_wch( win, y, x, cch );
742 }
743 
744 #undef mvwin_wch
745 #define mvwin_wch UNDEF(mvwin_wch)
746 #endif
747 
748 #ifdef mvwinsch
749 inline int UNDEF( mvwinsch )( WINDOW *win, int y, int x, char c )
750 { return mvwinsch( win, y, x, c ); }
751 
752 #undef mvwinsch
753 #define mvwinsch UNDEF(mvwinsch)
754 #endif
755 
756 #ifdef mvaddch
757 inline int UNDEF( mvaddch )( int y, int x, chtype ch )
758 { return mvaddch( y, x, ch ); }
759 
760 #undef mvaddch
761 #define mvaddch UNDEF(mvaddch)
762 #endif
763 
764 #ifdef mvaddnstr
765 inline int UNDEF( mvaddnstr )( int y, int x, const char *str, int n )
766 { return mvaddnstr( y, x, ( char* )str, n ); }
767 
768 #undef mvaddnstr
769 #define mvaddnstr UNDEF(mvaddnstr)
770 #endif
771 
772 #ifdef mvaddstr
773 inline int UNDEF( mvaddstr )( int y, int x, const char * str )
774 { return mvaddstr( y, x, ( char* )str ); }
775 
776 #undef mvaddstr
777 #define mvaddstr UNDEF(mvaddstr)
778 #endif
779 
780 #ifdef mvwadd_wch
781 inline int UNDEF( mvwadd_wch )( WINDOW *win, int y, int x, const cchar_t * cch )
782 { return mvwadd_wch( win, y, x, ( cchar_t* )cch ); }
783 
784 #undef mvwadd_wch
785 #define mvwadd_wch UNDEF(mvwadd_wch)
786 #endif
787 
788 #ifdef mvdelch
789 inline int UNDEF( mvdelch )( int y, int x ) { return mvdelch( y, x );}
790 
791 #undef mvdelch
792 #define mvdelch UNDEF(mvdelch)
793 #endif
794 
795 #ifdef mvgetch
796 inline int UNDEF( mvgetch )( int y, int x ) { return mvgetch( y, x );}
797 
798 #undef mvgetch
799 #define mvgetch UNDEF(mvgetch)
800 #endif
801 
802 #ifdef mvgetstr
803 inline int UNDEF( mvgetstr )( int y, int x, char *str ) {return mvgetstr( y, x, str );}
804 
805 #undef mvgetstr
806 #define mvgetstr UNDEF(mvgetstr)
807 #endif
808 
809 #ifdef mvgetnstr
810 inline int UNDEF( mvgetnstr )( int y, int x, char *str, int n )
811 {
812  return mvgetnstr( y, x, str, n );
813 }
814 
815 #undef mvgetnstr
816 #define mvgetnstr UNDEF(mvgetnstr)
817 #endif
818 
819 #ifdef mvinch
820 inline chtype UNDEF( mvinch )( int y, int x ) { return mvinch( y, x );}
821 
822 #undef mvinch
823 #define mvinch UNDEF(mvinch)
824 #endif
825 
826 #ifdef mvinsch
827 inline int UNDEF( mvinsch )( int y, int x, char c )
828 { return mvinsch( y, x, c ); }
829 
830 #undef mvinsch
831 #define mvinsch UNDEF(mvinsch)
832 #endif
833 
834 #ifdef napms
835 inline void UNDEF( napms )( unsigned long x ) { napms( x ); }
836 
837 #undef napms
838 #define napms UNDEF(napms)
839 #endif
840 
841 #ifdef fixterm
842 inline int UNDEF( fixterm )( void ) { return fixterm(); }
843 
844 #undef fixterm
845 #define fixterm UNDEF(fixterm)
846 #endif
847 
848 #ifdef resetterm
849 inline int UNDEF( resetterm )( void ) { return resetterm(); }
850 
851 #undef resetterm
852 #define resetterm UNDEF(resetterm)
853 #endif
854 
855 #ifdef saveterm
856 inline int UNDEF( saveterm )( void ) { return saveterm(); }
857 
858 #undef saveterm
859 #define saveterm UNDEF(saveterm)
860 #endif
861 
862 #ifdef crmode
863 inline int UNDEF( crmode )( void ) { return crmode(); }
864 
865 #undef crmode
866 #define crmode UNDEF(crmode)
867 #endif
868 
869 #ifdef nocrmode
870 inline int UNDEF( nocrmode )( void ) { return nocrmode(); }
871 
872 #undef nocrmode
873 #define nocrmode UNDEF(nocrmode)
874 #endif
875 
876 #ifdef getbkgd
877 inline chtype UNDEF( getbkgd )( const WINDOW *win ) { return getbkgd( win ); }
878 
879 #undef getbkgd
880 #define getbkgd UNDEF(getbkgd)
881 #endif
882 
883 #ifdef bkgd
884 inline int UNDEF( bkgd )( chtype ch ) { return bkgd( ch ); }
885 
886 #undef bkgd
887 #define bkgd UNDEF(bkgd)
888 #endif
889 
890 #ifdef bkgdset
891 inline void UNDEF( bkgdset )( chtype ch ) { bkgdset( ch ); }
892 
893 #undef bkgdset
894 #define bkgdset UNDEF(bkgdset)
895 #endif
896 
897 template <class _Tp> inline int ncursesMaxCoord() { return INT_MAX; }
898 template <> inline int ncursesMaxCoord<short>() { return SHRT_MAX; }
899 
900 /**
901  * @short C++ class for windows.
902 */
903 
905 {
906  friend std::ostream & operator<<( std::ostream & Stream, const NCursesWindow & Obj_Cv );
907  friend std::ostream & operator<<( std::ostream & Stream, const NCursesWindow * Obj_Cv );
908 
909  friend class NCursesMenu;
910  friend class NCursesForm;
911 
912 private:
913  static bool b_initialized;
914  static void initialize();
915  static int ripoff_init( WINDOW *, int );
916 
917  void init();
918 
919  short getcolor( int getback ) const;
920 
921  static int setpalette( short fore, short back, short pair );
922  static int colorInitialized;
923 
924  /**
925  * This private constructor is only used during the initialization
926  * of windows generated by ripoffline() calls.
927  */
928  NCursesWindow( WINDOW* win, int cols );
929 
930 protected:
931  /**
932  * Signal an error with the given message text.
933  */
934  void err_handler( const char * ) const THROWS( NCursesException );
935 
936  /**
937  * count of all active windows
938  */
939  static long count;
940  // We rely on the c++ promise that
941  // all otherwise uninitialized
942  // static class vars are set to 0
943 
944  /**
945  * the curses WINDOW
946  */
947  WINDOW* w;
948 
949  /**
950  * TRUE if we own the WINDOW
951  */
952  bool alloced;
953 
954  /**
955  * parent, if subwindow
956  */
958  /**
959  * head of subwindows std::list
960  */
962  /**
963  * next subwindow of parent
964  */
966 
967  /**
968  * Destroy all subwindows.
969  */
970  void kill_subwindows();
971 
972  /**
973  * Only for use by derived classes. They are then in charge to
974  * fill the member variables correctly.
975  */
976  NCursesWindow();
977 
978 public:
979  /**
980  * Constructor. Useful only for stdscr
981  **/
982  NCursesWindow( WINDOW* window );
983 
984  /**
985  * Constructor.
986  **/
987  NCursesWindow( int lines,
988  int cols,
989  int begin_y,
990  int begin_x );
991 
992  /**
993  * Constructor.
994  *
995  * If 'absrel' is 'a', begin_x/y are absolute screen pos,
996  * if `r', they are relative to parent origin.
997  **/
999  int lines,
1000  int cols,
1001  int begin_y,
1002  int begin_x,
1003  char absrel = 'a' );
1004 
1005  /**
1006  * Destructor.
1007  **/
1008  virtual ~NCursesWindow();
1009 
1010  /**
1011  * Make an exact copy of the window.
1012  */
1013  NCursesWindow Clone();
1014 
1015  // -------------------------------------------------------------------------
1016  // Initialization.
1017  // -------------------------------------------------------------------------
1018  /**
1019  * Call this routine very early if you want to have colors.
1020  */
1021  static void useColors( void );
1022 
1023  /**
1024  * This function is used to generate a window of ripped-of lines.
1025  * If the argument is positive, lines are removed from the top, if it
1026  * is negative lines are removed from the bottom. This enhances the
1027  * lowlevel ripoffline() function because it uses the internal
1028  * implementation that allows to remove more than just a single line.
1029  * This function must be called before any other ncurses function. The
1030  * creation of the window is defered until ncurses gets initialized.
1031  * The initialization function is then called.
1032  */
1033  static int ripoffline( int ripoff_lines,
1034  int ( *init )( NCursesWindow& win ) );
1035 
1036  // -------------------------------------------------------------------------
1037  // terminal status
1038  // -------------------------------------------------------------------------
1039  /**
1040  * Number of lines on terminal, *not* window
1041  */
1042  static int lines() { initialize(); return LINES; }
1043 
1044  /**
1045  * Number of cols on terminal, *not* window
1046  */
1047  static int cols() { initialize(); return COLS; }
1048 
1049  /**
1050  * Size of a tab on terminal, *not* window
1051  */
1052  static int tabsize() { initialize(); return TABSIZE; }
1053 
1054  /**
1055  * Number of available colors
1056  */
1057  static int NumberOfColors();
1058 
1059  /**
1060  * Number of available colors
1061  */
1062  int colors() const { return NumberOfColors(); }
1063 
1064  // -------------------------------------------------------------------------
1065  // window status
1066  // -------------------------------------------------------------------------
1067  /**
1068  * Number of lines in this window
1069  */
1070  int height() const { return maxy() + 1; }
1071 
1072  /**
1073  * Number of columns in this window
1074  */
1075  int width() const { return maxx() + 1; }
1076 
1077  /**
1078  * Column of top left corner relative to stdscr
1079  */
1080  int begx() const { return getbegx(w); }
1081 
1082  /**
1083  * Line of top left corner relative to stdscr
1084  */
1085  int begy() const { return getbegy(w); }
1086 
1087  /**
1088  * Largest x coord in window
1089  */
1090  int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
1091 
1092  /**
1093  * Largest y coord in window
1094  */
1095  int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
1096 
1097  /** Ncurses up to ncurses5 internally uses \c short. */
1098  static int maxcoord() { return ncursesMaxCoord<NCURSES_SIZE_T>(); }
1099 
1100  wsze size() const { return wsze( height(), width() ); }
1101 
1102  wpos begpos() const { return wpos( begy(), begx() ); }
1103 
1104  wpos maxpos() const { return wpos( maxy(), maxx() ); }
1105 
1106  wrect area() const { return wrect( begpos(), size() ); }
1107 
1108  /**
1109  * Actual color pair
1110  */
1111  short getcolor() const;
1112 
1113  /**
1114  * Actual foreground color
1115  */
1116  short foreground() const { return getcolor( 0 ); }
1117 
1118  /**
1119  * Actual background color
1120  */
1121  short background() const { return getcolor( 1 ); }
1122 
1123  /**
1124  * Set color palette entry
1125  */
1126  int setpalette( short fore, short back );
1127 
1128  /**
1129  * Set actually used palette entry
1130  */
1131  int setcolor( short pair );
1132 
1133  // -------------------------------------------------------------------------
1134  // window positioning
1135  // -------------------------------------------------------------------------
1136  /**
1137  * Move window to new position with the new position as top left corner.
1138  * This is virtual because it is redefined in NCursesPanel.
1139  */
1140  virtual int mvwin( int begin_y, int begin_x )
1141  {
1142  return ::mvwin( w, begin_y, begin_x );
1143  }
1144 
1145  int mvsubwin( NCursesWindow* sub, int begin_y, int begin_x );
1146 
1147  virtual int resize( int lines, int columns );
1148 
1149  // -------------------------------------------------------------------------
1150  // coordinate positioning
1151  // -------------------------------------------------------------------------
1152  /**
1153  * Move cursor the this position
1154  */
1155  int move( int y, int x ) { return ::wmove( w, y, x ); }
1156 
1157  /**
1158  * Get current position of the cursor
1159  */
1160  void getyx( int& y, int& x ) const { ::getyx( w, y, x ); }
1161 
1162  /**
1163  * Perform lowlevel cursor motion that takes effect immediately.
1164  */
1165  int mvcur( int oldrow, int oldcol, int newrow, int newcol ) const
1166  {
1167  return ::mvcur( oldrow, oldcol, newrow, newcol );
1168  }
1169 
1170  // -------------------------------------------------------------------------
1171  // input
1172  // -------------------------------------------------------------------------
1173 
1174  int nodelay( bool bf ) { return ::nodelay( w, bf ); }
1175 
1176  /**
1177  * Get a keystroke from the window.
1178  */
1179  int getch() { return ::wgetch( w ); }
1180 
1181  /**
1182  * Move cursor to position and get a keystroke from the window
1183  */
1184  int getch( int y, int x ) { return ::mvwgetch( w, y, x ); }
1185 
1186  /**
1187  * Read a series of characters into str until a newline or carriage return
1188  * is received. Read at most n characters. If n is negative, the limit is
1189  * ignored.
1190  */
1191  int getstr( char* str, int n = -1 )
1192  {
1193  return ::wgetnstr( w, str, n );
1194  }
1195 
1196  /**
1197  * Move the cursor to the requested position and then perform the getstr()
1198  * as described above.
1199  */
1200  int getstr( int y, int x, char* str, int n = -1 )
1201  {
1202  return ::mvwgetnstr( w, y, x, str, n );
1203  }
1204 
1205  /**
1206  * Get a std::string of characters from the window into the buffer s. Retrieve
1207  * at most n characters, if n is negative retrieve all characters up to the
1208  * end of the current line. Attributes are stripped from the characters.
1209  */
1210  int instr( char *s, int n = -1 ) { return ::winnstr( w, s, n ); }
1211 
1212  /**
1213  * Move the cursor to the requested position and then perform the instr()
1214  * as described above.
1215  */
1216  int instr( int y, int x, char *s, int n = -1 )
1217  {
1218  return ::mvwinnstr( w, y, x, s, n );
1219  }
1220 
1221 
1222  // -------------------------------------------------------------------------
1223  // output
1224  // -------------------------------------------------------------------------
1225  /**
1226  * Put attributed character to the window.
1227  */
1228  int addch( const char ch )
1229  {
1230  return addch(( const chtype )( ch&A_CHARTEXT ) );
1231  }
1232 
1233  int addch( const chtype ch ) { return ::waddch( w, ch ); }
1234 
1235  /**
1236  * Put attributed character from given position to the window.
1237  */
1238  int add_attr_char( int y, int x );
1239  int add_attr_char();
1240 
1241  /**
1242  * Put a combined character to the window.
1243  */
1244  int add_wch( const cchar_t * cch ) { return ::wadd_wch( w, cch ); }
1245 
1246  int add_wch( int y, int x, const cchar_t * cch ) { return mvwadd_wch( w, y, x, cch ); }
1247 
1248  /**
1249  * Move cursor to the requested position and then put attributed character
1250  * to the window.
1251  */
1252  int addch( int y, int x, const char ch )
1253  {
1254  return addch( y, x, ( const chtype )( ch&A_CHARTEXT ) );
1255  }
1256 
1257  int addch( int y, int x, const chtype ch )
1258  {
1259  return ::mvwaddch( w, y, x, ch );
1260  }
1261 
1262  /**
1263  * Put attributed character to the window and refresh it immediately.
1264  */
1265  int echochar( const char ch )
1266  {
1267  return echochar(( const chtype )( ch&A_CHARTEXT ) );
1268  }
1269 
1270  int echochar( const chtype ch ) { return ::wechochar( w, ch ); }
1271 
1272  /**
1273  * Write the std::string str to the window, stop writing if the terminating
1274  * NUL or the limit n is reached. If n is negative, it is ignored.
1275  */
1276  int addstr( const char* str, int n = -1 )
1277  {
1278  return ::waddnstr( w, ( char* )str, n );
1279  }
1280 
1281  /**
1282  * Move the cursor to the requested position and then perform the addstr
1283  * as described above.
1284  */
1285  int addstr( int y, int x, const char * str, int n = -1 )
1286  {
1287  return ::mvwaddnstr( w, y, x, ( char* )str, n );
1288  }
1289 
1290  /**
1291  * Write the wchar_t str to the window, stop writing if the terminating
1292  * NUL or the limit n is reached. If n is negative, it is ignored.
1293  */
1294  int addwstr( const wchar_t* str, int n = -1 );
1295 
1296  /**
1297  * Move the cursor to the requested position and then perform the addwstr
1298  * as described above.
1299  */
1300  int addwstr( int y, int x, const wchar_t * str, int n = -1 );
1301 
1302  /**
1303  * Do a formatted print to the window.
1304  */
1305  int printw( const char* fmt, ... )
1306 #if __GNUG__ >= 2
1307  __attribute__(( format( printf, 2, 3 ) ) );
1308 #else
1309  ;
1310 #endif
1311 
1312  /**
1313  * Move the cursor and then do a formatted print to the window.
1314  */
1315  int printw( int y, int x, const char * fmt, ... )
1316 #if __GNUG__ >= 2
1317  __attribute__(( format( printf, 4, 5 ) ) );
1318 #else
1319  ;
1320 #endif
1321 
1322  /**
1323  * Retrieve attributed character under the current cursor position.
1324  */
1325  chtype inch() const { return ::winch( w ); }
1326 
1327  chtype inchar() const { return inch()&( A_CHARTEXT | A_ALTCHARSET ); }
1328 
1329  /**
1330  * Move cursor to requested position and then retrieve attributed character
1331  * at this position.
1332  */
1333  chtype inch( int y, int x ) { return ::mvwinch( w, y, x ); }
1334 
1335  chtype inchar( int y, int x ) { return inch( y, x )&( A_CHARTEXT | A_ALTCHARSET ); }
1336 
1337  /**
1338  * Retrieve combined character under the current cursor position.
1339  */
1340  int in_wchar( cchar_t * cchar );
1341  int in_wchar( int y, int x, cchar_t * cchar );
1342 
1343  /**
1344  * Insert attributed character into the window before current cursor
1345  * position.
1346  */
1347  int insch( chtype ch ) { return ::winsch( w, ch ); }
1348 
1349  /**
1350  * Move cursor to requested position and then insert the attributed
1351  * character before that position.
1352  */
1353  int insch( int y, int x, chtype ch )
1354  {
1355  return ::mvwinsch( w, y, x, ch );
1356  }
1357 
1358  /**
1359  * Move cursor to requested position and then insert the attributed
1360  * character before that position.
1361  */
1362  int ins_wch( int y, int x, const cchar_t * cchar )
1363  {
1364  return mvwins_wch( w, y, x, cchar );
1365  }
1366 
1367  /**
1368  * Insert an empty line above the current line.
1369  */
1370  int insertln() { return ::winsdelln( w, 1 ); }
1371 
1372  /**
1373  * If n>0 insert that many lines above the current line. If n<0 delete
1374  * that many lines beginning with the current line.
1375  */
1376  int insdelln( int n = 1 ) { return ::winsdelln( w, n ); }
1377 
1378  /**
1379  * Insert the std::string into the window before the current cursor position.
1380  * Insert stops at end of std::string or when the limit n is reached. If n is
1381  * negative, it is ignored.
1382  */
1383  int insstr( const char *s, int n = -1 )
1384  {
1385  return ::winsnstr( w, s, n );
1386  }
1387 
1388  /**
1389  * Move the cursor to the requested position and then perform the insstr()
1390  * as described above.
1391  */
1392  int insstr( int y, int x, const char *s, int n = -1 )
1393  {
1394  return ::mvwinsnstr( w, y, x, s, n );
1395  }
1396 
1397  /**
1398  * Switch on the window attributes;
1399  */
1400  int attron( chtype at ) { return ::wattron( w, at ); }
1401 
1402  /**
1403  * Switch off the window attributes;
1404  */
1405  int attroff( chtype at ) { return ::wattroff( w, at ); }
1406 
1407  /**
1408  * Set the window attributes;
1409  */
1410  int attrset( chtype at ) { return ::wattrset( w, at ); }
1411 
1412  /**
1413  * Change the attributes of the next n characters in the current line. If
1414  * n is negative or greater than the number of remaining characters in the
1415  * line, the attributes will be changed up to the end of the line.
1416  */
1417  int chgat( int n, attr_t attr, short color, const void *opts = NULL )
1418  {
1419  return ::wchgat( w, n, attr, color, opts );
1420  }
1421 
1422  /**
1423  * Move the cursor to the requested position and then perform chgat() as
1424  * described above.
1425  */
1426  int chgat( int y, int x,
1427  int n, attr_t attr, short color, const void *opts = NULL )
1428  {
1429  return ::mvwchgat( w, y, x, n, attr, color, opts );
1430  }
1431 
1432  // -------------------------------------------------------------------------
1433  // background
1434  // -------------------------------------------------------------------------
1435  /**
1436  * Get current background setting.
1437  */
1438  chtype getbkgd() const { return ::getbkgd( w ); }
1439 
1440  /**
1441  * Set the background property and apply it to the window.
1442  */
1443  int bkgd( const chtype ch ) { return ::wbkgd( w, ch ); }
1444 
1445  /**
1446  * Set the background property.
1447  */
1448  void bkgdset( chtype ch ) { ::wbkgdset( w, ch ); }
1449 
1450  // -------------------------------------------------------------------------
1451  // borders
1452  // -------------------------------------------------------------------------
1453  /**
1454  * Draw a box around the window with the given vertical and horizontal
1455  * drawing characters. If you specifiy a zero as character, curses will try
1456  * to find a "nice" character.
1457  */
1458  // int box(chtype vert=0, chtype hor=0) {
1459  // return ::wborder(w, vert, vert, hor, hor, 0, 0 ,0, 0); }
1460 
1461  // workaround for 8.1: don't use wborder to draw the box
1462  int box() { return box( wrect( wpos( 0, 0 ), size() ) ); }
1463 
1464  /**
1465  * Draw a border around the window with the given characters for the
1466  * various parts of the border. If you pass zero for a character, curses
1467  * will try to find "nice" characters.
1468  */
1469  int border( chtype left = 0, chtype right = 0,
1470  chtype top = 0, chtype bottom = 0,
1471  chtype top_left = 0, chtype top_right = 0,
1472  chtype bottom_left = 0, chtype bottom_right = 0 )
1473  {
1474  return ::wborder( w, left, right, top, bottom, top_left, top_right,
1475  bottom_left, bottom_right );
1476  }
1477 
1478  // -------------------------------------------------------------------------
1479  // lines and boxes
1480  // -------------------------------------------------------------------------
1481  /**
1482  * Draw a horizontal line of len characters with the given character. If
1483  * you pass zero for the character, curses will try to find a "nice" one.
1484  */
1485  int hline( int len, chtype ch = 0 ) { return ::whline( w, ch, len ); }
1486 
1487  /**
1488  * Move the cursor to the requested position and then draw a horizontal line.
1489  */
1490  int hline( int y, int x, int len, chtype ch = 0 )
1491  {
1492  return ::mvwhline( w, y, x, ch, len );
1493  }
1494 
1495  /**
1496  * Draw a vertical line of len characters with the given character. If
1497  * you pass zero for the character, curses will try to find a "nice" one.
1498  */
1499  int vline( int len, chtype ch = 0 ) { return ::wvline( w, ch, len ); }
1500 
1501  /**
1502  * Move the cursor to the requested position and then draw a vertical line.
1503  */
1504  int vline( int y, int x, int len, chtype ch = 0 )
1505  {
1506  return ::mvwvline( w, y, x, ch, len );
1507  }
1508 
1509  int box( const wrect & dim );
1510 
1511  // -------------------------------------------------------------------------
1512  // erasure
1513  // -------------------------------------------------------------------------
1514  /**
1515  * Erase the window.
1516  */
1517  int erase() { return ::werase( w ); }
1518 
1519  /**
1520  * Clear the window.
1521  */
1522  int clear() { return ::wclear( w ); }
1523 
1524  /**
1525  * Set/Reset the clear flag. If std::set, the next refresh() will clear the
1526  * screen.
1527  */
1528  int clearok( bool bf ) { return ::clearok( w, bf ); }
1529 
1530  /**
1531  * Clear to the end of the window.
1532  */
1533  int clrtobot() { return ::wclrtobot( w ); }
1534 
1535  /**
1536  * Clear to the end of the line.
1537  */
1538  int clrtoeol() { return ::wclrtoeol( w ); }
1539 
1540  /**
1541  * Delete character under the cursor.
1542  */
1543  int delch() { return ::wdelch( w ); }
1544 
1545  /**
1546  * Move cursor to requested position and delete the character under the
1547  * cursor.
1548  */
1549  int delch( int y, int x ) { return ::mvwdelch( w, y, x ); }
1550 
1551  /**
1552  * Delete the current line.
1553  */
1554  int deleteln() { return ::winsdelln( w, -1 ); }
1555 
1556  // -------------------------------------------------------------------------
1557  // screen control
1558  // -------------------------------------------------------------------------
1559  /**
1560  * Scroll amount lines. If amount is positive, scroll up, otherwise
1561  * scroll down.
1562  */
1563  int scroll( int amount = 1 ) { return ::wscrl( w, amount ); }
1564 
1565  /**
1566  * If bf is TRUE, window scrolls if cursor is moved off the bottom
1567  * edge of the window or a scrolling region, otherwise the cursor is left
1568  * at the bottom line.
1569  */
1570  int scrollok( bool bf ) { return ::scrollok( w, bf ); }
1571 
1572  /**
1573  * Define a soft scrolling region.
1574  */
1575  int setscrreg( int from, int to )
1576  {
1577  return ::wsetscrreg( w, from, to );
1578  }
1579 
1580  /**
1581  * If bf is TRUE, use insert/delete line hardware support if possible.
1582  * Otherwise do it in software.
1583  */
1584  int idlok( bool bf ) { return ::idlok( w, bf ); }
1585 
1586  /**
1587  * If bf is TRUE, use insert/delete character hardware support if possible.
1588  * Otherwise do it in software.
1589  */
1590  void idcok( bool bf ) { ::idcok( w, bf ); }
1591 
1592  /**
1593  * Mark the whole window as modified.
1594  */
1595  int touchwin() { return ::wtouchln( w, 0, height(), 1 ); }
1596 
1597  /**
1598  * Mark the whole window as unmodified.
1599  */
1600  int untouchwin() { return ::wtouchln( w, 0, height(), 0 ); }
1601 
1602  /**
1603  * Mark cnt lines beginning from line s as changed or unchanged, depending
1604  * on the value of the changed flag.
1605  */
1606  int touchln( int s, int cnt, bool changed = TRUE )
1607  {
1608  return ::wtouchln( w, s, cnt, ( int )( changed ? 1 : 0 ) );
1609  }
1610 
1611  /**
1612  * Return TRUE if line is marked as changed, FALSE otherwise
1613  */
1614  bool is_linetouched( int line ) const
1615  {
1616  return ( ::is_linetouched( w, line ) ? TRUE : FALSE );
1617  }
1618 
1619  /**
1620  * Return TRUE if window is marked as changed, FALSE otherwise
1621  */
1622  bool is_wintouched() const
1623  {
1624  return ( ::is_wintouched( w ) ? TRUE : FALSE );
1625  }
1626 
1627  /**
1628  * If bf is TRUE, curses will leave the cursor after an update whereever
1629  * it is after the update.
1630  */
1631  int leaveok( bool bf ) { return ::leaveok( w, bf ); }
1632 
1633  /**
1634  * Redraw n lines starting from the requested line
1635  */
1636  int redrawln( int from, int n ) { return ::wredrawln( w, from, n ); }
1637 
1638  /**
1639  * Redraw the whole window
1640  */
1641  int redrawwin() { return ::wredrawln( w, 0, height() ); }
1642 
1643  /**
1644  * Do all outputs to make the physical screen looking like the virtual one
1645  */
1646  int doupdate() { return ::doupdate(); }
1647 
1648  /**
1649  * Propagate the changes down to all descendant windows
1650  */
1651  void syncdown() { ::wsyncdown( w ); }
1652 
1653  /**
1654  * Propagate the changes up in the hierarchy
1655  */
1656  void syncup() { ::wsyncup( w ); }
1657 
1658  /**
1659  * Position the cursor in all ancestor windows corresponding to our setting
1660  */
1661  void cursyncup() { ::wcursyncup( w ); }
1662 
1663  /**
1664  * If called with bf=TRUE, syncup() is called whenever the window is changed
1665  */
1666  int syncok( bool bf ) { return ::syncok( w, bf ); }
1667 
1668 #ifndef _no_flushok
1669  int flushok( bool bf ) { return ::flushok( w, bf ); }
1670 
1671 #endif
1672 
1673  /**
1674  * If called with bf=TRUE, any change in the window will cause an
1675  * automatic immediate refresh()
1676  */
1677  void immedok( bool bf ) { ::immedok( w, bf ); }
1678 
1679  /**
1680  * If called with bf=TRUE, the application will interpret function keys.
1681  */
1682  int keypad( bool bf ) { return ::keypad( w, bf ); }
1683 
1684  /**
1685  * If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
1686  * 7-Bit characters are generated.
1687  */
1688  int meta( bool bf ) { return ::meta( w, bf ); }
1689 
1690  /**
1691  * Enable "standout" attributes
1692  */
1693  int standout() { return ::wstandout( w ); }
1694 
1695  /**
1696  * Disable "standout" attributes
1697  */
1698  int standend() { return ::wstandend( w ); }
1699 
1700  // -------------------------------------------------------------------------
1701  // The next two are virtual, because we redefine them in the
1702  // NCursesPanel class.
1703  // -------------------------------------------------------------------------
1704  /**
1705  * Propagate the changes in this window to the virtual screen and call
1706  * doupdate(). This is redefined in NCursesPanel.
1707  */
1708  virtual int refresh() { return ::wrefresh( w ); }
1709 
1710  /**
1711  * Propagate the changes in this window to the virtual screen. This is
1712  * redefined in NCursesPanel.
1713  */
1714  virtual int noutrefresh() { return ::wnoutrefresh( w ); }
1715 
1716  // -------------------------------------------------------------------------
1717  // multiple window control
1718  // -------------------------------------------------------------------------
1719  /**
1720  * Overlay this window over win.
1721  */
1723  {
1724  return ::overlay( w, win.w );
1725  }
1726 
1727  /**
1728  * Overwrite win with this window.
1729  */
1731  {
1732  return ::overwrite( w, win.w );
1733  }
1734 
1735  /**
1736  * Overlay or overwrite the rectangle in win given by dminrow,dmincol,
1737  * dmaxrow,dmaxcol with the rectangle in this window beginning at
1738  * sminrow,smincol.
1739  */
1741  int sminrow, int smincol,
1742  int dminrow, int dmincol,
1743  int dmaxrow, int dmaxcol, bool overlay = TRUE )
1744  {
1745  return ::copywin( w, win.w, sminrow, smincol, dminrow, dmincol,
1746  dmaxrow, dmaxcol, ( int )( overlay ? 1 : 0 ) );
1747  }
1748 
1749  // -------------------------------------------------------------------------
1750  // Mouse related
1751  // -------------------------------------------------------------------------
1752  /**
1753  * Return TRUE if terminal supports a mouse, FALSE otherwise
1754  */
1755  bool has_mouse() const;
1756 
1757  // -------------------------------------------------------------------------
1758  // traversal support
1759  // -------------------------------------------------------------------------
1760  /**
1761  * Get the first child window.
1762  */
1763  NCursesWindow* child() { return subwins; }
1764 
1765  const NCursesWindow* child() const { return subwins; }
1766 
1767  /**
1768  * Get the next child of my parent.
1769  */
1770  NCursesWindow* sibling() { return sib; }
1771 
1772  const NCursesWindow* sibling() const { return sib; }
1773 
1774  /**
1775  * Get my parent.
1776  */
1777  NCursesWindow* parent() { return par; }
1778 
1779  const NCursesWindow* parent() const { return par; }
1780 
1781  /**
1782  * Return TRUE if win is a descendant of this.
1783  */
1784  bool isDescendant( NCursesWindow& win );
1785 };
1786 
1787 /**
1788  * @short We leave this here for compatibility reasons.
1789 */
1790 
1792 {
1793 
1794 public:
1795  /**
1796  * Constructor. Useful only for stdscr
1797  */
1798  NCursesColorWindow( WINDOW* &window )
1799  : NCursesWindow( window )
1800  {
1801  useColors();
1802  }
1803 
1804  /**
1805  * Constructor.
1806  **/
1808  int cols,
1809  int begin_y,
1810  int begin_x )
1811  : NCursesWindow( lines, cols, begin_y, begin_x )
1812  {
1813  useColors();
1814  }
1815 
1816  /**
1817  * Constructor.
1818  *
1819  * If 'absrel' is 'a', begin_x/y are absolute screen pos,
1820  * else if 'r', they are relative to par origin
1821  */
1823  int lines,
1824  int cols,
1825  int begin_y,
1826  int begin_x,
1827  char absrel = 'a' )
1828  : NCursesWindow( par, lines, cols,
1829  begin_y, begin_x,
1830  absrel )
1831  {
1832  useColors();
1833  }
1834 };
1835 
1836 /**
1837  * @short
1838 */
1839 
1841 {
1842 
1843 public:
1844  NCursesPad( int lines, int cols );
1845 
1846  /**
1847  * Put the attributed character onto the pad and immediately do a
1848  * prefresh().
1849  */
1850  int echochar( const chtype ch ) { return ::pechochar( w, ch ); }
1851 
1852  /**
1853  * For Pad's we reimplement refresh() and noutrefresh() to do nothing.
1854  * You should call the versions with the argument std::list that are specific
1855  * for Pad's.
1856  */
1857  int refresh() { return OK; };
1858 
1859  int noutrefresh() { return OK; };
1860 
1861  /**
1862  * The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
1863  * on the screen. <b>refresh</b> copies a rectangle of this size beginning
1864  * with top left corner pminrow,pmincol onto the screen and calls doupdate().
1865  */
1866  int refresh( int pminrow, int pmincol,
1867  int sminrow, int smincol,
1868  int smaxrow, int smaxcol )
1869  {
1870  return ::prefresh( w, pminrow, pmincol,
1871  sminrow, smincol, smaxrow, smaxcol );
1872  }
1873 
1874  /**
1875  * Does the same like refresh() but without calling doupdate().
1876  */
1877  int noutrefresh( int pminrow, int pmincol,
1878  int sminrow, int smincol,
1879  int smaxrow, int smaxcol )
1880  {
1881  return ::pnoutrefresh( w, pminrow, pmincol,
1882  sminrow, smincol, smaxrow, smaxcol );
1883  }
1884 };
1885 
1886 #endif // _CURSESW_H
int hline(int y, int x, int len, chtype ch=0)
Definition: ncursesw.h:1490
int overlay(NCursesWindow &win)
Definition: ncursesw.h:1722
We leave this here for compatibility reasons.
Definition: ncursesw.h:1791
C++ class for windows.
Definition: ncursesw.h:904
void kill_subwindows()
Definition: ncursesw.cc:436
int printw(const char *fmt,...)
Definition: ncursesw.cc:75
void syncup()
Definition: ncursesw.h:1656
static int lines()
Definition: ncursesw.h:1042
short getcolor() const
Definition: ncursesw.cc:556
int echochar(const chtype ch)
Definition: ncursesw.h:1850
static int tabsize()
Definition: ncursesw.h:1052
NCursesWindow * parent()
Definition: ncursesw.h:1777
int vline(int len, chtype ch=0)
Definition: ncursesw.h:1499
int bkgd(const chtype ch)
Definition: ncursesw.h:1443
void idcok(bool bf)
Definition: ncursesw.h:1590
int vline(int y, int x, int len, chtype ch=0)
Definition: ncursesw.h:1504
void bkgdset(chtype ch)
Definition: ncursesw.h:1448
NCursesWindow * par
Definition: ncursesw.h:957
int insch(int y, int x, chtype ch)
Definition: ncursesw.h:1353
int addstr(int y, int x, const char *str, int n=-1)
Definition: ncursesw.h:1285
short foreground() const
Definition: ncursesw.h:1116
int clearok(bool bf)
Definition: ncursesw.h:1528
int maxx() const
Definition: ncursesw.h:1090
bool isDescendant(NCursesWindow &win)
Definition: ncursesw.cc:419
int delch(int y, int x)
Definition: ncursesw.h:1549
int insertln()
Definition: ncursesw.h:1370
short background() const
Definition: ncursesw.h:1121
virtual int refresh()
Definition: ncursesw.h:1708
int colors() const
Definition: ncursesw.h:1062
int syncok(bool bf)
Definition: ncursesw.h:1666
static int cols()
Definition: ncursesw.h:1047
int chgat(int y, int x, int n, attr_t attr, short color, const void *opts=NULL)
Definition: ncursesw.h:1426
static int NumberOfColors()
Definition: ncursesw.cc:547
int insch(chtype ch)
Definition: ncursesw.h:1347
int noutrefresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
Definition: ncursesw.h:1877
static int maxcoord()
Definition: ncursesw.h:1098
int idlok(bool bf)
Definition: ncursesw.h:1584
int setcolor(short pair)
Definition: ncursesw.cc:584
void syncdown()
Definition: ncursesw.h:1651
NCursesColorWindow(NCursesWindow &par, int lines, int cols, int begin_y, int begin_x, char absrel= 'a')
Definition: ncursesw.h:1822
int clrtoeol()
Definition: ncursesw.h:1538
int hline(int len, chtype ch=0)
Definition: ncursesw.h:1485
int addch(int y, int x, const char ch)
Definition: ncursesw.h:1252
Definition: position.h:109
int attroff(chtype at)
Definition: ncursesw.h:1405
void immedok(bool bf)
Definition: ncursesw.h:1677
int overwrite(NCursesWindow &win)
Definition: ncursesw.h:1730
int copywin(NCursesWindow &win, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, bool overlay=TRUE)
Definition: ncursesw.h:1740
NCursesColorWindow(WINDOW *&window)
Definition: ncursesw.h:1798
int addwstr(const wchar_t *str, int n=-1)
Definition: ncursesw.cc:123
void err_handler(const char *) const THROWS(NCursesException)
Definition: ncursesw.cc:230
int doupdate()
Definition: ncursesw.h:1646
virtual ~NCursesWindow()
Definition: ncursesw.cc:455
int height() const
Definition: ncursesw.h:1070
int instr(char *s, int n=-1)
Definition: ncursesw.h:1210
int standout()
Definition: ncursesw.h:1693
int standend()
Definition: ncursesw.h:1698
int add_attr_char(int y, int x)
Definition: ncursesw.cc:166
int addch(const char ch)
Definition: ncursesw.h:1228
int setscrreg(int from, int to)
Definition: ncursesw.h:1575
int redrawwin()
Definition: ncursesw.h:1641
int in_wchar(cchar_t *cchar)
Definition: ncursesw.cc:153
static long count
Definition: ncursesw.h:939
int border(chtype left=0, chtype right=0, chtype top=0, chtype bottom=0, chtype top_left=0, chtype top_right=0, chtype bottom_left=0, chtype bottom_right=0)
Definition: ncursesw.h:1469
virtual int noutrefresh()
Definition: ncursesw.h:1714
int begy() const
Definition: ncursesw.h:1085
int getch(int y, int x)
Definition: ncursesw.h:1184
NCursesWindow * sibling()
Definition: ncursesw.h:1770
int mvcur(int oldrow, int oldcol, int newrow, int newcol) const
Definition: ncursesw.h:1165
int redrawln(int from, int n)
Definition: ncursesw.h:1636
void getyx(int &y, int &x) const
Definition: ncursesw.h:1160
int insstr(const char *s, int n=-1)
Definition: ncursesw.h:1383
int chgat(int n, attr_t attr, short color, const void *opts=NULL)
Definition: ncursesw.h:1417
int refresh()
Definition: ncursesw.h:1857
int begx() const
Definition: ncursesw.h:1080
int instr(int y, int x, char *s, int n=-1)
Definition: ncursesw.h:1216
virtual int mvwin(int begin_y, int begin_x)
Definition: ncursesw.h:1140
chtype getbkgd() const
Definition: ncursesw.h:1438
int keypad(bool bf)
Definition: ncursesw.h:1682
static void useColors(void)
Definition: ncursesw.cc:508
int getstr(int y, int x, char *str, int n=-1)
Definition: ncursesw.h:1200
int insstr(int y, int x, const char *s, int n=-1)
Definition: ncursesw.h:1392
int leaveok(bool bf)
Definition: ncursesw.h:1631
int move(int y, int x)
Definition: ncursesw.h:1155
int attron(chtype at)
Definition: ncursesw.h:1400
int deleteln()
Definition: ncursesw.h:1554
int echochar(const char ch)
Definition: ncursesw.h:1265
int maxy() const
Definition: ncursesw.h:1095
bool has_mouse() const
Definition: ncursesw.cc:601
int refresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
Definition: ncursesw.h:1866
int touchwin()
Definition: ncursesw.h:1595
int scrollok(bool bf)
Definition: ncursesw.h:1570
NCursesWindow * sib
Definition: ncursesw.h:965
int ins_wch(int y, int x, const cchar_t *cchar)
Definition: ncursesw.h:1362
int attrset(chtype at)
Definition: ncursesw.h:1410
NCursesWindow Clone()
Definition: ncursesw.cc:364
NCursesWindow * subwins
Definition: ncursesw.h:961
int touchln(int s, int cnt, bool changed=TRUE)
Definition: ncursesw.h:1606
Definition: position.h:154
bool is_wintouched() const
Definition: ncursesw.h:1622
int scroll(int amount=1)
Definition: ncursesw.h:1563
int insdelln(int n=1)
Definition: ncursesw.h:1376
int untouchwin()
Definition: ncursesw.h:1600
int addstr(const char *str, int n=-1)
Definition: ncursesw.h:1276
chtype inch() const
Definition: ncursesw.h:1325
int width() const
Definition: ncursesw.h:1075
NCursesColorWindow(int lines, int cols, int begin_y, int begin_x)
Definition: ncursesw.h:1807
WINDOW * w
Definition: ncursesw.h:947
bool is_linetouched(int line) const
Definition: ncursesw.h:1614
int getstr(char *str, int n=-1)
Definition: ncursesw.h:1191
chtype inch(int y, int x)
Definition: ncursesw.h:1333
void cursyncup()
Definition: ncursesw.h:1661
static int ripoffline(int ripoff_lines, int(*init)(NCursesWindow &win))
Definition: ncursesw.cc:405
int meta(bool bf)
Definition: ncursesw.h:1688
NCursesWindow * child()
Definition: ncursesw.h:1763
int noutrefresh()
Definition: ncursesw.h:1859
int add_wch(const cchar_t *cch)
Definition: ncursesw.h:1244
bool alloced
Definition: ncursesw.h:952
int clrtobot()
Definition: ncursesw.h:1533