libyui-ncurses
2.44.1
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: ncursesw.h 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef _CURSESW_H 00026 #define _CURSESW_H 00027 00028 #include <iosfwd> 00029 00030 #include <ncursesw/etip.h> 00031 #include <cstdio> 00032 #include <cstdarg> 00033 #include <climits> 00034 #include "position.h" 00035 00036 #include <ncursesw/curses.h> 00037 00038 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. 00039 Undefine it here, because NCursesWindow uses lines as a method. */ 00040 #undef lines 00041 00042 /* "Convert" macros to inlines. We'll define it as another symbol to avoid 00043 * conflict with library symbols. 00044 */ 00045 #undef UNDEF 00046 #define UNDEF(name) CUR_ ##name 00047 00048 #ifdef addch 00049 inline int UNDEF( addch )( chtype ch ) { return addch( ch ); } 00050 00051 #undef addch 00052 #define addch UNDEF(addch) 00053 #endif 00054 00055 #ifdef add_wch 00056 inline int UNDEF( add_wch )( cchar_t * cch ) { return add_wch( cch ); } 00057 00058 #undef add_wch 00059 #define add_wch UNDEF(add_wch) 00060 #endif 00061 00062 #ifdef echochar 00063 inline int UNDEF( echochar )( chtype ch ) { return echochar( ch ); } 00064 00065 #undef echochar 00066 #define echochar UNDEF(echochar) 00067 #endif 00068 00069 #ifdef insdelln 00070 inline int UNDEF( insdelln )( int n ) { return insdelln( n ); } 00071 00072 #undef insdelln 00073 #define insdelln UNDEF(insdelln) 00074 #endif 00075 00076 #ifdef addstr 00077 /* The (char*) cast is to hack around missing const's */ 00078 inline int UNDEF( addstr )( const char * str ) { return addstr(( char* )str ); } 00079 00080 #undef addstr 00081 #define addstr UNDEF(addstr) 00082 #endif 00083 00084 #ifdef addwstr 00085 /* The (wchar*_t) cast is to hack around missing const's */ 00086 inline int UNDEF( addwstr )( const wchar_t * str ) { return addwstr(( wchar_t* )str ); } 00087 00088 #undef addwstr 00089 #define addwstr UNDEF(addwstr) 00090 #endif 00091 00092 #ifdef attron 00093 inline int UNDEF( attron )( chtype at ) { return attron( at ); } 00094 00095 #undef attron 00096 #define attron UNDEF(attron) 00097 #endif 00098 00099 #ifdef attroff 00100 inline int UNDEF( attroff )( chtype at ) { return attroff( at ); } 00101 00102 #undef attroff 00103 #define attroff UNDEF(attroff) 00104 #endif 00105 00106 #ifdef attrset 00107 inline chtype UNDEF( attrset )( chtype at ) { return attrset( at ); } 00108 00109 #undef attrset 00110 #define attrset UNDEF(attrset) 00111 #endif 00112 00113 #ifdef border 00114 inline int UNDEF( border )( chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br ) 00115 { return border( ls, rs, ts, bs, tl, tr, bl, br ); } 00116 00117 #undef border 00118 #define border UNDEF(border) 00119 #endif 00120 00121 #ifdef box 00122 inline int UNDEF( box )( WINDOW *win, int v, int h ) { return box( win, v, h ); } 00123 00124 #undef box 00125 #define box UNDEF(box) 00126 #endif 00127 00128 #ifdef mvwhline 00129 inline int UNDEF( mvwhline )( WINDOW *win, int y, int x, chtype c, int n ) 00130 { 00131 return mvwhline( win, y, x, c, n ); 00132 } 00133 00134 #undef mvwhline 00135 #define mvwhline UNDEF(mvwhline) 00136 #endif 00137 00138 #ifdef mvwvline 00139 inline int UNDEF( mvwvline )( WINDOW *win, int y, int x, chtype c, int n ) 00140 { 00141 return mvwvline( win, y, x, c, n ); 00142 } 00143 00144 #undef mvwvline 00145 #define mvwvline UNDEF(mvwvline) 00146 #endif 00147 00148 #ifdef clear 00149 inline int UNDEF( clear )() { return clear(); } 00150 00151 #undef clear 00152 #define clear UNDEF(clear) 00153 #endif 00154 00155 #ifdef clearok 00156 inline int UNDEF( clearok )( WINDOW* win, bool bf ) { return clearok( win, bf ); } 00157 00158 #undef clearok 00159 #define clearok UNDEF(clearok) 00160 #else 00161 extern "C" int clearok( WINDOW*, bool ); 00162 #endif 00163 00164 #ifdef clrtobot 00165 inline int UNDEF( clrtobot )() { return clrtobot(); } 00166 00167 #undef clrtobot 00168 #define clrtobot UNDEF(clrtobot) 00169 #endif 00170 00171 #ifdef clrtoeol 00172 inline int UNDEF( clrtoeol )() { return clrtoeol(); } 00173 00174 #undef clrtoeol 00175 #define clrtoeol UNDEF(clrtoeol) 00176 #endif 00177 00178 #ifdef delch 00179 inline int UNDEF( delch )() { return delch(); } 00180 00181 #undef delch 00182 #define delch UNDEF(delch) 00183 #endif 00184 00185 #ifdef deleteln 00186 inline int UNDEF( deleteln )() { return deleteln(); } 00187 00188 #undef deleteln 00189 #define deleteln UNDEF(deleteln) 00190 #endif 00191 00192 #ifdef erase 00193 inline int UNDEF( erase )() { return erase(); } 00194 00195 #undef erase 00196 #define erase UNDEF(erase) 00197 #endif 00198 00199 #ifdef flushok 00200 inline int UNDEF( flushok )( WINDOW* _win, bool _bf ) 00201 { 00202 return flushok( _win, _bf ); 00203 } 00204 00205 #undef flushok 00206 #define flushok UNDEF(flushok) 00207 #else 00208 #define _no_flushok 00209 #endif 00210 00211 #ifdef getch 00212 inline int UNDEF( getch )() { return getch(); } 00213 00214 #undef getch 00215 #define getch UNDEF(getch) 00216 #endif 00217 00218 #ifdef getstr 00219 inline int UNDEF( getstr )( char *_str ) { return getstr( _str ); } 00220 00221 #undef getstr 00222 #define getstr UNDEF(getstr) 00223 #endif 00224 00225 #ifdef instr 00226 inline int UNDEF( instr )( char *_str ) { return instr( _str ); } 00227 00228 #undef instr 00229 #define instr UNDEF(instr) 00230 #endif 00231 00232 #ifdef innstr 00233 inline int UNDEF( innstr )( char *_str, int n ) { return innstr( _str, n ); } 00234 00235 #undef innstr 00236 #define innstr UNDEF(innstr) 00237 #endif 00238 00239 #ifdef mvwinnstr 00240 inline int UNDEF( mvwinnstr )( WINDOW *win, int y, int x, char *_str, int n ) 00241 { 00242 return mvwinnstr( win, y, x, _str, n ); 00243 } 00244 00245 #undef mvwinnstr 00246 #define mvwinnstr UNDEF(mvwinnstr) 00247 #endif 00248 00249 #ifdef mvinnstr 00250 inline int UNDEF( mvinnstr )( int y, int x, char *_str, int n ) 00251 { 00252 return mvinnstr( y, x, _str, n ); 00253 } 00254 00255 #undef mvinnstr 00256 #define mvinnstr UNDEF(mvinnstr) 00257 #endif 00258 00259 #ifdef winsstr 00260 inline int UNDEF( winsstr )( WINDOW *w, const char *_str ) 00261 { 00262 return winsstr( w, _str ); 00263 } 00264 00265 #undef winsstr 00266 #define winsstr UNDEF(winsstr) 00267 #endif 00268 00269 #ifdef mvwinsstr 00270 inline int UNDEF( mvwinsstr )( WINDOW *w, int y, int x, const char *_str ) 00271 { 00272 return mvwinsstr( w, y, x, _str ); 00273 } 00274 00275 #undef mvwinsstr 00276 #define mvwinsstr UNDEF(mvwinsstr) 00277 #endif 00278 00279 #ifdef insstr 00280 inline int UNDEF( insstr )( const char *_str ) 00281 { 00282 return insstr( _str ); 00283 } 00284 00285 #undef insstr 00286 #define insstr UNDEF(insstr) 00287 #endif 00288 00289 #ifdef mvinsstr 00290 inline int UNDEF( mvinsstr )( int y, int x, const char *_str ) 00291 { 00292 return mvinsstr( y, x, _str ); 00293 } 00294 00295 #undef mvinsstr 00296 #define mvinsstr UNDEF(mvinsstr) 00297 #endif 00298 00299 #ifdef insnstr 00300 inline int UNDEF( insnstr )( const char *_str, int n ) 00301 { 00302 return insnstr( _str, n ); 00303 } 00304 00305 #undef insnstr 00306 #define insnstr UNDEF(insnstr) 00307 #endif 00308 00309 #ifdef mvwinsnstr 00310 inline int UNDEF( mvwinsnstr )( WINDOW *w, int y, int x, const char *_str, int n ) 00311 { 00312 return mvwinsnstr( w, y, x, _str, n ); 00313 } 00314 00315 #undef mvwinsnstr 00316 #define mvwinsnstr UNDEF(mvwinsnstr) 00317 #endif 00318 00319 #ifdef mvinsnstr 00320 inline int UNDEF( mvinsnstr )( int y, int x, const char *_str, int n ) 00321 { 00322 return mvinsnstr( y, x, _str, n ); 00323 } 00324 00325 #undef mvinsnstr 00326 #define mvinsnstr UNDEF(mvinsnstr) 00327 #endif 00328 00329 #ifdef getnstr 00330 inline int UNDEF( getnstr )( char *_str, int n ) { return getnstr( _str, n ); } 00331 00332 #undef getnstr 00333 #define getnstr UNDEF(getnstr) 00334 #endif 00335 00336 #ifdef getyx 00337 inline void UNDEF( getyx )( const WINDOW* win, int& y, int& x ) 00338 { 00339 getyx( win, y, x ); 00340 } 00341 00342 #undef getyx 00343 #define getyx UNDEF(getyx) 00344 #endif 00345 00346 #ifdef getbegyx 00347 inline void UNDEF( getbegyx )( WINDOW* win, int& y, int& x ) { getbegyx( win, y, x ); } 00348 00349 #undef getbegyx 00350 #define getbegyx UNDEF(getbegyx) 00351 #endif 00352 00353 #ifdef getmaxyx 00354 inline void UNDEF( getmaxyx )( WINDOW* win, int& y, int& x ) { getmaxyx( win, y, x ); } 00355 00356 #undef getmaxyx 00357 #define getmaxyx UNDEF(getmaxyx) 00358 #endif 00359 00360 #ifdef hline 00361 inline int UNDEF( hline )( chtype ch, int n ) { return hline( ch, n ); } 00362 00363 #undef hline 00364 #define hline UNDEF(hline) 00365 #endif 00366 00367 #ifdef inch 00368 inline chtype UNDEF( inch )() { return inch(); } 00369 00370 #undef inch 00371 #define inch UNDEF(inch) 00372 #endif 00373 00374 #ifdef in_wch 00375 inline int UNDEF( in_wch )( cchar_t * cch ) { return in_wch( cch ); } 00376 00377 #undef in_wch 00378 #define in_wch UNDEF(in_wch) 00379 #endif 00380 00381 #ifdef insch 00382 inline int UNDEF( insch )( char c ) { return insch( c ); } 00383 00384 #undef insch 00385 #define insch UNDEF(insch) 00386 #endif 00387 00388 #ifdef ins_wch 00389 inline int UNDEF( ins_wch )( const cchar_t *c ) { return ins_wch( c ); } 00390 00391 #undef ins_wch 00392 #define ins_wch UNDEF(ins_wch) 00393 #endif 00394 00395 #ifdef mvwins_wch 00396 inline int UNDEF( mvwins_wch )( WINDOW *w, int y, int x, const cchar_t *cchar ) { return mvwins_wch( w, y, x, cchar ); } 00397 00398 #undef mvwins_wch 00399 #define mvwins_wch UNDEF(mvwins_wch) 00400 #endif 00401 00402 #ifdef insertln 00403 inline int UNDEF( insertln )() { return insertln(); } 00404 00405 #undef insertln 00406 #define insertln UNDEF(insertln) 00407 #endif 00408 00409 #ifdef leaveok 00410 inline int UNDEF( leaveok )( WINDOW* win, bool bf ) { return leaveok( win, bf ); } 00411 00412 #undef leaveok 00413 #define leaveok UNDEF(leaveok) 00414 #else 00415 extern "C" int leaveok( WINDOW* win, bool bf ); 00416 #endif 00417 00418 #ifdef move 00419 inline int UNDEF( move )( int x, int y ) { return move( x, y ); } 00420 00421 #undef move 00422 #define move UNDEF(move) 00423 #endif 00424 00425 #ifdef refresh 00426 inline int UNDEF( refresh )() { return refresh(); } 00427 00428 #undef refresh 00429 #define refresh UNDEF(refresh) 00430 #endif 00431 00432 #ifdef redrawwin 00433 inline int UNDEF( redrawwin )( WINDOW *win ) { return redrawwin( win ); } 00434 00435 #undef redrawwin 00436 #define redrawwin UNDEF(redrawwin) 00437 #endif 00438 00439 #ifdef scrl 00440 inline int UNDEF( scrl )( int l ) { return scrl( l ); } 00441 00442 #undef scrl 00443 #define scrl UNDEF(scrl) 00444 #endif 00445 00446 #ifdef scroll 00447 inline int UNDEF( scroll )( WINDOW *win ) { return scroll( win ); } 00448 00449 #undef scroll 00450 #define scroll UNDEF(scroll) 00451 #endif 00452 00453 #ifdef scrollok 00454 inline int UNDEF( scrollok )( WINDOW* win, bool bf ) { return scrollok( win, bf ); } 00455 00456 #undef scrollok 00457 #define scrollok UNDEF(scrollok) 00458 #else 00459 #if defined(__NCURSES_H) 00460 extern "C" int scrollok( WINDOW*, bool ); 00461 #else 00462 extern "C" int scrollok( WINDOW*, char ); 00463 #endif 00464 #endif 00465 00466 #ifdef setscrreg 00467 inline int UNDEF( setscrreg )( int t, int b ) { return setscrreg( t, b ); } 00468 00469 #undef setscrreg 00470 #define setscrreg UNDEF(setscrreg) 00471 #endif 00472 00473 #ifdef standend 00474 inline int UNDEF( standend )() { return standend(); } 00475 00476 #undef standend 00477 #define standend UNDEF(standend) 00478 #endif 00479 00480 #ifdef standout 00481 inline int UNDEF( standout )() { return standout(); } 00482 00483 #undef standout 00484 #define standout UNDEF(standout) 00485 #endif 00486 00487 #ifdef subpad 00488 inline WINDOW *UNDEF( subpad )( WINDOW *p, int l, int c, int y, int x ) 00489 { return derwin( p, l, c, y, x ); } 00490 00491 #undef subpad 00492 #define subpad UNDEF(subpad) 00493 #endif 00494 00495 #ifdef timeout 00496 #if NCURSES_VERSION_MAJOR < 5 00497 inline int UNDEF( timeout )( int delay ) { return timeout( delay ); } 00498 00499 #else 00500 inline void UNDEF( timeout )( int delay ) { timeout( delay ); } 00501 00502 #endif 00503 #undef timeout 00504 #define timeout UNDEF(timeout) 00505 #endif 00506 00507 #ifdef touchline 00508 inline int UNDEF( touchline )( WINDOW *win, int s, int c ) 00509 { return touchline( win, s, c ); } 00510 00511 #undef touchline 00512 #define touchline UNDEF(touchline) 00513 #endif 00514 00515 #ifdef touchwin 00516 inline int UNDEF( touchwin )( WINDOW *win ) { return touchwin( win ); } 00517 00518 #undef touchwin 00519 #define touchwin UNDEF(touchwin) 00520 #endif 00521 00522 #ifdef untouchwin 00523 inline int UNDEF( untouchwin )( WINDOW *win ) { return untouchwin( win ); } 00524 00525 #undef untouchwin 00526 #define untouchwin UNDEF(untouchwin) 00527 #endif 00528 00529 #ifdef vline 00530 inline int UNDEF( vline )( chtype ch, int n ) { return vline( ch, n ); } 00531 00532 #undef vline 00533 #define vline UNDEF(vline) 00534 #endif 00535 00536 #ifdef waddstr 00537 inline int UNDEF( waddstr )( WINDOW *win, char *str ) { return waddstr( win, str ); } 00538 00539 #undef waddstr 00540 #define waddstr UNDEF(waddstr) 00541 #endif 00542 00543 #ifdef waddwstr 00544 inline int UNDEF( waddwstr )( WINDOW *win, wchar_t *str ) { return waddwstr( win, str ); } 00545 00546 #undef waddwstr 00547 #define waddwstr UNDEF(waddwstr) 00548 #endif 00549 00550 #ifdef mvwaddwstr 00551 inline int UNDEF( mvwaddwstr )( WINDOW *win, int y, int x, wchar_t *str ) 00552 { return mvwaddwstr( win, y, x, str ); } 00553 00554 #undef mvwaddwstr 00555 #define mvwaddwstr UNDEF(mvwaddwstr) 00556 #endif 00557 00558 #ifdef waddchstr 00559 inline int UNDEF( waddchstr )( WINDOW *win, chtype *at ) { return waddchstr( win, at ); } 00560 00561 #undef waddchstr 00562 #define waddchstr UNDEF(waddchstr) 00563 #endif 00564 00565 #ifdef wstandend 00566 inline int UNDEF( wstandend )( WINDOW *win ) { return wstandend( win ); } 00567 00568 #undef wstandend 00569 #define wstandend UNDEF(wstandend) 00570 #endif 00571 00572 #ifdef wstandout 00573 inline int UNDEF( wstandout )( WINDOW *win ) { return wstandout( win ); } 00574 00575 #undef wstandout 00576 #define wstandout UNDEF(wstandout) 00577 #endif 00578 00579 00580 #ifdef wattroff 00581 inline int UNDEF( wattroff )( WINDOW *win, int att ) { return wattroff( win, att ); } 00582 00583 #undef wattroff 00584 #define wattroff UNDEF(wattroff) 00585 #endif 00586 00587 #ifdef chgat 00588 inline int UNDEF( chgat )( int n, attr_t attr, short color, const void *opts ) 00589 { 00590 return chgat( n, attr, color, opts ); 00591 } 00592 00593 #undef chgat 00594 #define chgat UNDEF(chgat) 00595 #endif 00596 00597 #ifdef mvchgat 00598 inline int UNDEF( mvchgat )( int y, int x, int n, 00599 attr_t attr, short color, const void *opts ) 00600 { 00601 return mvchgat( y, x, n, attr, color, opts ); 00602 } 00603 00604 #undef mvchgat 00605 #define mvchgat UNDEF(mvchgat) 00606 #endif 00607 00608 #ifdef mvwchgat 00609 inline int UNDEF( mvwchgat )( WINDOW *win, int y, int x, int n, 00610 attr_t attr, short color, const void *opts ) 00611 { 00612 return mvwchgat( win, y, x, n, attr, color, opts ); 00613 } 00614 00615 #undef mvwchgat 00616 #define mvwchgat UNDEF(mvwchgat) 00617 #endif 00618 00619 #ifdef wattrset 00620 inline int UNDEF( wattrset )( WINDOW *win, int att ) { return wattrset( win, att ); } 00621 00622 #undef wattrset 00623 #define wattrset UNDEF(wattrset) 00624 #endif 00625 00626 #ifdef winch 00627 inline chtype UNDEF( winch )( const WINDOW* win ) { return winch( win ); } 00628 00629 #undef winch 00630 #define winch UNDEF(winch) 00631 #endif 00632 00633 #ifdef mvwaddch 00634 inline int UNDEF( mvwaddch )( WINDOW *win, int y, int x, const chtype ch ) 00635 { return mvwaddch( win, y, x, ch ); } 00636 00637 #undef mvwaddch 00638 #define mvwaddch UNDEF(mvwaddch) 00639 #endif 00640 00641 #ifdef mvwaddchnstr 00642 inline int UNDEF( mvwaddchnstr )( WINDOW *win, int y, int x, chtype *str, int n ) 00643 { return mvwaddchnstr( win, y, x, str, n ); } 00644 00645 #undef mvwaddchnstr 00646 #define mvwaddchnstr UNDEF(mvwaddchnstr) 00647 #endif 00648 00649 #ifdef mvwaddchstr 00650 inline int UNDEF( mvwaddchstr )( WINDOW *win, int y, int x, chtype *str ) 00651 { return mvwaddchstr( win, y, x, str ); } 00652 00653 #undef mvwaddchstr 00654 #define mvwaddchstr UNDEF(mvwaddchstr) 00655 #endif 00656 00657 #ifdef addnstr 00658 inline int UNDEF( addnstr )( const char *str, int n ) 00659 { return addnstr(( char* )str, n ); } 00660 00661 #undef addnstr 00662 #define addnstr UNDEF(addnstr) 00663 #endif 00664 00665 #ifdef addnwstr 00666 inline int UNDEF( addnwstr )( const wchar_t *str, int n ) 00667 { return addnwstr(( wchar_t* )str, n ); } 00668 00669 #undef addnwstr 00670 #define addnwstr UNDEF(addnwstr) 00671 #endif 00672 00673 #ifdef mvwaddnstr 00674 inline int UNDEF( mvwaddnstr )( WINDOW *win, int y, int x, const char *str, int n ) 00675 { return mvwaddnstr( win, y, x, ( char* )str, n ); } 00676 00677 #undef mvwaddnstr 00678 #define mvwaddnstr UNDEF(mvwaddnstr) 00679 #endif 00680 00681 #ifdef mvwaddnwstr 00682 inline int UNDEF( mvwaddnwstr )( WINDOW *win, int y, int x, const wchar_t *str, int n ) 00683 { return mvwaddnwstr( win, y, x, ( wchar_t* )str, n ); } 00684 00685 #undef mvwaddnwstr 00686 #define mvwaddnwstr UNDEF(mvwaddnwstr) 00687 #endif 00688 00689 #ifdef mvwaddstr 00690 inline int UNDEF( mvwaddstr )( WINDOW *win, int y, int x, const char * str ) 00691 { return mvwaddstr( win, y, x, ( char* )str ); } 00692 00693 #undef mvwaddstr 00694 #define mvwaddstr UNDEF(mvwaddstr) 00695 #endif 00696 00697 #ifdef mvwdelch 00698 inline int UNDEF( mvwdelch )( WINDOW *win, int y, int x ) 00699 { return mvwdelch( win, y, x ); } 00700 00701 #undef mvwdelch 00702 #define mvwdelch UNDEF(mvwdelch) 00703 #endif 00704 00705 #ifdef mvwgetch 00706 inline int UNDEF( mvwgetch )( WINDOW *win, int y, int x ) { return mvwgetch( win, y, x );} 00707 00708 #undef mvwgetch 00709 #define mvwgetch UNDEF(mvwgetch) 00710 #endif 00711 00712 #ifdef mvwgetstr 00713 inline int UNDEF( mvwgetstr )( WINDOW *win, int y, int x, char *str ) 00714 {return mvwgetstr( win, y, x, str );} 00715 00716 #undef mvwgetstr 00717 #define mvwgetstr UNDEF(mvwgetstr) 00718 #endif 00719 00720 #ifdef mvwgetnstr 00721 inline int UNDEF( mvwgetnstr )( WINDOW *win, int y, int x, char *str, int n ) 00722 {return mvwgetnstr( win, y, x, str, n );} 00723 00724 #undef mvwgetnstr 00725 #define mvwgetnstr UNDEF(mvwgetnstr) 00726 #endif 00727 00728 #ifdef mvwinch 00729 inline chtype UNDEF( mvwinch )( WINDOW *win, int y, int x ) 00730 { 00731 return mvwinch( win, y, x ); 00732 } 00733 00734 #undef mvwinch 00735 #define mvwinch UNDEF(mvwinch) 00736 #endif 00737 00738 #ifdef mvwin_wch 00739 inline int UNDEF( mvwin_wch )( WINDOW *win, int y, int x, cchar_t * cch ) 00740 { 00741 return mvwin_wch( win, y, x, cch ); 00742 } 00743 00744 #undef mvwin_wch 00745 #define mvwin_wch UNDEF(mvwin_wch) 00746 #endif 00747 00748 #ifdef mvwinsch 00749 inline int UNDEF( mvwinsch )( WINDOW *win, int y, int x, char c ) 00750 { return mvwinsch( win, y, x, c ); } 00751 00752 #undef mvwinsch 00753 #define mvwinsch UNDEF(mvwinsch) 00754 #endif 00755 00756 #ifdef mvaddch 00757 inline int UNDEF( mvaddch )( int y, int x, chtype ch ) 00758 { return mvaddch( y, x, ch ); } 00759 00760 #undef mvaddch 00761 #define mvaddch UNDEF(mvaddch) 00762 #endif 00763 00764 #ifdef mvaddnstr 00765 inline int UNDEF( mvaddnstr )( int y, int x, const char *str, int n ) 00766 { return mvaddnstr( y, x, ( char* )str, n ); } 00767 00768 #undef mvaddnstr 00769 #define mvaddnstr UNDEF(mvaddnstr) 00770 #endif 00771 00772 #ifdef mvaddstr 00773 inline int UNDEF( mvaddstr )( int y, int x, const char * str ) 00774 { return mvaddstr( y, x, ( char* )str ); } 00775 00776 #undef mvaddstr 00777 #define mvaddstr UNDEF(mvaddstr) 00778 #endif 00779 00780 #ifdef mvwadd_wch 00781 inline int UNDEF( mvwadd_wch )( WINDOW *win, int y, int x, const cchar_t * cch ) 00782 { return mvwadd_wch( win, y, x, ( cchar_t* )cch ); } 00783 00784 #undef mvwadd_wch 00785 #define mvwadd_wch UNDEF(mvwadd_wch) 00786 #endif 00787 00788 #ifdef mvdelch 00789 inline int UNDEF( mvdelch )( int y, int x ) { return mvdelch( y, x );} 00790 00791 #undef mvdelch 00792 #define mvdelch UNDEF(mvdelch) 00793 #endif 00794 00795 #ifdef mvgetch 00796 inline int UNDEF( mvgetch )( int y, int x ) { return mvgetch( y, x );} 00797 00798 #undef mvgetch 00799 #define mvgetch UNDEF(mvgetch) 00800 #endif 00801 00802 #ifdef mvgetstr 00803 inline int UNDEF( mvgetstr )( int y, int x, char *str ) {return mvgetstr( y, x, str );} 00804 00805 #undef mvgetstr 00806 #define mvgetstr UNDEF(mvgetstr) 00807 #endif 00808 00809 #ifdef mvgetnstr 00810 inline int UNDEF( mvgetnstr )( int y, int x, char *str, int n ) 00811 { 00812 return mvgetnstr( y, x, str, n ); 00813 } 00814 00815 #undef mvgetnstr 00816 #define mvgetnstr UNDEF(mvgetnstr) 00817 #endif 00818 00819 #ifdef mvinch 00820 inline chtype UNDEF( mvinch )( int y, int x ) { return mvinch( y, x );} 00821 00822 #undef mvinch 00823 #define mvinch UNDEF(mvinch) 00824 #endif 00825 00826 #ifdef mvinsch 00827 inline int UNDEF( mvinsch )( int y, int x, char c ) 00828 { return mvinsch( y, x, c ); } 00829 00830 #undef mvinsch 00831 #define mvinsch UNDEF(mvinsch) 00832 #endif 00833 00834 #ifdef napms 00835 inline void UNDEF( napms )( unsigned long x ) { napms( x ); } 00836 00837 #undef napms 00838 #define napms UNDEF(napms) 00839 #endif 00840 00841 #ifdef fixterm 00842 inline int UNDEF( fixterm )( void ) { return fixterm(); } 00843 00844 #undef fixterm 00845 #define fixterm UNDEF(fixterm) 00846 #endif 00847 00848 #ifdef resetterm 00849 inline int UNDEF( resetterm )( void ) { return resetterm(); } 00850 00851 #undef resetterm 00852 #define resetterm UNDEF(resetterm) 00853 #endif 00854 00855 #ifdef saveterm 00856 inline int UNDEF( saveterm )( void ) { return saveterm(); } 00857 00858 #undef saveterm 00859 #define saveterm UNDEF(saveterm) 00860 #endif 00861 00862 #ifdef crmode 00863 inline int UNDEF( crmode )( void ) { return crmode(); } 00864 00865 #undef crmode 00866 #define crmode UNDEF(crmode) 00867 #endif 00868 00869 #ifdef nocrmode 00870 inline int UNDEF( nocrmode )( void ) { return nocrmode(); } 00871 00872 #undef nocrmode 00873 #define nocrmode UNDEF(nocrmode) 00874 #endif 00875 00876 #ifdef getbkgd 00877 inline chtype UNDEF( getbkgd )( const WINDOW *win ) { return getbkgd( win ); } 00878 00879 #undef getbkgd 00880 #define getbkgd UNDEF(getbkgd) 00881 #endif 00882 00883 #ifdef bkgd 00884 inline int UNDEF( bkgd )( chtype ch ) { return bkgd( ch ); } 00885 00886 #undef bkgd 00887 #define bkgd UNDEF(bkgd) 00888 #endif 00889 00890 #ifdef bkgdset 00891 inline void UNDEF( bkgdset )( chtype ch ) { bkgdset( ch ); } 00892 00893 #undef bkgdset 00894 #define bkgdset UNDEF(bkgdset) 00895 #endif 00896 00897 template <class _Tp> inline int ncursesMaxCoord() { return INT_MAX; } 00898 template <> inline int ncursesMaxCoord<short>() { return SHRT_MAX; } 00899 00900 /** 00901 * @short C++ class for windows. 00902 */ 00903 00904 class NCursesWindow 00905 { 00906 friend std::ostream & operator<<( std::ostream & Stream, const NCursesWindow & Obj_Cv ); 00907 friend std::ostream & operator<<( std::ostream & Stream, const NCursesWindow * Obj_Cv ); 00908 00909 friend class NCursesMenu; 00910 friend class NCursesForm; 00911 00912 private: 00913 static bool b_initialized; 00914 static void initialize(); 00915 static int ripoff_init( WINDOW *, int ); 00916 00917 void init(); 00918 00919 short getcolor( int getback ) const; 00920 00921 static int setpalette( short fore, short back, short pair ); 00922 static int colorInitialized; 00923 00924 /** 00925 * This private constructor is only used during the initialization 00926 * of windows generated by ripoffline() calls. 00927 */ 00928 NCursesWindow( WINDOW* win, int cols ); 00929 00930 protected: 00931 /** 00932 * Signal an error with the given message text. 00933 */ 00934 void err_handler( const char * ) const THROWS( NCursesException ); 00935 00936 /** 00937 * count of all active windows 00938 */ 00939 static long count; 00940 // We rely on the c++ promise that 00941 // all otherwise uninitialized 00942 // static class vars are set to 0 00943 00944 /** 00945 * the curses WINDOW 00946 */ 00947 WINDOW* w; 00948 00949 /** 00950 * TRUE if we own the WINDOW 00951 */ 00952 bool alloced; 00953 00954 /** 00955 * parent, if subwindow 00956 */ 00957 NCursesWindow* par; 00958 /** 00959 * head of subwindows std::list 00960 */ 00961 NCursesWindow* subwins; 00962 /** 00963 * next subwindow of parent 00964 */ 00965 NCursesWindow* sib; 00966 00967 /** 00968 * Destroy all subwindows. 00969 */ 00970 void kill_subwindows(); 00971 00972 /** 00973 * Only for use by derived classes. They are then in charge to 00974 * fill the member variables correctly. 00975 */ 00976 NCursesWindow(); 00977 00978 public: 00979 /** 00980 * Constructor. Useful only for stdscr 00981 **/ 00982 NCursesWindow( WINDOW* window ); 00983 00984 /** 00985 * Constructor. 00986 **/ 00987 NCursesWindow( int lines, 00988 int cols, 00989 int begin_y, 00990 int begin_x ); 00991 00992 /** 00993 * Constructor. 00994 * 00995 * If 'absrel' is 'a', begin_x/y are absolute screen pos, 00996 * if `r', they are relative to parent origin. 00997 **/ 00998 NCursesWindow( NCursesWindow & parent, 00999 int lines, 01000 int cols, 01001 int begin_y, 01002 int begin_x, 01003 char absrel = 'a' ); 01004 01005 /** 01006 * Destructor. 01007 **/ 01008 virtual ~NCursesWindow(); 01009 01010 /** 01011 * Make an exact copy of the window. 01012 */ 01013 NCursesWindow Clone(); 01014 01015 // ------------------------------------------------------------------------- 01016 // Initialization. 01017 // ------------------------------------------------------------------------- 01018 /** 01019 * Call this routine very early if you want to have colors. 01020 */ 01021 static void useColors( void ); 01022 01023 /** 01024 * This function is used to generate a window of ripped-of lines. 01025 * If the argument is positive, lines are removed from the top, if it 01026 * is negative lines are removed from the bottom. This enhances the 01027 * lowlevel ripoffline() function because it uses the internal 01028 * implementation that allows to remove more than just a single line. 01029 * This function must be called before any other ncurses function. The 01030 * creation of the window is defered until ncurses gets initialized. 01031 * The initialization function is then called. 01032 */ 01033 static int ripoffline( int ripoff_lines, 01034 int ( *init )( NCursesWindow& win ) ); 01035 01036 // ------------------------------------------------------------------------- 01037 // terminal status 01038 // ------------------------------------------------------------------------- 01039 /** 01040 * Number of lines on terminal, *not* window 01041 */ 01042 static int lines() { initialize(); return LINES; } 01043 01044 /** 01045 * Number of cols on terminal, *not* window 01046 */ 01047 static int cols() { initialize(); return COLS; } 01048 01049 /** 01050 * Size of a tab on terminal, *not* window 01051 */ 01052 static int tabsize() { initialize(); return TABSIZE; } 01053 01054 /** 01055 * Number of available colors 01056 */ 01057 static int NumberOfColors(); 01058 01059 /** 01060 * Number of available colors 01061 */ 01062 int colors() const { return NumberOfColors(); } 01063 01064 // ------------------------------------------------------------------------- 01065 // window status 01066 // ------------------------------------------------------------------------- 01067 /** 01068 * Number of lines in this window 01069 */ 01070 int height() const { return maxy() + 1; } 01071 01072 /** 01073 * Number of columns in this window 01074 */ 01075 int width() const { return maxx() + 1; } 01076 01077 /** 01078 * Column of top left corner relative to stdscr 01079 */ 01080 int begx() const { return getbegx(w); } 01081 01082 /** 01083 * Line of top left corner relative to stdscr 01084 */ 01085 int begy() const { return getbegy(w); } 01086 01087 /** 01088 * Largest x coord in window 01089 */ 01090 int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; } 01091 01092 /** 01093 * Largest y coord in window 01094 */ 01095 int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; } 01096 01097 /** Ncurses up to ncurses5 internally uses \c short. */ 01098 static int maxcoord() { return ncursesMaxCoord<NCURSES_SIZE_T>(); } 01099 01100 wsze size() const { return wsze( height(), width() ); } 01101 01102 wpos begpos() const { return wpos( begy(), begx() ); } 01103 01104 wpos maxpos() const { return wpos( maxy(), maxx() ); } 01105 01106 wrect area() const { return wrect( begpos(), size() ); } 01107 01108 /** 01109 * Actual color pair 01110 */ 01111 short getcolor() const; 01112 01113 /** 01114 * Actual foreground color 01115 */ 01116 short foreground() const { return getcolor( 0 ); } 01117 01118 /** 01119 * Actual background color 01120 */ 01121 short background() const { return getcolor( 1 ); } 01122 01123 /** 01124 * Set color palette entry 01125 */ 01126 int setpalette( short fore, short back ); 01127 01128 /** 01129 * Set actually used palette entry 01130 */ 01131 int setcolor( short pair ); 01132 01133 // ------------------------------------------------------------------------- 01134 // window positioning 01135 // ------------------------------------------------------------------------- 01136 /** 01137 * Move window to new position with the new position as top left corner. 01138 * This is virtual because it is redefined in NCursesPanel. 01139 */ 01140 virtual int mvwin( int begin_y, int begin_x ) 01141 { 01142 return ::mvwin( w, begin_y, begin_x ); 01143 } 01144 01145 int mvsubwin( NCursesWindow* sub, int begin_y, int begin_x ); 01146 01147 virtual int resize( int lines, int columns ); 01148 01149 // ------------------------------------------------------------------------- 01150 // coordinate positioning 01151 // ------------------------------------------------------------------------- 01152 /** 01153 * Move cursor the this position 01154 */ 01155 int move( int y, int x ) { return ::wmove( w, y, x ); } 01156 01157 /** 01158 * Get current position of the cursor 01159 */ 01160 void getyx( int& y, int& x ) const { ::getyx( w, y, x ); } 01161 01162 /** 01163 * Perform lowlevel cursor motion that takes effect immediately. 01164 */ 01165 int mvcur( int oldrow, int oldcol, int newrow, int newcol ) const 01166 { 01167 return ::mvcur( oldrow, oldcol, newrow, newcol ); 01168 } 01169 01170 // ------------------------------------------------------------------------- 01171 // input 01172 // ------------------------------------------------------------------------- 01173 01174 int nodelay( bool bf ) { return ::nodelay( w, bf ); } 01175 01176 /** 01177 * Get a keystroke from the window. 01178 */ 01179 int getch() { return ::wgetch( w ); } 01180 01181 /** 01182 * Move cursor to position and get a keystroke from the window 01183 */ 01184 int getch( int y, int x ) { return ::mvwgetch( w, y, x ); } 01185 01186 /** 01187 * Read a series of characters into str until a newline or carriage return 01188 * is received. Read at most n characters. If n is negative, the limit is 01189 * ignored. 01190 */ 01191 int getstr( char* str, int n = -1 ) 01192 { 01193 return ::wgetnstr( w, str, n ); 01194 } 01195 01196 /** 01197 * Move the cursor to the requested position and then perform the getstr() 01198 * as described above. 01199 */ 01200 int getstr( int y, int x, char* str, int n = -1 ) 01201 { 01202 return ::mvwgetnstr( w, y, x, str, n ); 01203 } 01204 01205 /** 01206 * Get a std::string of characters from the window into the buffer s. Retrieve 01207 * at most n characters, if n is negative retrieve all characters up to the 01208 * end of the current line. Attributes are stripped from the characters. 01209 */ 01210 int instr( char *s, int n = -1 ) { return ::winnstr( w, s, n ); } 01211 01212 /** 01213 * Move the cursor to the requested position and then perform the instr() 01214 * as described above. 01215 */ 01216 int instr( int y, int x, char *s, int n = -1 ) 01217 { 01218 return ::mvwinnstr( w, y, x, s, n ); 01219 } 01220 01221 01222 // ------------------------------------------------------------------------- 01223 // output 01224 // ------------------------------------------------------------------------- 01225 /** 01226 * Put attributed character to the window. 01227 */ 01228 int addch( const char ch ) 01229 { 01230 return addch(( const chtype )( ch&A_CHARTEXT ) ); 01231 } 01232 01233 int addch( const chtype ch ) { return ::waddch( w, ch ); } 01234 01235 /** 01236 * Put attributed character from given position to the window. 01237 */ 01238 int add_attr_char( int y, int x ); 01239 int add_attr_char(); 01240 01241 /** 01242 * Put a combined character to the window. 01243 */ 01244 int add_wch( const cchar_t * cch ) { return ::wadd_wch( w, cch ); } 01245 01246 int add_wch( int y, int x, const cchar_t * cch ) { return mvwadd_wch( w, y, x, cch ); } 01247 01248 /** 01249 * Move cursor to the requested position and then put attributed character 01250 * to the window. 01251 */ 01252 int addch( int y, int x, const char ch ) 01253 { 01254 return addch( y, x, ( const chtype )( ch&A_CHARTEXT ) ); 01255 } 01256 01257 int addch( int y, int x, const chtype ch ) 01258 { 01259 return ::mvwaddch( w, y, x, ch ); 01260 } 01261 01262 /** 01263 * Put attributed character to the window and refresh it immediately. 01264 */ 01265 int echochar( const char ch ) 01266 { 01267 return echochar(( const chtype )( ch&A_CHARTEXT ) ); 01268 } 01269 01270 int echochar( const chtype ch ) { return ::wechochar( w, ch ); } 01271 01272 /** 01273 * Write the std::string str to the window, stop writing if the terminating 01274 * NUL or the limit n is reached. If n is negative, it is ignored. 01275 */ 01276 int addstr( const char* str, int n = -1 ) 01277 { 01278 return ::waddnstr( w, ( char* )str, n ); 01279 } 01280 01281 /** 01282 * Move the cursor to the requested position and then perform the addstr 01283 * as described above. 01284 */ 01285 int addstr( int y, int x, const char * str, int n = -1 ) 01286 { 01287 return ::mvwaddnstr( w, y, x, ( char* )str, n ); 01288 } 01289 01290 /** 01291 * Write the wchar_t str to the window, stop writing if the terminating 01292 * NUL or the limit n is reached. If n is negative, it is ignored. 01293 */ 01294 int addwstr( const wchar_t* str, int n = -1 ); 01295 01296 /** 01297 * Move the cursor to the requested position and then perform the addwstr 01298 * as described above. 01299 */ 01300 int addwstr( int y, int x, const wchar_t * str, int n = -1 ); 01301 01302 /** 01303 * Do a formatted print to the window. 01304 */ 01305 int printw( const char* fmt, ... ) 01306 #if __GNUG__ >= 2 01307 __attribute__(( format( printf, 2, 3 ) ) ); 01308 #else 01309 ; 01310 #endif 01311 01312 /** 01313 * Move the cursor and then do a formatted print to the window. 01314 */ 01315 int printw( int y, int x, const char * fmt, ... ) 01316 #if __GNUG__ >= 2 01317 __attribute__(( format( printf, 4, 5 ) ) ); 01318 #else 01319 ; 01320 #endif 01321 01322 /** 01323 * Retrieve attributed character under the current cursor position. 01324 */ 01325 chtype inch() const { return ::winch( w ); } 01326 01327 chtype inchar() const { return inch()&( A_CHARTEXT | A_ALTCHARSET ); } 01328 01329 /** 01330 * Move cursor to requested position and then retrieve attributed character 01331 * at this position. 01332 */ 01333 chtype inch( int y, int x ) { return ::mvwinch( w, y, x ); } 01334 01335 chtype inchar( int y, int x ) { return inch( y, x )&( A_CHARTEXT | A_ALTCHARSET ); } 01336 01337 /** 01338 * Retrieve combined character under the current cursor position. 01339 */ 01340 int in_wchar( cchar_t * cchar ); 01341 int in_wchar( int y, int x, cchar_t * cchar ); 01342 01343 /** 01344 * Insert attributed character into the window before current cursor 01345 * position. 01346 */ 01347 int insch( chtype ch ) { return ::winsch( w, ch ); } 01348 01349 /** 01350 * Move cursor to requested position and then insert the attributed 01351 * character before that position. 01352 */ 01353 int insch( int y, int x, chtype ch ) 01354 { 01355 return ::mvwinsch( w, y, x, ch ); 01356 } 01357 01358 /** 01359 * Move cursor to requested position and then insert the attributed 01360 * character before that position. 01361 */ 01362 int ins_wch( int y, int x, const cchar_t * cchar ) 01363 { 01364 return mvwins_wch( w, y, x, cchar ); 01365 } 01366 01367 /** 01368 * Insert an empty line above the current line. 01369 */ 01370 int insertln() { return ::winsdelln( w, 1 ); } 01371 01372 /** 01373 * If n>0 insert that many lines above the current line. If n<0 delete 01374 * that many lines beginning with the current line. 01375 */ 01376 int insdelln( int n = 1 ) { return ::winsdelln( w, n ); } 01377 01378 /** 01379 * Insert the std::string into the window before the current cursor position. 01380 * Insert stops at end of std::string or when the limit n is reached. If n is 01381 * negative, it is ignored. 01382 */ 01383 int insstr( const char *s, int n = -1 ) 01384 { 01385 return ::winsnstr( w, s, n ); 01386 } 01387 01388 /** 01389 * Move the cursor to the requested position and then perform the insstr() 01390 * as described above. 01391 */ 01392 int insstr( int y, int x, const char *s, int n = -1 ) 01393 { 01394 return ::mvwinsnstr( w, y, x, s, n ); 01395 } 01396 01397 /** 01398 * Switch on the window attributes; 01399 */ 01400 int attron( chtype at ) { return ::wattron( w, at ); } 01401 01402 /** 01403 * Switch off the window attributes; 01404 */ 01405 int attroff( chtype at ) { return ::wattroff( w, at ); } 01406 01407 /** 01408 * Set the window attributes; 01409 */ 01410 int attrset( chtype at ) { return ::wattrset( w, at ); } 01411 01412 /** 01413 * Change the attributes of the next n characters in the current line. If 01414 * n is negative or greater than the number of remaining characters in the 01415 * line, the attributes will be changed up to the end of the line. 01416 */ 01417 int chgat( int n, attr_t attr, short color, const void *opts = NULL ) 01418 { 01419 return ::wchgat( w, n, attr, color, opts ); 01420 } 01421 01422 /** 01423 * Move the cursor to the requested position and then perform chgat() as 01424 * described above. 01425 */ 01426 int chgat( int y, int x, 01427 int n, attr_t attr, short color, const void *opts = NULL ) 01428 { 01429 return ::mvwchgat( w, y, x, n, attr, color, opts ); 01430 } 01431 01432 // ------------------------------------------------------------------------- 01433 // background 01434 // ------------------------------------------------------------------------- 01435 /** 01436 * Get current background setting. 01437 */ 01438 chtype getbkgd() const { return ::getbkgd( w ); } 01439 01440 /** 01441 * Set the background property and apply it to the window. 01442 */ 01443 int bkgd( const chtype ch ) { return ::wbkgd( w, ch ); } 01444 01445 /** 01446 * Set the background property. 01447 */ 01448 void bkgdset( chtype ch ) { ::wbkgdset( w, ch ); } 01449 01450 // ------------------------------------------------------------------------- 01451 // borders 01452 // ------------------------------------------------------------------------- 01453 /** 01454 * Draw a box around the window with the given vertical and horizontal 01455 * drawing characters. If you specifiy a zero as character, curses will try 01456 * to find a "nice" character. 01457 */ 01458 // int box(chtype vert=0, chtype hor=0) { 01459 // return ::wborder(w, vert, vert, hor, hor, 0, 0 ,0, 0); } 01460 01461 // workaround for 8.1: don't use wborder to draw the box 01462 int box() { return box( wrect( wpos( 0, 0 ), size() ) ); } 01463 01464 /** 01465 * Draw a border around the window with the given characters for the 01466 * various parts of the border. If you pass zero for a character, curses 01467 * will try to find "nice" characters. 01468 */ 01469 int border( chtype left = 0, chtype right = 0, 01470 chtype top = 0, chtype bottom = 0, 01471 chtype top_left = 0, chtype top_right = 0, 01472 chtype bottom_left = 0, chtype bottom_right = 0 ) 01473 { 01474 return ::wborder( w, left, right, top, bottom, top_left, top_right, 01475 bottom_left, bottom_right ); 01476 } 01477 01478 // ------------------------------------------------------------------------- 01479 // lines and boxes 01480 // ------------------------------------------------------------------------- 01481 /** 01482 * Draw a horizontal line of len characters with the given character. If 01483 * you pass zero for the character, curses will try to find a "nice" one. 01484 */ 01485 int hline( int len, chtype ch = 0 ) { return ::whline( w, ch, len ); } 01486 01487 /** 01488 * Move the cursor to the requested position and then draw a horizontal line. 01489 */ 01490 int hline( int y, int x, int len, chtype ch = 0 ) 01491 { 01492 return ::mvwhline( w, y, x, ch, len ); 01493 } 01494 01495 /** 01496 * Draw a vertical line of len characters with the given character. If 01497 * you pass zero for the character, curses will try to find a "nice" one. 01498 */ 01499 int vline( int len, chtype ch = 0 ) { return ::wvline( w, ch, len ); } 01500 01501 /** 01502 * Move the cursor to the requested position and then draw a vertical line. 01503 */ 01504 int vline( int y, int x, int len, chtype ch = 0 ) 01505 { 01506 return ::mvwvline( w, y, x, ch, len ); 01507 } 01508 01509 int box( const wrect & dim ); 01510 01511 // ------------------------------------------------------------------------- 01512 // erasure 01513 // ------------------------------------------------------------------------- 01514 /** 01515 * Erase the window. 01516 */ 01517 int erase() { return ::werase( w ); } 01518 01519 /** 01520 * Clear the window. 01521 */ 01522 int clear() { return ::wclear( w ); } 01523 01524 /** 01525 * Set/Reset the clear flag. If std::set, the next refresh() will clear the 01526 * screen. 01527 */ 01528 int clearok( bool bf ) { return ::clearok( w, bf ); } 01529 01530 /** 01531 * Clear to the end of the window. 01532 */ 01533 int clrtobot() { return ::wclrtobot( w ); } 01534 01535 /** 01536 * Clear to the end of the line. 01537 */ 01538 int clrtoeol() { return ::wclrtoeol( w ); } 01539 01540 /** 01541 * Delete character under the cursor. 01542 */ 01543 int delch() { return ::wdelch( w ); } 01544 01545 /** 01546 * Move cursor to requested position and delete the character under the 01547 * cursor. 01548 */ 01549 int delch( int y, int x ) { return ::mvwdelch( w, y, x ); } 01550 01551 /** 01552 * Delete the current line. 01553 */ 01554 int deleteln() { return ::winsdelln( w, -1 ); } 01555 01556 // ------------------------------------------------------------------------- 01557 // screen control 01558 // ------------------------------------------------------------------------- 01559 /** 01560 * Scroll amount lines. If amount is positive, scroll up, otherwise 01561 * scroll down. 01562 */ 01563 int scroll( int amount = 1 ) { return ::wscrl( w, amount ); } 01564 01565 /** 01566 * If bf is TRUE, window scrolls if cursor is moved off the bottom 01567 * edge of the window or a scrolling region, otherwise the cursor is left 01568 * at the bottom line. 01569 */ 01570 int scrollok( bool bf ) { return ::scrollok( w, bf ); } 01571 01572 /** 01573 * Define a soft scrolling region. 01574 */ 01575 int setscrreg( int from, int to ) 01576 { 01577 return ::wsetscrreg( w, from, to ); 01578 } 01579 01580 /** 01581 * If bf is TRUE, use insert/delete line hardware support if possible. 01582 * Otherwise do it in software. 01583 */ 01584 int idlok( bool bf ) { return ::idlok( w, bf ); } 01585 01586 /** 01587 * If bf is TRUE, use insert/delete character hardware support if possible. 01588 * Otherwise do it in software. 01589 */ 01590 void idcok( bool bf ) { ::idcok( w, bf ); } 01591 01592 /** 01593 * Mark the whole window as modified. 01594 */ 01595 int touchwin() { return ::wtouchln( w, 0, height(), 1 ); } 01596 01597 /** 01598 * Mark the whole window as unmodified. 01599 */ 01600 int untouchwin() { return ::wtouchln( w, 0, height(), 0 ); } 01601 01602 /** 01603 * Mark cnt lines beginning from line s as changed or unchanged, depending 01604 * on the value of the changed flag. 01605 */ 01606 int touchln( int s, int cnt, bool changed = TRUE ) 01607 { 01608 return ::wtouchln( w, s, cnt, ( int )( changed ? 1 : 0 ) ); 01609 } 01610 01611 /** 01612 * Return TRUE if line is marked as changed, FALSE otherwise 01613 */ 01614 bool is_linetouched( int line ) const 01615 { 01616 return ( ::is_linetouched( w, line ) ? TRUE : FALSE ); 01617 } 01618 01619 /** 01620 * Return TRUE if window is marked as changed, FALSE otherwise 01621 */ 01622 bool is_wintouched() const 01623 { 01624 return ( ::is_wintouched( w ) ? TRUE : FALSE ); 01625 } 01626 01627 /** 01628 * If bf is TRUE, curses will leave the cursor after an update whereever 01629 * it is after the update. 01630 */ 01631 int leaveok( bool bf ) { return ::leaveok( w, bf ); } 01632 01633 /** 01634 * Redraw n lines starting from the requested line 01635 */ 01636 int redrawln( int from, int n ) { return ::wredrawln( w, from, n ); } 01637 01638 /** 01639 * Redraw the whole window 01640 */ 01641 int redrawwin() { return ::wredrawln( w, 0, height() ); } 01642 01643 /** 01644 * Do all outputs to make the physical screen looking like the virtual one 01645 */ 01646 int doupdate() { return ::doupdate(); } 01647 01648 /** 01649 * Propagate the changes down to all descendant windows 01650 */ 01651 void syncdown() { ::wsyncdown( w ); } 01652 01653 /** 01654 * Propagate the changes up in the hierarchy 01655 */ 01656 void syncup() { ::wsyncup( w ); } 01657 01658 /** 01659 * Position the cursor in all ancestor windows corresponding to our setting 01660 */ 01661 void cursyncup() { ::wcursyncup( w ); } 01662 01663 /** 01664 * If called with bf=TRUE, syncup() is called whenever the window is changed 01665 */ 01666 int syncok( bool bf ) { return ::syncok( w, bf ); } 01667 01668 #ifndef _no_flushok 01669 int flushok( bool bf ) { return ::flushok( w, bf ); } 01670 01671 #endif 01672 01673 /** 01674 * If called with bf=TRUE, any change in the window will cause an 01675 * automatic immediate refresh() 01676 */ 01677 void immedok( bool bf ) { ::immedok( w, bf ); } 01678 01679 /** 01680 * If called with bf=TRUE, the application will interpret function keys. 01681 */ 01682 int keypad( bool bf ) { return ::keypad( w, bf ); } 01683 01684 /** 01685 * If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise 01686 * 7-Bit characters are generated. 01687 */ 01688 int meta( bool bf ) { return ::meta( w, bf ); } 01689 01690 /** 01691 * Enable "standout" attributes 01692 */ 01693 int standout() { return ::wstandout( w ); } 01694 01695 /** 01696 * Disable "standout" attributes 01697 */ 01698 int standend() { return ::wstandend( w ); } 01699 01700 // ------------------------------------------------------------------------- 01701 // The next two are virtual, because we redefine them in the 01702 // NCursesPanel class. 01703 // ------------------------------------------------------------------------- 01704 /** 01705 * Propagate the changes in this window to the virtual screen and call 01706 * doupdate(). This is redefined in NCursesPanel. 01707 */ 01708 virtual int refresh() { return ::wrefresh( w ); } 01709 01710 /** 01711 * Propagate the changes in this window to the virtual screen. This is 01712 * redefined in NCursesPanel. 01713 */ 01714 virtual int noutrefresh() { return ::wnoutrefresh( w ); } 01715 01716 // ------------------------------------------------------------------------- 01717 // multiple window control 01718 // ------------------------------------------------------------------------- 01719 /** 01720 * Overlay this window over win. 01721 */ 01722 int overlay( NCursesWindow& win ) 01723 { 01724 return ::overlay( w, win.w ); 01725 } 01726 01727 /** 01728 * Overwrite win with this window. 01729 */ 01730 int overwrite( NCursesWindow& win ) 01731 { 01732 return ::overwrite( w, win.w ); 01733 } 01734 01735 /** 01736 * Overlay or overwrite the rectangle in win given by dminrow,dmincol, 01737 * dmaxrow,dmaxcol with the rectangle in this window beginning at 01738 * sminrow,smincol. 01739 */ 01740 int copywin( NCursesWindow& win, 01741 int sminrow, int smincol, 01742 int dminrow, int dmincol, 01743 int dmaxrow, int dmaxcol, bool overlay = TRUE ) 01744 { 01745 return ::copywin( w, win.w, sminrow, smincol, dminrow, dmincol, 01746 dmaxrow, dmaxcol, ( int )( overlay ? 1 : 0 ) ); 01747 } 01748 01749 // ------------------------------------------------------------------------- 01750 // Mouse related 01751 // ------------------------------------------------------------------------- 01752 /** 01753 * Return TRUE if terminal supports a mouse, FALSE otherwise 01754 */ 01755 bool has_mouse() const; 01756 01757 // ------------------------------------------------------------------------- 01758 // traversal support 01759 // ------------------------------------------------------------------------- 01760 /** 01761 * Get the first child window. 01762 */ 01763 NCursesWindow* child() { return subwins; } 01764 01765 const NCursesWindow* child() const { return subwins; } 01766 01767 /** 01768 * Get the next child of my parent. 01769 */ 01770 NCursesWindow* sibling() { return sib; } 01771 01772 const NCursesWindow* sibling() const { return sib; } 01773 01774 /** 01775 * Get my parent. 01776 */ 01777 NCursesWindow* parent() { return par; } 01778 01779 const NCursesWindow* parent() const { return par; } 01780 01781 /** 01782 * Return TRUE if win is a descendant of this. 01783 */ 01784 bool isDescendant( NCursesWindow& win ); 01785 }; 01786 01787 /** 01788 * @short We leave this here for compatibility reasons. 01789 */ 01790 01791 class NCursesColorWindow : public NCursesWindow 01792 { 01793 01794 public: 01795 /** 01796 * Constructor. Useful only for stdscr 01797 */ 01798 NCursesColorWindow( WINDOW* &window ) 01799 : NCursesWindow( window ) 01800 { 01801 useColors(); 01802 } 01803 01804 /** 01805 * Constructor. 01806 **/ 01807 NCursesColorWindow( int lines, 01808 int cols, 01809 int begin_y, 01810 int begin_x ) 01811 : NCursesWindow( lines, cols, begin_y, begin_x ) 01812 { 01813 useColors(); 01814 } 01815 01816 /** 01817 * Constructor. 01818 * 01819 * If 'absrel' is 'a', begin_x/y are absolute screen pos, 01820 * else if 'r', they are relative to par origin 01821 */ 01822 NCursesColorWindow( NCursesWindow& par, 01823 int lines, 01824 int cols, 01825 int begin_y, 01826 int begin_x, 01827 char absrel = 'a' ) 01828 : NCursesWindow( par, lines, cols, 01829 begin_y, begin_x, 01830 absrel ) 01831 { 01832 useColors(); 01833 } 01834 }; 01835 01836 /** 01837 * @short 01838 */ 01839 01840 class NCursesPad : public NCursesWindow 01841 { 01842 01843 public: 01844 NCursesPad( int lines, int cols ); 01845 01846 /** 01847 * Put the attributed character onto the pad and immediately do a 01848 * prefresh(). 01849 */ 01850 int echochar( const chtype ch ) { return ::pechochar( w, ch ); } 01851 01852 /** 01853 * For Pad's we reimplement refresh() and noutrefresh() to do nothing. 01854 * You should call the versions with the argument std::list that are specific 01855 * for Pad's. 01856 */ 01857 int refresh() { return OK; }; 01858 01859 int noutrefresh() { return OK; }; 01860 01861 /** 01862 * The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle 01863 * on the screen. <b>refresh</b> copies a rectangle of this size beginning 01864 * with top left corner pminrow,pmincol onto the screen and calls doupdate(). 01865 */ 01866 int refresh( int pminrow, int pmincol, 01867 int sminrow, int smincol, 01868 int smaxrow, int smaxcol ) 01869 { 01870 return ::prefresh( w, pminrow, pmincol, 01871 sminrow, smincol, smaxrow, smaxcol ); 01872 } 01873 01874 /** 01875 * Does the same like refresh() but without calling doupdate(). 01876 */ 01877 int noutrefresh( int pminrow, int pmincol, 01878 int sminrow, int smincol, 01879 int smaxrow, int smaxcol ) 01880 { 01881 return ::pnoutrefresh( w, pminrow, pmincol, 01882 sminrow, smincol, smaxrow, smaxcol ); 01883 } 01884 }; 01885 01886 #endif // _CURSESW_H