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