Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-07 10:26:43

0001 // * This makes emacs happy -*-Mode: C++;-*-
0002 // vile:cppmode
0003 /****************************************************************************
0004  * Copyright 2019-2024,2025 Thomas E. Dickey                                *
0005  * Copyright 1998-2014,2017 Free Software Foundation, Inc.                  *
0006  *                                                                          *
0007  * Permission is hereby granted, free of charge, to any person obtaining a  *
0008  * copy of this software and associated documentation files (the            *
0009  * "Software"), to deal in the Software without restriction, including      *
0010  * without limitation the rights to use, copy, modify, merge, publish,      *
0011  * distribute, distribute with modifications, sublicense, and/or sell       *
0012  * copies of the Software, and to permit persons to whom the Software is    *
0013  * furnished to do so, subject to the following conditions:                 *
0014  *                                                                          *
0015  * The above copyright notice and this permission notice shall be included  *
0016  * in all copies or substantial portions of the Software.                   *
0017  *                                                                          *
0018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
0019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
0020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
0021  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
0022  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
0023  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
0024  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
0025  *                                                                          *
0026  * Except as contained in this notice, the name(s) of the above copyright   *
0027  * holders shall not be used in advertising or otherwise to promote the     *
0028  * sale, use or other dealings in this Software without prior written       *
0029  * authorization.                                                           *
0030  ****************************************************************************/
0031 
0032 #ifndef NCURSES_CURSESW_H_incl
0033 #define NCURSES_CURSESW_H_incl 1
0034 
0035 // $Id: cursesw.h,v 1.62 2025/01/25 21:21:05 tom Exp $
0036 
0037 #include <ncursesw/curses.h>
0038 
0039 #if defined(BUILDING_NCURSES_CXX)
0040 # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
0041 #else
0042 # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
0043 #endif
0044 
0045 #define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
0046 
0047 #define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API
0048 #define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type
0049 
0050 #include <ncursesw/etip.h>
0051 
0052 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
0053    Undefine it here, because NCursesWindow uses lines as a method.  */
0054 #undef lines
0055 
0056 /* "Convert" macros to inlines. We'll define it as another symbol to avoid
0057  * conflict with library symbols.
0058  */
0059 #undef UNDEF
0060 #define UNDEF(name) CUR_ ##name
0061 
0062 #ifdef addch
0063 inline int UNDEF(addch)(chtype ch)  { return addch(ch); }
0064 #undef addch
0065 #define addch UNDEF(addch)
0066 #endif
0067 
0068 #ifdef addchstr
0069 inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
0070 #undef addchstr
0071 #define addchstr UNDEF(addchstr)
0072 #endif
0073 
0074 #ifdef addnstr
0075 inline int UNDEF(addnstr)(const char *str, int n)
0076 { return addnstr(str, n); }
0077 #undef addnstr
0078 #define addnstr UNDEF(addnstr)
0079 #endif
0080 
0081 #ifdef addstr
0082 inline int UNDEF(addstr)(const char * str)  { return addstr(str); }
0083 #undef addstr
0084 #define addstr UNDEF(addstr)
0085 #endif
0086 
0087 #ifdef attroff
0088 inline int UNDEF(attroff)(chtype at) { return attroff(at); }
0089 #undef attroff
0090 #define attroff UNDEF(attroff)
0091 #endif
0092 
0093 #ifdef attron
0094 inline int UNDEF(attron)(chtype at) { return attron(at); }
0095 #undef attron
0096 #define attron UNDEF(attron)
0097 #endif
0098 
0099 #ifdef attrset
0100 inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
0101 #undef attrset
0102 #define attrset UNDEF(attrset)
0103 #endif
0104 
0105 #ifdef bkgd
0106 inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
0107 #undef bkgd
0108 #define bkgd UNDEF(bkgd)
0109 #endif
0110 
0111 #ifdef bkgdset
0112 inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
0113 #undef bkgdset
0114 #define bkgdset UNDEF(bkgdset)
0115 #endif
0116 
0117 #ifdef border
0118 inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
0119 { return border(ls, rs, ts, bs, tl, tr, bl, br); }
0120 #undef border
0121 #define border UNDEF(border)
0122 #endif
0123 
0124 #ifdef box
0125 inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
0126 #undef box
0127 #define box UNDEF(box)
0128 #endif
0129 
0130 #ifdef chgat
0131 inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
0132   return chgat(n, attr, color, opts); }
0133 #undef chgat
0134 #define chgat UNDEF(chgat)
0135 #endif
0136 
0137 #ifdef clear
0138 inline int UNDEF(clear)()  { return clear(); }
0139 #undef clear
0140 #define clear UNDEF(clear)
0141 #endif
0142 
0143 #ifdef clearok
0144 inline int UNDEF(clearok)(WINDOW* win, bool bf)  { return clearok(win, bf); }
0145 #undef clearok
0146 #define clearok UNDEF(clearok)
0147 #else
0148 extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
0149 #endif
0150 
0151 #ifdef clrtobot
0152 inline int UNDEF(clrtobot)()  { return clrtobot(); }
0153 #undef clrtobot
0154 #define clrtobot UNDEF(clrtobot)
0155 #endif
0156 
0157 #ifdef clrtoeol
0158 inline int UNDEF(clrtoeol)()  { return clrtoeol(); }
0159 #undef clrtoeol
0160 #define clrtoeol UNDEF(clrtoeol)
0161 #endif
0162 
0163 #ifdef color_set
0164 inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
0165 #undef color_set
0166 #define color_set UNDEF(color_set)
0167 #endif
0168 
0169 #ifdef crmode
0170 inline int UNDEF(crmode)(void) { return crmode(); }
0171 #undef crmode
0172 #define crmode UNDEF(crmode)
0173 #endif
0174 
0175 #ifdef delch
0176 inline int UNDEF(delch)()  { return delch(); }
0177 #undef delch
0178 #define delch UNDEF(delch)
0179 #endif
0180 
0181 #ifdef deleteln
0182 inline int UNDEF(deleteln)()  { return deleteln(); }
0183 #undef deleteln
0184 #define deleteln UNDEF(deleteln)
0185 #endif
0186 
0187 #ifdef echochar
0188 inline int UNDEF(echochar)(chtype ch)  { return echochar(ch); }
0189 #undef echochar
0190 #define echochar UNDEF(echochar)
0191 #endif
0192 
0193 #ifdef erase
0194 inline int UNDEF(erase)()  { return erase(); }
0195 #undef erase
0196 #define erase UNDEF(erase)
0197 #endif
0198 
0199 #ifdef fixterm
0200 inline int UNDEF(fixterm)(void) { return fixterm(); }
0201 #undef fixterm
0202 #define fixterm UNDEF(fixterm)
0203 #endif
0204 
0205 #ifdef flushok
0206 inline int UNDEF(flushok)(WINDOW* _win, bool _bf)  {
0207   return flushok(_win, _bf); }
0208 #undef flushok
0209 #define flushok UNDEF(flushok)
0210 #else
0211 #define _no_flushok
0212 #endif
0213 
0214 #ifdef getattrs
0215 inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
0216 #undef getattrs
0217 #define getattrs UNDEF(getattrs)
0218 #endif
0219 
0220 #ifdef getbegyx
0221 inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
0222 #undef getbegyx
0223 #define getbegyx UNDEF(getbegyx)
0224 #endif
0225 
0226 #ifdef getbkgd
0227 inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
0228 #undef getbkgd
0229 #define getbkgd UNDEF(getbkgd)
0230 #endif
0231 
0232 #ifdef getch
0233 inline int UNDEF(getch)()  { return getch(); }
0234 #undef getch
0235 #define getch UNDEF(getch)
0236 #endif
0237 
0238 #ifdef getmaxyx
0239 inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
0240 #undef getmaxyx
0241 #define getmaxyx UNDEF(getmaxyx)
0242 #endif
0243 
0244 #ifdef getnstr
0245 inline int UNDEF(getnstr)(char *_str, int n)  { return getnstr(_str, n); }
0246 #undef getnstr
0247 #define getnstr UNDEF(getnstr)
0248 #endif
0249 
0250 #ifdef getparyx
0251 inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
0252 #undef getparyx
0253 #define getparyx UNDEF(getparyx)
0254 #endif
0255 
0256 #ifdef getstr
0257 inline int UNDEF(getstr)(char *_str)  { return getstr(_str); }
0258 #undef getstr
0259 #define getstr UNDEF(getstr)
0260 #endif
0261 
0262 #ifdef getyx
0263 inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
0264   getyx(win, y, x); }
0265 #undef getyx
0266 #define getyx UNDEF(getyx)
0267 #endif
0268 
0269 #ifdef hline
0270 inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
0271 #undef hline
0272 #define hline UNDEF(hline)
0273 #endif
0274 
0275 #ifdef inch
0276 inline chtype UNDEF(inch)()  { return inch(); }
0277 #undef inch
0278 #define inch UNDEF(inch)
0279 #endif
0280 
0281 #ifdef inchstr
0282 inline int UNDEF(inchstr)(chtype *str)  { return inchstr(str); }
0283 #undef inchstr
0284 #define inchstr UNDEF(inchstr)
0285 #endif
0286 
0287 #ifdef innstr
0288 inline int UNDEF(innstr)(char *_str, int n)  { return innstr(_str, n); }
0289 #undef innstr
0290 #define innstr UNDEF(innstr)
0291 #endif
0292 
0293 #ifdef insch
0294 inline int UNDEF(insch)(chtype c)  { return insch(c); }
0295 #undef insch
0296 #define insch UNDEF(insch)
0297 #endif
0298 
0299 #ifdef insdelln
0300 inline int UNDEF(insdelln)(int n)  { return insdelln(n); }
0301 #undef insdelln
0302 #define insdelln UNDEF(insdelln)
0303 #endif
0304 
0305 #ifdef insertln
0306 inline int UNDEF(insertln)()  { return insertln(); }
0307 #undef insertln
0308 #define insertln UNDEF(insertln)
0309 #endif
0310 
0311 #ifdef insnstr
0312 inline int UNDEF(insnstr)(const char *_str, int n)  {
0313   return insnstr(_str, n); }
0314 #undef insnstr
0315 #define insnstr UNDEF(insnstr)
0316 #endif
0317 
0318 #ifdef insstr
0319 inline int UNDEF(insstr)(const char *_str)  {
0320   return insstr(_str); }
0321 #undef insstr
0322 #define insstr UNDEF(insstr)
0323 #endif
0324 
0325 #ifdef instr
0326 inline int UNDEF(instr)(char *_str)  { return instr(_str); }
0327 #undef instr
0328 #define instr UNDEF(instr)
0329 #endif
0330 
0331 #ifdef intrflush
0332 inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
0333 #undef intrflush
0334 #define intrflush UNDEF(intrflush)
0335 #endif
0336 
0337 #ifdef is_linetouched
0338 inline int UNDEF(is_linetouched)(WINDOW *w, int l)  { return is_linetouched(w,l); }
0339 #undef is_linetouched
0340 #define is_linetouched UNDEF(is_linetouched)
0341 #endif
0342 
0343 #ifdef leaveok
0344 inline int UNDEF(leaveok)(WINDOW* win, bool bf)  { return leaveok(win, bf); }
0345 #undef leaveok
0346 #define leaveok UNDEF(leaveok)
0347 #else
0348 extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
0349 #endif
0350 
0351 #ifdef move
0352 inline int UNDEF(move)(int x, int y)  { return move(x, y); }
0353 #undef move
0354 #define move UNDEF(move)
0355 #endif
0356 
0357 #ifdef mvaddch
0358 inline int UNDEF(mvaddch)(int y, int x, chtype ch)
0359 { return mvaddch(y, x, ch); }
0360 #undef mvaddch
0361 #define mvaddch UNDEF(mvaddch)
0362 #endif
0363 
0364 #ifdef mvaddnstr
0365 inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
0366 { return mvaddnstr(y, x, str, n); }
0367 #undef mvaddnstr
0368 #define mvaddnstr UNDEF(mvaddnstr)
0369 #endif
0370 
0371 #ifdef mvaddstr
0372 inline int UNDEF(mvaddstr)(int y, int x, const char * str)
0373 { return mvaddstr(y, x, str); }
0374 #undef mvaddstr
0375 #define mvaddstr UNDEF(mvaddstr)
0376 #endif
0377 
0378 #ifdef mvchgat
0379 inline int UNDEF(mvchgat)(int y, int x, int n,
0380               attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
0381   return mvchgat(y, x, n, attr, color, opts); }
0382 #undef mvchgat
0383 #define mvchgat UNDEF(mvchgat)
0384 #endif
0385 
0386 #ifdef mvdelch
0387 inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
0388 #undef mvdelch
0389 #define mvdelch UNDEF(mvdelch)
0390 #endif
0391 
0392 #ifdef mvgetch
0393 inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
0394 #undef mvgetch
0395 #define mvgetch UNDEF(mvgetch)
0396 #endif
0397 
0398 #ifdef mvgetnstr
0399 inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
0400   return mvgetnstr(y, x, str, n);}
0401 #undef mvgetnstr
0402 #define mvgetnstr UNDEF(mvgetnstr)
0403 #endif
0404 
0405 #ifdef mvgetstr
0406 inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
0407 #undef mvgetstr
0408 #define mvgetstr UNDEF(mvgetstr)
0409 #endif
0410 
0411 #ifdef mvinch
0412 inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
0413 #undef mvinch
0414 #define mvinch UNDEF(mvinch)
0415 #endif
0416 
0417 #ifdef mvinnstr
0418 inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
0419   return mvinnstr(y, x, _str, n); }
0420 #undef mvinnstr
0421 #define mvinnstr UNDEF(mvinnstr)
0422 #endif
0423 
0424 #ifdef mvinsch
0425 inline int UNDEF(mvinsch)(int y, int x, chtype c)
0426 { return mvinsch(y, x, c); }
0427 #undef mvinsch
0428 #define mvinsch UNDEF(mvinsch)
0429 #endif
0430 
0431 #ifdef mvinsnstr
0432 inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
0433   return mvinsnstr(y, x, _str, n); }
0434 #undef mvinsnstr
0435 #define mvinsnstr UNDEF(mvinsnstr)
0436 #endif
0437 
0438 #ifdef mvinsstr
0439 inline int UNDEF(mvinsstr)(int y, int x, const char *_str)  {
0440   return mvinsstr(y, x, _str); }
0441 #undef mvinsstr
0442 #define mvinsstr UNDEF(mvinsstr)
0443 #endif
0444 
0445 #ifdef mvwaddch
0446 inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
0447 { return mvwaddch(win, y, x, ch); }
0448 #undef mvwaddch
0449 #define mvwaddch UNDEF(mvwaddch)
0450 #endif
0451 
0452 #ifdef mvwaddchnstr
0453 inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
0454 { return mvwaddchnstr(win, y, x, str, n); }
0455 #undef mvwaddchnstr
0456 #define mvwaddchnstr UNDEF(mvwaddchnstr)
0457 #endif
0458 
0459 #ifdef mvwaddchstr
0460 inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
0461 { return mvwaddchstr(win, y, x, str); }
0462 #undef mvwaddchstr
0463 #define mvwaddchstr UNDEF(mvwaddchstr)
0464 #endif
0465 
0466 #ifdef mvwaddnstr
0467 inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
0468 { return mvwaddnstr(win, y, x, str, n); }
0469 #undef mvwaddnstr
0470 #define mvwaddnstr UNDEF(mvwaddnstr)
0471 #endif
0472 
0473 #ifdef mvwaddstr
0474 inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
0475 { return mvwaddstr(win, y, x, str); }
0476 #undef mvwaddstr
0477 #define mvwaddstr UNDEF(mvwaddstr)
0478 #endif
0479 
0480 #ifdef mvwchgat
0481 inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
0482                attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
0483   return mvwchgat(win, y, x, n, attr, color, opts); }
0484 #undef mvwchgat
0485 #define mvwchgat UNDEF(mvwchgat)
0486 #endif
0487 
0488 #ifdef mvwdelch
0489 inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
0490 { return mvwdelch(win, y, x); }
0491 #undef mvwdelch
0492 #define mvwdelch UNDEF(mvwdelch)
0493 #endif
0494 
0495 #ifdef mvwgetch
0496 inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
0497 #undef mvwgetch
0498 #define mvwgetch UNDEF(mvwgetch)
0499 #endif
0500 
0501 #ifdef mvwgetnstr
0502 inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
0503 {return mvwgetnstr(win, y, x, str, n);}
0504 #undef mvwgetnstr
0505 #define mvwgetnstr UNDEF(mvwgetnstr)
0506 #endif
0507 
0508 #ifdef mvwgetstr
0509 inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
0510 {return mvwgetstr(win, y, x, str);}
0511 #undef mvwgetstr
0512 #define mvwgetstr UNDEF(mvwgetstr)
0513 #endif
0514 
0515 #ifdef mvwhline
0516 inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
0517   return mvwhline(win, y, x, c, n); }
0518 #undef mvwhline
0519 #define mvwhline UNDEF(mvwhline)
0520 #endif
0521 
0522 #ifdef mvwinch
0523 inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
0524   return mvwinch(win, y, x);}
0525 #undef mvwinch
0526 #define mvwinch UNDEF(mvwinch)
0527 #endif
0528 
0529 #ifdef mvwinchnstr
0530 inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n)  { return mvwinchnstr(win, y, x, str, n); }
0531 #undef mvwinchnstr
0532 #define mvwinchnstr UNDEF(mvwinchnstr)
0533 #endif
0534 
0535 #ifdef mvwinchstr
0536 inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str)  { return mvwinchstr(win, y, x, str); }
0537 #undef mvwinchstr
0538 #define mvwinchstr UNDEF(mvwinchstr)
0539 #endif
0540 
0541 #ifdef mvwinnstr
0542 inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
0543   return mvwinnstr(win, y, x, _str, n); }
0544 #undef mvwinnstr
0545 #define mvwinnstr UNDEF(mvwinnstr)
0546 #endif
0547 
0548 #ifdef mvwinsch
0549 inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
0550 { return mvwinsch(win, y, x, c); }
0551 #undef mvwinsch
0552 #define mvwinsch UNDEF(mvwinsch)
0553 #endif
0554 
0555 #ifdef mvwinsnstr
0556 inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
0557   return mvwinsnstr(w, y, x, _str, n); }
0558 #undef mvwinsnstr
0559 #define mvwinsnstr UNDEF(mvwinsnstr)
0560 #endif
0561 
0562 #ifdef mvwinsstr
0563 inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x,  const char *_str)  {
0564   return mvwinsstr(w, y, x, _str); }
0565 #undef mvwinsstr
0566 #define mvwinsstr UNDEF(mvwinsstr)
0567 #endif
0568 
0569 #ifdef mvwvline
0570 inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
0571   return mvwvline(win, y, x, c, n); }
0572 #undef mvwvline
0573 #define mvwvline UNDEF(mvwvline)
0574 #endif
0575 
0576 #ifdef napms
0577 inline void UNDEF(napms)(unsigned long x) { napms(x); }
0578 #undef napms
0579 #define napms UNDEF(napms)
0580 #endif
0581 
0582 #ifdef nocrmode
0583 inline int UNDEF(nocrmode)(void) { return nocrmode(); }
0584 #undef nocrmode
0585 #define nocrmode UNDEF(nocrmode)
0586 #endif
0587 
0588 #ifdef nodelay
0589 inline void UNDEF(nodelay)() { nodelay(); }
0590 #undef nodelay
0591 #define nodelay UNDEF(nodelay)
0592 #endif
0593 
0594 #ifdef redrawwin
0595 inline int UNDEF(redrawwin)(WINDOW *win)  { return redrawwin(win); }
0596 #undef redrawwin
0597 #define redrawwin UNDEF(redrawwin)
0598 #endif
0599 
0600 #ifdef refresh
0601 inline int UNDEF(refresh)()  { return refresh(); }
0602 #undef refresh
0603 #define refresh UNDEF(refresh)
0604 #endif
0605 
0606 #ifdef resetterm
0607 inline int UNDEF(resetterm)(void) { return resetterm(); }
0608 #undef resetterm
0609 #define resetterm UNDEF(resetterm)
0610 #endif
0611 
0612 #ifdef saveterm
0613 inline int UNDEF(saveterm)(void) { return saveterm(); }
0614 #undef saveterm
0615 #define saveterm UNDEF(saveterm)
0616 #endif
0617 
0618 #ifdef scrl
0619 inline int UNDEF(scrl)(int l) { return scrl(l); }
0620 #undef scrl
0621 #define scrl UNDEF(scrl)
0622 #endif
0623 
0624 #ifdef scroll
0625 inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
0626 #undef scroll
0627 #define scroll UNDEF(scroll)
0628 #endif
0629 
0630 #ifdef scrollok
0631 inline int UNDEF(scrollok)(WINDOW* win, bool bf)  { return scrollok(win, bf); }
0632 #undef scrollok
0633 #define scrollok UNDEF(scrollok)
0634 #else
0635 #if defined(__NCURSES_H)
0636 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
0637 #else
0638 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
0639 #endif
0640 #endif
0641 
0642 #ifdef setscrreg
0643 inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
0644 #undef setscrreg
0645 #define setscrreg UNDEF(setscrreg)
0646 #endif
0647 
0648 #ifdef standend
0649 inline int UNDEF(standend)()  { return standend(); }
0650 #undef standend
0651 #define standend UNDEF(standend)
0652 #endif
0653 
0654 #ifdef standout
0655 inline int UNDEF(standout)()  { return standout(); }
0656 #undef standout
0657 #define standout UNDEF(standout)
0658 #endif
0659 
0660 #ifdef subpad
0661 inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
0662 { return derwin(p, l, c, y, x); }
0663 #undef subpad
0664 #define subpad UNDEF(subpad)
0665 #endif
0666 
0667 #ifdef timeout
0668 inline void UNDEF(timeout)(int delay) { timeout(delay); }
0669 #undef timeout
0670 #define timeout UNDEF(timeout)
0671 #endif
0672 
0673 #ifdef touchline
0674 inline int UNDEF(touchline)(WINDOW *win, int s, int c)
0675 { return touchline(win, s, c); }
0676 #undef touchline
0677 #define touchline UNDEF(touchline)
0678 #endif
0679 
0680 #ifdef touchwin
0681 inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
0682 #undef touchwin
0683 #define touchwin UNDEF(touchwin)
0684 #endif
0685 
0686 #ifdef untouchwin
0687 inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
0688 #undef untouchwin
0689 #define untouchwin UNDEF(untouchwin)
0690 #endif
0691 
0692 #ifdef vline
0693 inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
0694 #undef vline
0695 #define vline UNDEF(vline)
0696 #endif
0697 
0698 #ifdef waddchstr
0699 inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
0700 #undef waddchstr
0701 #define waddchstr UNDEF(waddchstr)
0702 #endif
0703 
0704 #ifdef waddstr
0705 inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
0706 #undef waddstr
0707 #define waddstr UNDEF(waddstr)
0708 #endif
0709 
0710 #ifdef wattroff
0711 inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
0712 #undef wattroff
0713 #define wattroff UNDEF(wattroff)
0714 #endif
0715 
0716 #ifdef wattrset
0717 inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
0718 #undef wattrset
0719 #define wattrset UNDEF(wattrset)
0720 #endif
0721 
0722 #ifdef winch
0723 inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
0724 #undef winch
0725 #define winch UNDEF(winch)
0726 #endif
0727 
0728 #ifdef winchnstr
0729 inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n)  { return winchnstr(win, str, n); }
0730 #undef winchnstr
0731 #define winchnstr UNDEF(winchnstr)
0732 #endif
0733 
0734 #ifdef winchstr
0735 inline int UNDEF(winchstr)(WINDOW *win, chtype *str)  { return winchstr(win, str); }
0736 #undef winchstr
0737 #define winchstr UNDEF(winchstr)
0738 #endif
0739 
0740 #ifdef winsstr
0741 inline int UNDEF(winsstr)(WINDOW *w, const char *_str)  {
0742   return winsstr(w, _str); }
0743 #undef winsstr
0744 #define winsstr UNDEF(winsstr)
0745 #endif
0746 
0747 #ifdef wstandend
0748 inline int UNDEF(wstandend)(WINDOW *win)  { return wstandend(win); }
0749 #undef wstandend
0750 #define wstandend UNDEF(wstandend)
0751 #endif
0752 
0753 #ifdef wstandout
0754 inline int UNDEF(wstandout)(WINDOW *win)  { return wstandout(win); }
0755 #undef wstandout
0756 #define wstandout UNDEF(wstandout)
0757 #endif
0758 
0759 /*
0760  *
0761  * C++ class for windows.
0762  *
0763  */
0764 
0765 extern "C" int     _nc_ripoffline(int, int (*init)(WINDOW*, int));
0766 extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
0767 extern "C" int     _nc_has_mouse(void);
0768 
0769 class NCURSES_CXX_IMPEXP NCursesWindow
0770 {
0771   friend class NCursesMenu;
0772   friend class NCursesForm;
0773 
0774 private:
0775   static bool    b_initialized;
0776   static void    initialize();
0777   void           constructing();
0778   friend int     _nc_xx_ripoff_init(WINDOW *, int);
0779 
0780   void           set_keyboard();
0781 
0782   NCURSES_COLOR_T getcolor(int getback) const;
0783   NCURSES_PAIRS_T getPair() const;
0784 
0785   static int     setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
0786   static int     colorInitialized;
0787 
0788   // This private constructor is only used during the initialization
0789   // of windows generated by ripoffline() calls.
0790   NCursesWindow(WINDOW* win, int ncols);
0791 
0792 protected:
0793   virtual void   err_handler(const char *) const THROWS(NCursesException);
0794   // Signal an error with the given message text.
0795 
0796   static long count;        // count of all active windows:
0797   //   We rely on the c++ promise that
0798   //   all otherwise uninitialized
0799   //   static class vars are set to 0
0800 
0801   WINDOW*        w;                // the curses WINDOW
0802 
0803   bool           alloced;          // TRUE if we own the WINDOW
0804 
0805   NCursesWindow* par;              // parent, if subwindow
0806   NCursesWindow* subwins;          // head of subwindows list
0807   NCursesWindow* sib;              // next subwindow of parent
0808 
0809   void           kill_subwindows(); // disable all subwindows
0810   // Destroy all subwindows.
0811 
0812   /* Only for use by derived classes. They are then in charge to
0813      fill the member variables correctly. */
0814   NCursesWindow();
0815 
0816 public:
0817   explicit NCursesWindow(WINDOW* window);   // useful only for stdscr
0818 
0819   NCursesWindow(int nlines,        // number of lines
0820         int ncols,         // number of columns
0821         int begin_y,       // line origin
0822         int begin_x);      // col origin
0823 
0824   NCursesWindow(NCursesWindow& par,// parent window
0825         int nlines,        // number of lines
0826         int ncols,         // number of columns
0827         int begin_y,       // absolute or relative
0828         int begin_x,       //   origins:
0829         char absrel = 'a');// if `a', begin_y & begin_x are
0830   // absolute screen pos, else if `r', they are relative to par origin
0831 
0832   NCursesWindow(NCursesWindow& par,// parent window
0833         bool do_box = TRUE);
0834   // this is the very common case that we want to create the subwindow that
0835   // is two lines and two columns smaller and begins at (1,1).
0836   // We may automatically request the box around it.
0837 
0838   NCursesWindow& operator=(const NCursesWindow& rhs)
0839   {
0840     if (this != &rhs)
0841       *this = rhs;
0842     return *this;
0843   }
0844 
0845   NCursesWindow(const NCursesWindow& rhs)
0846     : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
0847   {
0848   }
0849 
0850   virtual ~NCursesWindow() THROWS(NCursesException);
0851 
0852   NCursesWindow Clone();
0853   // Make an exact copy of the window.
0854 
0855   // Initialization.
0856   static void    useColors(void);
0857   // Call this routine very early if you want to have colors.
0858 
0859   static int ripoffline(int ripoff_lines,
0860             int (*init)(NCursesWindow& win));
0861   // This function is used to generate a window of ripped-of lines.
0862   // If the argument is positive, lines are removed from the top, if it
0863   // is negative lines are removed from the bottom. This enhances the
0864   // lowlevel ripoffline() function because it uses the internal
0865   // implementation that allows to remove more than just a single line.
0866   // This function must be called before any other ncurses function. The
0867   // creation of the window is deferred until ncurses gets initialized.
0868   // The initialization function is then called.
0869 
0870   // -------------------------------------------------------------------------
0871   // terminal status
0872   // -------------------------------------------------------------------------
0873   int            lines() const { initialize(); return LINES; }
0874   // Number of lines on terminal, *not* window
0875 
0876   int            cols() const { initialize(); return COLS; }
0877   // Number of cols  on terminal, *not* window
0878 
0879   int            tabsize() const { initialize(); return TABSIZE; }
0880   // Size of a tab on terminal, *not* window
0881 
0882   static int     NumberOfColors();
0883   // Number of available colors
0884 
0885   int            colors() const { return NumberOfColors(); }
0886   // Number of available colors
0887 
0888   // -------------------------------------------------------------------------
0889   // window status
0890   // -------------------------------------------------------------------------
0891   int            height() const { return maxy() + 1; }
0892   // Number of lines in this window
0893 
0894   int            width() const { return maxx() + 1; }
0895   // Number of columns in this window
0896 
0897   int            begx() const { return getbegx(w); }
0898   // Column of top left corner relative to stdscr
0899 
0900   int            begy() const { return getbegy(w); }
0901   // Line of top left corner relative to stdscr
0902 
0903   int            curx() const { return getcurx(w); }
0904   // Column of top left corner relative to stdscr
0905 
0906   int            cury() const { return getcury(w); }
0907   // Line of top left corner relative to stdscr
0908 
0909   int            maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
0910   // Largest x coord in window
0911 
0912   int            maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
0913   // Largest y coord in window
0914 
0915   NCURSES_PAIRS_T getcolor() const;
0916   // Actual color pair
0917 
0918   NCURSES_COLOR_T foreground() const { return getcolor(0); }
0919   // Actual foreground color
0920 
0921   NCURSES_COLOR_T background() const { return getcolor(1); }
0922   // Actual background color
0923 
0924   int            setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
0925   // Set color palette entry
0926 
0927   int            setcolor(NCURSES_PAIRS_T pair);
0928   // Set actually used palette entry
0929 
0930   // -------------------------------------------------------------------------
0931   // window positioning
0932   // -------------------------------------------------------------------------
0933   virtual int    mvwin(int begin_y, int begin_x) {
0934     return ::mvwin(w, begin_y, begin_x); }
0935   // Move window to new position with the new position as top left corner.
0936   // This is virtual because it is redefined in NCursesPanel.
0937 
0938   // -------------------------------------------------------------------------
0939   // coordinate positioning
0940   // -------------------------------------------------------------------------
0941   int            move(int y, int x) { return ::wmove(w, y, x); }
0942   // Move cursor the this position
0943 
0944   void           getyx(int& y, int& x) const { ::getyx(w, y, x); }
0945   // Get current position of the cursor
0946 
0947   void           getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
0948   // Get beginning of the window
0949 
0950   void           getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
0951   // Get size of the window
0952 
0953   void           getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
0954   // Get parent's beginning of the window
0955 
0956   int            mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
0957     return ::mvcur(oldrow, oldcol, newrow, newcol); }
0958   // Perform lowlevel cursor motion that takes effect immediately.
0959 
0960   // -------------------------------------------------------------------------
0961   // input
0962   // -------------------------------------------------------------------------
0963   int            getch() { return ::wgetch(w); }
0964   // Get a keystroke from the window.
0965 
0966   int            getch(int y, int x) { return ::mvwgetch(w, y, x); }
0967   // Move cursor to position and get a keystroke from the window
0968 
0969   int            getstr(char* str, int n=-1) {
0970     return ::wgetnstr(w, str, n); }
0971   // Read a series of characters into str until a newline or carriage return
0972   // is received. Read at most n characters. If n is negative, the limit is
0973   // ignored.
0974 
0975   int            getstr(int y, int x, char* str, int n=-1) {
0976     return ::mvwgetnstr(w, y, x, str, n); }
0977   // Move the cursor to the requested position and then perform the getstr()
0978   // as described above.
0979 
0980   int            instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
0981   // Get a string of characters from the window into the buffer s. Retrieve
0982   // at most n characters, if n is negative retrieve all characters up to the
0983   // end of the current line. Attributes are stripped from the characters.
0984 
0985   int            instr(int y, int x, char *s, int n=-1) {
0986     return ::mvwinnstr(w, y, x, s, n); }
0987   // Move the cursor to the requested position and then perform the instr()
0988   // as described above.
0989 
0990   int            scanw(const char* fmt, ...)
0991     // Perform a scanw function from the window.
0992 #if __GNUG__ >= 2
0993     __attribute__ ((format (scanf, 2, 3)));
0994 #else
0995   ;
0996 #endif
0997 
0998   int            scanw(const char*, va_list);
0999     // Perform a scanw function from the window.
1000 
1001   int            scanw(int y, int x, const char* fmt, ...)
1002     // Move the cursor to the requested position and then perform a scanw
1003     // from the window.
1004 #if __GNUG__ >= 2
1005     __attribute__ ((format (scanf, 4, 5)));
1006 #else
1007   ;
1008 #endif
1009 
1010   int            scanw(int y, int x, const char* fmt, va_list);
1011     // Move the cursor to the requested position and then perform a scanw
1012     // from the window.
1013 
1014   // -------------------------------------------------------------------------
1015   // output
1016   // -------------------------------------------------------------------------
1017   int            addch(const chtype ch) { return ::waddch(w, ch); }
1018   // Put attributed character to the window.
1019 
1020   int            addch(int y, int x, const chtype ch) {
1021     return ::mvwaddch(w, y, x, ch); }
1022   // Move cursor to the requested position and then put attributed character
1023   // to the window.
1024 
1025   int            echochar(const chtype ch) { return ::wechochar(w, ch); }
1026   // Put attributed character to the window and refresh it immediately.
1027 
1028   int            addstr(const char* str, int n=-1) {
1029     return ::waddnstr(w, str, n); }
1030   // Write the string str to the window, stop writing if the terminating
1031   // NUL or the limit n is reached. If n is negative, it is ignored.
1032 
1033   int            addstr(int y, int x, const char * str, int n=-1) {
1034     return ::mvwaddnstr(w, y, x, str, n); }
1035   // Move the cursor to the requested position and then perform the addchstr
1036   // as described above.
1037 
1038   int            addchstr(const chtype* str, int n=-1) {
1039     return ::waddchnstr(w, str, n); }
1040   // Write the string str to the window, stop writing if the terminating
1041   // NUL or the limit n is reached. If n is negative, it is ignored.
1042 
1043   int            addchstr(int y, int x, const chtype * str, int n=-1) {
1044     return ::mvwaddchnstr(w, y, x, str, n); }
1045   // Move the cursor to the requested position and then perform the addchstr
1046   // as described above.
1047 
1048   int            printw(const char* fmt, ...)
1049     // Do a formatted print to the window.
1050 #if (__GNUG__ >= 2) && !defined(printf)
1051     __attribute__ ((format (printf, 2, 3)));
1052 #else
1053   ;
1054 #endif
1055 
1056   int            printw(int y, int x, const char * fmt, ...)
1057     // Move the cursor and then do a formatted print to the window.
1058 #if (__GNUG__ >= 2) && !defined(printf)
1059     __attribute__ ((format (printf, 4, 5)));
1060 #else
1061   ;
1062 #endif
1063 
1064   int            printw(const char* fmt, va_list args);
1065     // Do a formatted print to the window.
1066 
1067   int            printw(int y, int x, const char * fmt, va_list args);
1068     // Move the cursor and then do a formatted print to the window.
1069 
1070   chtype         inch() const { return ::winch(w); }
1071   // Retrieve attributed character under the current cursor position.
1072 
1073   chtype         inch(int y, int x) { return ::mvwinch(w, y, x); }
1074   // Move cursor to requested position and then retrieve attributed character
1075   // at this position.
1076 
1077   int            inchstr(chtype* str, int n=-1) {
1078     return ::winchnstr(w, str, n); }
1079   // Read the string str from the window, stop reading if the terminating
1080   // NUL or the limit n is reached. If n is negative, it is ignored.
1081 
1082   int            inchstr(int y, int x, chtype * str, int n=-1) {
1083     return ::mvwinchnstr(w, y, x, str, n); }
1084   // Move the cursor to the requested position and then perform the inchstr
1085   // as described above.
1086 
1087   int            insch(chtype ch) { return ::winsch(w, ch); }
1088   // Insert attributed character into the window before current cursor
1089   // position.
1090 
1091   int            insch(int y, int x, chtype ch) {
1092     return ::mvwinsch(w, y, x, ch); }
1093   // Move cursor to requested position and then insert the attributed
1094   // character before that position.
1095 
1096   int            insertln() { return ::winsdelln(w, 1); }
1097   // Insert an empty line above the current line.
1098 
1099   int            insdelln(int n=1) { return ::winsdelln(w, n); }
1100   // If n>0 insert that many lines above the current line. If n<0 delete
1101   // that many lines beginning with the current line.
1102 
1103   int            insstr(const char *s, int n=-1) {
1104     return ::winsnstr(w, s, n); }
1105   // Insert the string into the window before the current cursor position.
1106   // Insert stops at end of string or when the limit n is reached. If n is
1107   // negative, it is ignored.
1108 
1109   int            insstr(int y, int x, const char *s, int n=-1) {
1110     return ::mvwinsnstr(w, y, x, s, n); }
1111   // Move the cursor to the requested position and then perform the insstr()
1112   // as described above.
1113 
1114   int            attron (chtype at) { return ::wattron (w, at); }
1115   // Switch on the window attributes;
1116 
1117   int            attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
1118   // Switch off the window attributes;
1119 
1120   int            attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
1121   // Set the window attributes;
1122 
1123   chtype         attrget() { return ::getattrs(w); }
1124   // Get the window attributes;
1125 
1126   int            color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
1127     return ::wcolor_set(w, color_pair_number, opts); }
1128   // Set the window color attribute;
1129 
1130   int            chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
1131     return ::wchgat(w, n, attr, color, opts); }
1132   // Change the attributes of the next n characters in the current line. If
1133   // n is negative or greater than the number of remaining characters in the
1134   // line, the attributes will be changed up to the end of the line.
1135 
1136   int            chgat(int y, int x,
1137                int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
1138     return ::mvwchgat(w, y, x, n, attr, color, opts); }
1139   // Move the cursor to the requested position and then perform chgat() as
1140   // described above.
1141 
1142   // -------------------------------------------------------------------------
1143   // background
1144   // -------------------------------------------------------------------------
1145   chtype         getbkgd() const { return ::getbkgd(w); }
1146   // Get current background setting.
1147 
1148   int            bkgd(const chtype ch) { return ::wbkgd(w, ch); }
1149   // Set the background property and apply it to the window.
1150 
1151   void           bkgdset(chtype ch) { ::wbkgdset(w, ch); }
1152   // Set the background property.
1153 
1154   // -------------------------------------------------------------------------
1155   // borders
1156   // -------------------------------------------------------------------------
1157   int            box(chtype vert=0, chtype  hor=0) {
1158     return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
1159   // Draw a box around the window with the given vertical and horizontal
1160   // drawing characters. If you specify a zero as character, curses will try
1161   // to find a "nice" character.
1162 
1163   int            border(chtype left=0, chtype right=0,
1164             chtype top =0, chtype bottom=0,
1165             chtype top_left =0, chtype top_right=0,
1166             chtype bottom_left =0, chtype bottom_right=0) {
1167     return ::wborder(w, left, right, top, bottom, top_left, top_right,
1168              bottom_left, bottom_right); }
1169   // Draw a border around the window with the given characters for the
1170   // various parts of the border. If you pass zero for a character, curses
1171   // will try to find "nice" characters.
1172 
1173   // -------------------------------------------------------------------------
1174   // lines and boxes
1175   // -------------------------------------------------------------------------
1176   int            hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
1177   // Draw a horizontal line of len characters with the given character. If
1178   // you pass zero for the character, curses will try to find a "nice" one.
1179 
1180   int            hline(int y, int x, int len, chtype ch=0) {
1181     return ::mvwhline(w, y, x, ch, len); }
1182   // Move the cursor to the requested position and then draw a horizontal line.
1183 
1184   int            vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
1185   // Draw a vertical line of len characters with the given character. If
1186   // you pass zero for the character, curses will try to find a "nice" one.
1187 
1188   int            vline(int y, int x, int len, chtype ch=0) {
1189     return ::mvwvline(w, y, x, ch, len); }
1190   // Move the cursor to the requested position and then draw a vertical line.
1191 
1192   // -------------------------------------------------------------------------
1193   // erasure
1194   // -------------------------------------------------------------------------
1195   int            erase() { return ::werase(w); }
1196   // Erase the window.
1197 
1198   int            clear() { return ::wclear(w); }
1199   // Clear the window.
1200 
1201   int            clearok(bool bf) { return ::clearok(w, bf); }
1202   // Set/Reset the clear flag. If set, the next refresh() will clear the
1203   // screen.
1204 
1205   int            clrtobot() { return ::wclrtobot(w); }
1206   // Clear to the end of the window.
1207 
1208   int            clrtoeol() { return ::wclrtoeol(w); }
1209   // Clear to the end of the line.
1210 
1211   int            delch() { return ::wdelch(w); }
1212   // Delete character under the cursor.
1213 
1214   int            delch(int y, int x) { return ::mvwdelch(w, y, x); }
1215   // Move cursor to requested position and delete the character under the
1216   // cursor.
1217 
1218   int            deleteln() { return ::winsdelln(w, -1); }
1219   // Delete the current line.
1220 
1221   // -------------------------------------------------------------------------
1222   // screen control
1223   // -------------------------------------------------------------------------
1224   int            scroll(int amount=1) { return ::wscrl(w, amount); }
1225   // Scroll amount lines. If amount is positive, scroll up, otherwise
1226   // scroll down.
1227 
1228   int            scrollok(bool bf) { return ::scrollok(w, bf); }
1229   // If bf is TRUE, window scrolls if cursor is moved off the bottom
1230   // edge of the window or a scrolling region, otherwise the cursor is left
1231   // at the bottom line.
1232 
1233   int            setscrreg(int from, int to) {
1234     return ::wsetscrreg(w, from, to); }
1235   // Define a soft scrolling region.
1236 
1237   int            idlok(bool bf) { return ::idlok(w, bf); }
1238   // If bf is TRUE, use insert/delete line hardware support if possible.
1239   // Otherwise do it in software.
1240 
1241   void           idcok(bool bf) { ::idcok(w, bf); }
1242   // If bf is TRUE, use insert/delete character hardware support if possible.
1243   // Otherwise do it in software.
1244 
1245   int            touchline(int s, int c) { return ::touchline(w, s, c); }
1246   // Mark the given lines as modified.
1247 
1248   int            touchwin()   { return ::wtouchln(w, 0, height(), 1); }
1249   // Mark the whole window as modified.
1250 
1251   int            untouchwin() { return ::wtouchln(w, 0, height(), 0); }
1252   // Mark the whole window as unmodified.
1253 
1254   int            touchln(int s, int cnt, bool changed=TRUE) {
1255     return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
1256   // Mark cnt lines beginning from line s as changed or unchanged, depending
1257   // on the value of the changed flag.
1258 
1259   bool           is_linetouched(int line) const {
1260     return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
1261   // Return TRUE if line is marked as changed, FALSE otherwise
1262 
1263   bool           is_wintouched() const {
1264     return (::is_wintouched(w) ? TRUE:FALSE); }
1265   // Return TRUE if window is marked as changed, FALSE otherwise
1266 
1267   int            leaveok(bool bf) { return ::leaveok(w, bf); }
1268   // If bf is TRUE, curses will leave the cursor after an update wherever
1269   // it is after the update.
1270 
1271   int            redrawln(int from, int n) { return ::wredrawln(w, from, n); }
1272   // Redraw n lines starting from the requested line
1273 
1274   int            redrawwin() { return ::wredrawln(w, 0, height()); }
1275   // Redraw the whole window
1276 
1277   int            doupdate()  { return ::doupdate(); }
1278   // Do all outputs to make the physical screen looking like the virtual one
1279 
1280   void           syncdown()  { ::wsyncdown(w); }
1281   // Propagate the changes down to all descendant windows
1282 
1283   void           syncup()    { ::wsyncup(w); }
1284   // Propagate the changes up in the hierarchy
1285 
1286   void           cursyncup() { ::wcursyncup(w); }
1287   // Position the cursor in all ancestor windows corresponding to our setting
1288 
1289   int            syncok(bool bf) { return ::syncok(w, bf); }
1290   // If called with bf=TRUE, syncup() is called whenever the window is changed
1291 
1292 #ifndef _no_flushok
1293   int            flushok(bool bf) { return ::flushok(w, bf); }
1294 #endif
1295 
1296   void           immedok(bool bf) { ::immedok(w, bf); }
1297   // If called with bf=TRUE, any change in the window will cause an
1298   // automatic immediate refresh()
1299 
1300   int            intrflush(bool bf) { return ::intrflush(w, bf); }
1301 
1302   int            keypad(bool bf) { return ::keypad(w, bf); }
1303   // If called with bf=TRUE, the application will interpret function keys.
1304 
1305   int            nodelay(bool bf) { return ::nodelay(w, bf); }
1306 
1307   int            meta(bool bf) { return ::meta(w, bf); }
1308   // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
1309   // 7-Bit characters are generated.
1310 
1311   int            standout() { return ::wstandout(w); }
1312   // Enable "standout" attributes
1313 
1314   int            standend() { return ::wstandend(w); }
1315   // Disable "standout" attributes
1316 
1317   // -------------------------------------------------------------------------
1318   // The next two are virtual, because we redefine them in the
1319   // NCursesPanel class.
1320   // -------------------------------------------------------------------------
1321   virtual int    refresh() { return ::wrefresh(w); }
1322   // Propagate the changes in this window to the virtual screen and call
1323   // doupdate(). This is redefined in NCursesPanel.
1324 
1325   virtual int    noutrefresh() { return ::wnoutrefresh(w); }
1326   // Propagate the changes in this window to the virtual screen. This is
1327   // redefined in NCursesPanel.
1328 
1329   // -------------------------------------------------------------------------
1330   // multiple window control
1331   // -------------------------------------------------------------------------
1332   int            overlay(NCursesWindow& win) {
1333     return ::overlay(w, win.w); }
1334   // Overlay this window over win.
1335 
1336   int            overwrite(NCursesWindow& win) {
1337     return ::overwrite(w, win.w); }
1338   // Overwrite win with this window.
1339 
1340   int            copywin(NCursesWindow& win,
1341              int sminrow, int smincol,
1342              int dminrow, int dmincol,
1343              int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
1344     return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
1345              dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
1346   // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
1347   // dmaxrow,dmaxcol with the rectangle in this window beginning at
1348   // sminrow,smincol.
1349 
1350   // -------------------------------------------------------------------------
1351   // Extended functions
1352   // -------------------------------------------------------------------------
1353 #if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
1354   int            wresize(int newLines, int newColumns) {
1355     return ::wresize(w, newLines, newColumns); }
1356 #endif
1357 
1358   // -------------------------------------------------------------------------
1359   // Mouse related
1360   // -------------------------------------------------------------------------
1361   bool has_mouse() const;
1362   // Return TRUE if terminal supports a mouse, FALSE otherwise
1363 
1364   // -------------------------------------------------------------------------
1365   // traversal support
1366   // -------------------------------------------------------------------------
1367   NCursesWindow*  child() { return subwins; }
1368   // Get the first child window.
1369 
1370   NCursesWindow*  sibling() { return sib; }
1371   // Get the next child of my parent.
1372 
1373   NCursesWindow*  parent() { return par; }
1374   // Get my parent.
1375 
1376   bool isDescendant(NCursesWindow& win);
1377   // Return TRUE if win is a descendant of this.
1378 };
1379 
1380 // -------------------------------------------------------------------------
1381 // We leave this here for compatibility reasons.
1382 // -------------------------------------------------------------------------
1383 class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow
1384 {
1385 public:
1386   explicit NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
1387     : NCursesWindow(window) {
1388       useColors(); }
1389 
1390   NCursesColorWindow(int nlines,        // number of lines
1391              int ncols,         // number of columns
1392              int begin_y,       // line origin
1393              int begin_x)       // col origin
1394     : NCursesWindow(nlines, ncols, begin_y, begin_x) {
1395       useColors(); }
1396 
1397   NCursesColorWindow(NCursesWindow& parentWin,// parent window
1398              int nlines,        // number of lines
1399              int ncols,         // number of columns
1400              int begin_y,       // absolute or relative
1401              int begin_x,       //   origins:
1402              char absrel = 'a') // if `a', by & bx are
1403     : NCursesWindow(parentWin,
1404             nlines, ncols,  // absolute screen pos,
1405             begin_y, begin_x,   // else if `r', they are
1406             absrel ) {          // relative to par origin
1407       useColors(); }
1408 };
1409 
1410 // These enum definitions really belong inside the NCursesPad class, but only
1411 // recent compilers support that feature.
1412 
1413   typedef enum {
1414     REQ_PAD_REFRESH = KEY_MAX + 1,
1415     REQ_PAD_UP,
1416     REQ_PAD_DOWN,
1417     REQ_PAD_LEFT,
1418     REQ_PAD_RIGHT,
1419     REQ_PAD_EXIT
1420   } Pad_Request;
1421 
1422   const Pad_Request PAD_LOW  = REQ_PAD_REFRESH;   // lowest  op-code
1423   const Pad_Request PAD_HIGH = REQ_PAD_EXIT;      // highest op-code
1424 
1425 // -------------------------------------------------------------------------
1426 // Pad Support. We allow an association of a pad with a "real" window
1427 // through which the pad may be viewed.
1428 // -------------------------------------------------------------------------
1429 class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow
1430 {
1431 private:
1432   NCursesWindow* viewWin;       // the "viewport" window
1433   NCursesWindow* viewSub;       // the "viewport" subwindow
1434 
1435   int h_gridsize, v_gridsize;
1436 
1437 protected:
1438   int min_row, min_col;         // top left row/col of the pads display area
1439 
1440   NCursesWindow* Win(void) const {
1441     // Get the window into which the pad should be copied (if any)
1442     return (viewSub?viewSub:(viewWin?viewWin:NULL));
1443   }
1444 
1445   NCursesWindow* getWindow(void) const {
1446     return viewWin;
1447   }
1448 
1449   NCursesWindow* getSubWindow(void) const {
1450     return viewSub;
1451   }
1452 
1453   virtual int driver (int key);      // Virtualize keystroke key
1454   // The driver translates the keystroke c into an Pad_Request
1455 
1456   virtual void OnUnknownOperation(int pad_req) {
1457     (void) pad_req;
1458     ::beep();
1459   }
1460   // This is called if the driver returns an unknown op-code
1461 
1462   virtual void OnNavigationError(int pad_req) {
1463     (void) pad_req;
1464     ::beep();
1465   }
1466   // This is called if a navigation request couldn't be satisfied
1467 
1468   virtual void OnOperation(int pad_req) {
1469     (void) pad_req;
1470   };
1471   // OnOperation is called if a Pad_Operation was executed and just before
1472   // the refresh() operation is done.
1473 
1474 public:
1475   NCursesPad(int nlines, int ncols);
1476   // create a pad with the given size
1477 
1478   NCursesPad& operator=(const NCursesPad& rhs)
1479   {
1480     if (this != &rhs) {
1481       *this = rhs;
1482       NCursesWindow::operator=(rhs);
1483     }
1484     return *this;
1485   }
1486 
1487   NCursesPad(const NCursesPad& rhs)
1488     : NCursesWindow(rhs),
1489       viewWin(rhs.viewWin),
1490       viewSub(rhs.viewSub),
1491       h_gridsize(rhs.h_gridsize),
1492       v_gridsize(rhs.v_gridsize),
1493       min_row(rhs.min_row),
1494       min_col(rhs.min_col)
1495   {
1496   }
1497 
1498   virtual ~NCursesPad() THROWS(NCursesException) {}
1499 
1500   int echochar(const chtype ch) { return ::pechochar(w, ch); }
1501   // Put the attributed character onto the pad and immediately do a
1502   // prefresh().
1503 
1504   int refresh() NCURSES_OVERRIDE;
1505   // If a viewport is defined the pad is displayed in this window, otherwise
1506   // this is a noop.
1507 
1508   int refresh(int pminrow, int pmincol,
1509           int sminrow, int smincol,
1510           int smaxrow, int smaxcol) {
1511     return ::prefresh(w, pminrow, pmincol,
1512               sminrow, smincol, smaxrow, smaxcol);
1513   }
1514   // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
1515   // on the screen. <b>refresh</b> copies a rectangle of this size beginning
1516   // with top left corner pminrow,pmincol onto the screen and calls doupdate().
1517 
1518   int noutrefresh() NCURSES_OVERRIDE;
1519   // If a viewport is defined the pad is displayed in this window, otherwise
1520   // this is a noop.
1521 
1522   int noutrefresh(int pminrow, int pmincol,
1523           int sminrow, int smincol,
1524           int smaxrow, int smaxcol) {
1525     return ::pnoutrefresh(w, pminrow, pmincol,
1526               sminrow, smincol, smaxrow, smaxcol);
1527   }
1528   // Does the same as refresh() but without calling doupdate().
1529 
1530   virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
1531   // Add the window "view" as viewing window to the pad.
1532 
1533   virtual void setSubWindow(NCursesWindow& sub);
1534   // Use the subwindow "sub" of the viewport window for the actual viewing.
1535   // The full viewport window is usually used to provide some decorations
1536   // like frames, titles etc.
1537 
1538   virtual void operator() (void);
1539   // Perform Pad's operation
1540 };
1541 
1542 // A FramedPad is constructed always with a viewport window. This viewport
1543 // will be framed (by a box() command) and the interior of the box is the
1544 // viewport subwindow. On the frame we display scrollbar sliders.
1545 class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad
1546 {
1547 protected:
1548   virtual void OnOperation(int pad_req) NCURSES_OVERRIDE;
1549 
1550 public:
1551   NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
1552            int v_grid = 1, int h_grid = 1)
1553     : NCursesPad(nlines, ncols) {
1554     NCursesPad::setWindow(win, v_grid, h_grid);
1555     NCursesPad::setSubWindow(*(new NCursesWindow(win)));
1556   }
1557   // Construct the FramedPad with the given Window win as viewport.
1558 
1559   virtual ~NCursesFramedPad() THROWS(NCursesException) {
1560     delete getSubWindow();
1561   }
1562 
1563   void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE {
1564     (void) view;
1565     (void) v_grid;
1566     (void) h_grid;
1567     err_handler("Operation not allowed");
1568   }
1569   // Disable this call; the viewport is already defined
1570 
1571   void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE {
1572     (void) sub;
1573     err_handler("Operation not allowed");
1574   }
1575   // Disable this call; the viewport subwindow is already defined
1576 
1577 };
1578 
1579 #endif /* NCURSES_CURSESW_H_incl */