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