1 /* $OpenBSD: curses.priv.h,v 1.36 2023/10/17 09:52:08 nicm Exp $ */ 2 3 /**************************************************************************** 4 * Copyright 2018-2022,2023 Thomas E. Dickey * 5 * Copyright 1998-2017,2018 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 /**************************************************************************** 33 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 34 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 35 * and: Thomas E. Dickey 1996-on * 36 * and: Juergen Pfeifer * 37 ****************************************************************************/ 38 39 /* 40 * $Id: curses.priv.h,v 1.36 2023/10/17 09:52:08 nicm Exp $ 41 * 42 * curses.priv.h 43 * 44 * Header file for curses library objects which are private to 45 * the library. 46 * 47 */ 48 49 #ifndef CURSES_PRIV_H 50 #define CURSES_PRIV_H 1 51 /* *INDENT-OFF* */ 52 53 #include <ncurses_dll.h> 54 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 #include <ncurses_cfg.h> 60 61 #if USE_RCS_IDS 62 #define MODULE_ID(id) static const char Ident[] = id; 63 #else 64 #define MODULE_ID(id) /*nothing*/ 65 #endif 66 67 #include <stddef.h> /* for offsetof */ 68 #include <stdlib.h> 69 #include <string.h> 70 #include <sys/types.h> 71 #include <sys/stat.h> 72 73 #if HAVE_UNISTD_H 74 #include <unistd.h> 75 #endif 76 77 #if HAVE_LIMITS_H 78 # include <limits.h> 79 #elif HAVE_SYS_PARAM_H 80 # include <sys/param.h> 81 #endif 82 83 #include <assert.h> 84 #include <stdio.h> 85 86 #include <errno.h> 87 88 #if defined __hpux 89 # ifndef EILSEQ 90 # define EILSEQ 47 91 # endif 92 #endif 93 94 #ifndef PATH_MAX 95 # if defined(_POSIX_PATH_MAX) 96 # define PATH_MAX _POSIX_PATH_MAX 97 # elif defined(MAXPATHLEN) 98 # define PATH_MAX MAXPATHLEN 99 # else 100 # define PATH_MAX 255 /* the Posix minimum path-size */ 101 # endif 102 #endif 103 104 #if DECL_ERRNO 105 extern int errno; 106 #endif 107 108 /* Some Windows related defines */ 109 #undef _NC_WINDOWS 110 #if (defined(_WIN32) || defined(_WIN64)) 111 #define _NC_WINDOWS 112 #else 113 #undef EXP_WIN32_DRIVER 114 #endif 115 116 #undef _NC_MINGW 117 #if (defined(__MINGW32__) || defined(__MINGW64__)) 118 #define _NC_MINGW 119 #endif 120 121 #undef _NC_MSC 122 #ifdef _MSC_VER 123 #define _NC_MSC 124 #endif 125 126 /* Some systems have a broken 'select()', but workable 'poll()'. Use that */ 127 #if HAVE_WORKING_POLL 128 #define USE_FUNC_POLL 1 129 #if HAVE_POLL_H 130 #include <poll.h> 131 #else 132 #include <sys/poll.h> 133 #endif 134 #else 135 #define USE_FUNC_POLL 0 136 #endif 137 138 #if HAVE_INTTYPES_H 139 # include <inttypes.h> 140 #else 141 # if HAVE_STDINT_H 142 # include <stdint.h> 143 # endif 144 #endif 145 146 #if (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0) && (defined(__GNUC__) && (__GNUC__ < 12)) 147 # undef PRIxPTR /* gcc bug fixed in 12.x */ 148 # define PRIxPTR "lX" 149 # define CASTxPTR(n) (unsigned long)(intptr_t)(void*)(n) 150 #else 151 # define CASTxPTR(n) (intptr_t)(void*)(n) 152 #endif 153 154 #ifndef PRIxPTR 155 # define PRIxPTR "lx" 156 # define CASTxPTR(n) (long)(void*)(n) 157 #endif 158 159 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */ 160 #include <signal.h> 161 162 /* Alessandro Rubini's GPM (general-purpose mouse) */ 163 #if HAVE_LIBGPM && HAVE_GPM_H 164 #define USE_GPM_SUPPORT 1 165 #else 166 #define USE_GPM_SUPPORT 0 167 #endif 168 169 /* QNX mouse support */ 170 #if defined(__QNX__) && !defined(__QNXNTO__) 171 #define USE_QNX_MOUSE 1 172 #else 173 #define USE_QNX_MOUSE 0 174 #endif 175 176 /* EMX mouse support */ 177 #ifdef __EMX__ 178 #define USE_EMX_MOUSE 1 179 #else 180 #define USE_EMX_MOUSE 0 181 #endif 182 183 /* kLIBC keyboard/mouse support */ 184 #if defined(__OS2__) && defined(__KLIBC__) 185 #define USE_KLIBC_KBD 1 186 #define USE_KLIBC_MOUSE 1 187 #else 188 #define USE_KLIBC_KBD 0 189 #define USE_KLIBC_MOUSE 0 190 #endif 191 192 #define DEFAULT_MAXCLICK 166 193 #define EV_MAX 8 /* size of mouse circular event queue */ 194 195 /* 196 * If we don't have signals to support it, don't add a sigwinch handler. 197 * In any case, resizing is an extended feature. Use it if we've got it. 198 */ 199 #if !NCURSES_EXT_FUNCS 200 #undef HAVE_SIZECHANGE 201 #define HAVE_SIZECHANGE 0 202 #endif 203 204 #if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH) 205 #define USE_SIZECHANGE 1 206 #else 207 #define USE_SIZECHANGE 0 208 #undef USE_SIGWINCH 209 #define USE_SIGWINCH 0 210 #endif 211 212 /* 213 * When building in the MSYS2 environment, the automatic discovery of 214 * the path separator in configure doesn't work properly. So, if building 215 * for MinGW, we enforce the correct Windows PATH separator 216 */ 217 #if defined(_NC_WINDOWS) 218 # ifdef NCURSES_PATHSEP 219 # undef NCURSES_PATHSEP 220 # endif 221 # define NCURSES_PATHSEP ';' 222 #endif 223 224 /* 225 * When the standard handles have been redirected (such as inside a text editor 226 * or the less utility), keystrokes must be read from the console rather than 227 * the redirected handle. The standard output handle suffers from a similar 228 * problem. Both handles are not closed once opened. The console shall be 229 * considered reachable throughout the process. 230 */ 231 #if defined(_NC_WINDOWS) 232 #define GetDirectHandle(fileName, shareMode) \ 233 CreateFile(TEXT(fileName), \ 234 GENERIC_READ | GENERIC_WRITE, \ 235 shareMode, \ 236 0, \ 237 OPEN_EXISTING, \ 238 0, \ 239 0) 240 #endif 241 242 /* 243 * Not all platforms have memmove; some have an equivalent bcopy. (Some may 244 * have neither). 245 */ 246 #if USE_OK_BCOPY 247 #define memmove(d,s,n) bcopy(s,d,n) 248 #elif USE_MY_MEMMOVE 249 #define memmove(d,s,n) _nc_memmove(d,s,n) 250 extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); 251 #endif 252 253 /* 254 * If we have va_copy(), use it for assigning va_list's. 255 */ 256 #if defined(HAVE___VA_COPY) 257 #define begin_va_copy(dst,src) __va_copy(dst, src) 258 #define end_va_copy(dst) va_end(dst) 259 #elif defined(va_copy) || defined(HAVE_VA_COPY) 260 #define begin_va_copy(dst,src) va_copy(dst, src) 261 #define end_va_copy(dst) va_end(dst) 262 #else 263 #define begin_va_copy(dst,src) (dst) = (src) 264 #define end_va_copy(dst) /* nothing */ 265 #endif 266 267 /* 268 * Either/both S_ISxxx and/or S_IFxxx are defined in sys/types.h; some systems 269 * lack one or the other. 270 */ 271 #ifndef S_ISDIR 272 #define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR) 273 #endif 274 275 #ifndef S_ISREG 276 #define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) 277 #endif 278 279 /* 280 * POSIX ignores the "b", which c89 specified. Some very old systems do not 281 * accept it. 282 */ 283 #if USE_FOPEN_BIN_R 284 #define BIN_R "rb" 285 #define BIN_W "wb" 286 #else 287 #define BIN_R "r" 288 #define BIN_W "w" 289 #endif 290 291 /* 292 * Scroll hints are useless when hashmap is used 293 */ 294 #if !USE_SCROLL_HINTS 295 #if !USE_HASHMAP 296 #define USE_SCROLL_HINTS 1 297 #else 298 #define USE_SCROLL_HINTS 0 299 #endif 300 #endif 301 302 #if USE_SCROLL_HINTS 303 #define if_USE_SCROLL_HINTS(stmt) stmt 304 #else 305 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/ 306 #endif 307 308 #include <nc_string.h> 309 310 /* 311 * Options for terminal drivers, etc... 312 */ 313 #ifdef USE_TERM_DRIVER 314 #define NO_TERMINAL "unknown" 315 #define USE_SP_RIPOFF 1 316 #define USE_SP_TERMTYPE 1 317 #define USE_SP_WINDOWLIST 1 318 #else 319 #define NO_TERMINAL 0 320 #endif 321 322 #define VALID_TERM_ENV(term_env, no_terminal) \ 323 (term_env = (NonEmpty(term_env) \ 324 ? term_env \ 325 : no_terminal), \ 326 NonEmpty(term_env)) 327 328 /* 329 * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only 330 * when we're throwing control codes at the screen at high volume. To see 331 * this, re-enable USE_HARD_TABS and run worm for a while. Other systems 332 * probably don't want to define this either due to uncertainties about tab 333 * delays and expansion in raw mode. 334 */ 335 336 #define TRIES struct tries 337 typedef TRIES { 338 TRIES *child; /* ptr to child. NULL if none */ 339 TRIES *sibling; /* ptr to sibling. NULL if none */ 340 unsigned char ch; /* character at this node */ 341 unsigned short value; /* code of string so far. 0 if none. */ 342 #undef TRIES 343 } TRIES; 344 345 /* 346 * Common/troublesome character definitions 347 */ 348 #define StringOf(ch) {ch, 0} 349 350 #define L_BRACE '{' 351 #define R_BRACE '}' 352 #define S_QUOTE '\'' 353 #define D_QUOTE '"' 354 355 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~" 356 357 /* 358 * Structure for palette tables 359 */ 360 361 #define MAXCOLUMNS 135 362 #define MAXLINES 66 363 #define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */ 364 365 #define ACS_LEN 128 366 367 #define WINDOWLIST struct _win_list 368 369 #if USE_WIDEC_SUPPORT 370 #define _nc_bkgd _bkgrnd 371 #else 372 #undef _XOPEN_SOURCE_EXTENDED 373 #undef _XPG5 374 #define _nc_bkgd _bkgd 375 #define wgetbkgrnd(win, wch) ((*wch = win->_bkgd) != 0 ? OK : ERR) 376 #define wbkgrnd wbkgd 377 #endif 378 379 #undef NCURSES_OPAQUE 380 #define NCURSES_INTERNALS 1 381 #define NCURSES_OPAQUE 0 382 383 #include <curses.h> /* we'll use -Ipath directive to get the right one! */ 384 385 #if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT)) 386 #undef KEY_EVENT /* reduce compiler-warnings with Visual C++ */ 387 #endif 388 389 typedef struct 390 { 391 int red, green, blue; /* what color_content() returns */ 392 int r, g, b; /* params to init_color() */ 393 int init; /* true if we called init_color() */ 394 } 395 color_t; 396 397 typedef union { 398 struct { 399 unsigned char red; 400 unsigned char green; 401 unsigned char blue; 402 } bits; /* bits per color-value in RGB */ 403 unsigned value; 404 } rgb_bits_t; 405 406 /* 407 * If curses.h did not expose the SCREEN-functions, then we do not need the 408 * parameter in the corresponding unextended functions. 409 */ 410 411 #define USE_SP_FUNC_SUPPORT NCURSES_SP_FUNCS 412 #define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS) 413 414 #if NCURSES_SP_FUNCS 415 #define SP_PARM sp /* use parameter */ 416 #define NCURSES_SP_ARG SP_PARM 417 #define NCURSES_SP_DCL SCREEN *NCURSES_SP_ARG 418 #define NCURSES_SP_DCL0 NCURSES_SP_DCL 419 #define NCURSES_SP_ARGx NCURSES_SP_ARG, 420 #define NCURSES_SP_DCLx SCREEN *NCURSES_SP_ARGx 421 #else 422 #define SP_PARM SP /* use global variable */ 423 #define NCURSES_SP_ARG 424 #define NCURSES_SP_DCL 425 #define NCURSES_SP_DCL0 void 426 #define NCURSES_SP_ARGx 427 #define NCURSES_SP_DCLx 428 #endif 429 430 #include <nc_panel.h> 431 432 #include <term.priv.h> 433 #include <nc_termios.h> 434 435 #define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen) 436 #define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term))) 437 #define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp)) 438 439 #if USE_REENTRANT 440 #define CurTerm _nc_prescreen._cur_term 441 #else 442 #define CurTerm cur_term 443 #endif 444 445 #if NCURSES_SP_FUNCS 446 #define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm) 447 #else 448 #define TerminalOf(sp) CurTerm 449 #endif 450 451 /* 452 * The legacy layout for TERMTYPE uses "short" for all of the numbers. Moving 453 * past that, numeric capabilities can be "int" by using a TERMTYPE2 structure 454 * in TERMINAL, and doing most of the internal work using TERMTYPE2. There are 455 * a few places (mostly to expose the legacy layout) where the distinction 456 * needs attention. 457 */ 458 #if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR 459 #define NCURSES_EXT_NUMBERS 1 460 #define NCURSES_INT2 int 461 #define SIZEOF_INT2 4 462 #define TerminalType(tp) (tp)->type2 463 #else 464 #define NCURSES_EXT_NUMBERS 0 465 #define NCURSES_INT2 short 466 #define SIZEOF_INT2 2 467 #define TerminalType(tp) (tp)->type 468 #endif 469 470 #define SIZEOF_SHORT 2 471 472 #ifdef CUR 473 #undef CUR 474 #define CUR TerminalType(cur_term). 475 #endif 476 477 /* 478 * Reduce dependency on cur_term global by using terminfo data from SCREEN's 479 * pointer to this data. 480 */ 481 #ifdef USE_SP_TERMTYPE 482 #undef CUR 483 #endif 484 485 #define SP_TERMTYPE TerminalType(TerminalOf(sp)). 486 487 #include <term_entry.h> 488 489 #include <nc_tparm.h> 490 491 /* 492 * Simplify ifdef's for the "*_ATTR" macros in case italics are not configured. 493 */ 494 #if defined(A_ITALIC) && defined(exit_italics_mode) 495 #define USE_ITALIC 1 496 #else 497 #define USE_ITALIC 0 498 #undef A_ITALIC 499 #define A_ITALIC 0 500 #endif 501 502 /* 503 * Use these macros internally, to make tracing less verbose. But leave the 504 * option for compiling the tracing into the library. 505 */ 506 #if 1 507 #define ColorPair(n) (NCURSES_BITS(n, 0) & A_COLOR) 508 #define PairNumber(a) (NCURSES_CAST(int,(((unsigned long)(a) & A_COLOR) >> NCURSES_ATTR_SHIFT))) 509 #else 510 #define ColorPair(pair) COLOR_PAIR(pair) 511 #define PairNumber(attr) PAIR_NUMBER(attr) 512 #endif 513 514 #define unColor(n) unColor2(AttrOf(n)) 515 #define unColor2(a) ((a) & ALL_BUT_COLOR) 516 517 /* 518 * Extended-colors stores the color pair in a separate struct-member than the 519 * attributes. But for compatibility, we handle most cases where a program 520 * written for non-extended colors stores the color in the attributes by 521 * checking for a color pair in both places. 522 */ 523 #if NCURSES_EXT_COLORS 524 #define if_EXT_COLORS(stmt) stmt 525 #define SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p) 526 #define SetPair2(c,a,p) c = (p), \ 527 a = (unColor2(a) | ColorPair(oldColor(c))) 528 #define GetPair(value) GetPair2((value).ext_color, AttrOf(value)) 529 #define GetPair2(c,a) ((c) ? (c) : PairNumber(a)) 530 #define oldColor(p) (((p) > 255) ? 255 : (p)) 531 #define GET_WINDOW_PAIR(w) GetPair2((w)->_color, (w)->_attrs) 532 #define SET_WINDOW_PAIR(w,p) (w)->_color = (p) 533 #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b)) 534 535 #define VIDPUTS(sp,attr,pair) do { \ 536 int vid_pair = pair; \ 537 NCURSES_SP_NAME(vid_puts)( \ 538 NCURSES_SP_ARGx attr, \ 539 (NCURSES_PAIRS_T) pair, \ 540 &vid_pair, \ 541 NCURSES_OUTC_FUNC); \ 542 } while (0) 543 544 #else /* !NCURSES_EXT_COLORS */ 545 546 #define if_EXT_COLORS(stmt) /* nothing */ 547 #define SetPair(value,p) RemAttr(value, A_COLOR), \ 548 SetAttr(value, AttrOf(value) | ColorPair(p)) 549 #define GetPair(value) PairNumber(AttrOf(value)) 550 #define GET_WINDOW_PAIR(w) PairNumber(WINDOW_ATTRS(w)) 551 #define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \ 552 WINDOW_ATTRS(w) |= ColorPair(p) 553 #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b)) 554 555 #define VIDPUTS(sp,attr,pair) NCURSES_SP_NAME(vidputs)(NCURSES_SP_ARGx attr, NCURSES_OUTC_FUNC) 556 557 #endif /* NCURSES_EXT_COLORS */ 558 559 #define NCURSES_OUTC_FUNC NCURSES_SP_NAME(_nc_outch) 560 #define NCURSES_PUTP2(name,value) NCURSES_SP_NAME(_nc_putp)(NCURSES_SP_ARGx name, value) 561 #define NCURSES_PUTP2_FLUSH(name,value) NCURSES_SP_NAME(_nc_putp_flush)(NCURSES_SP_ARGx name, value) 562 563 #if NCURSES_NO_PADDING 564 #define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding) 565 #define SetNoPadding(sp) _nc_set_no_padding(sp) 566 extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *); 567 #else 568 #define GetNoPadding(sp) FALSE 569 #define SetNoPadding(sp) /*nothing*/ 570 #endif 571 572 #define WINDOW_ATTRS(w) ((w)->_attrs) 573 574 #define SCREEN_ATTRS(s) (*((s)->_current_attr)) 575 #define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s)) 576 #define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p) 577 578 #if USE_REENTRANT || NCURSES_SP_FUNCS 579 extern NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *); 580 extern NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *); 581 extern NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *); 582 extern NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); 583 #endif 584 585 #if USE_REENTRANT 586 587 #define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES)) 588 #define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS)) 589 #define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE)) 590 #define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY)) 591 592 #define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value 593 #define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value 594 #define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value 595 #define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value 596 597 #else 598 599 #define ptrLines(sp) &LINES 600 #define ptrCols(sp) &COLS 601 #define ptrTabsize(sp) &TABSIZE 602 #define ptrEscdelay(sp) &ESCDELAY 603 604 #define SET_LINES(value) LINES = value 605 #define SET_COLS(value) COLS = value 606 #define SET_TABSIZE(value) TABSIZE = value 607 #define SET_ESCDELAY(value) ESCDELAY = value 608 609 #endif 610 611 #define IS_SUBWIN(w) ((w)->_flags & _SUBWIN) 612 #define IS_PAD(w) ((w)->_flags & _ISPAD) 613 #define IS_WRAPPED(w) ((w)->_flags & _WRAPPED) 614 615 #define HasHardTabs() (NonEmpty(clear_all_tabs) && NonEmpty(set_tab)) 616 617 #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \ 618 __FILE__, __LINE__, \ 619 (unsigned long) (pthread_self()), \ 620 data.__data.__lock, \ 621 data.__data.__count, \ 622 data.__data.__owner, \ 623 data.__data.__kind, \ 624 (data.__data.__nusers > 5) ? " OOPS " : "", \ 625 data.__data.__nusers) 626 #define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name) 627 628 #if USE_WEAK_SYMBOLS 629 #if defined(__GNUC__) 630 # if defined __USE_ISOC99 631 # define _cat_pragma(exp) _Pragma(#exp) 632 # define _weak_pragma(exp) _cat_pragma(weak name) 633 # else 634 # define _weak_pragma(exp) 635 # endif 636 # define _declare(name) __extension__ extern __typeof__(name) name 637 # define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak)) 638 #else 639 # undef USE_WEAK_SYMBOLS 640 # define USE_WEAK_SYMBOLS 0 641 #endif 642 #endif 643 644 #ifdef USE_PTHREADS 645 646 #if USE_REENTRANT 647 #include <pthread.h> 648 extern NCURSES_EXPORT(void) _nc_init_pthreads(void); 649 extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *); 650 extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *); 651 extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *); 652 extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *); 653 #define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name) 654 #define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name) 655 #define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name) 656 657 #else 658 #error POSIX threads requires --enable-reentrant option 659 #endif 660 661 #ifdef USE_PTHREADS 662 # if USE_WEAK_SYMBOLS 663 weak_symbol(pthread_sigmask); 664 weak_symbol(pthread_kill); 665 weak_symbol(pthread_self); 666 weak_symbol(pthread_equal); 667 weak_symbol(pthread_mutex_init); 668 weak_symbol(pthread_mutex_lock); 669 weak_symbol(pthread_mutex_unlock); 670 weak_symbol(pthread_mutex_trylock); 671 weak_symbol(pthread_mutexattr_settype); 672 weak_symbol(pthread_mutexattr_init); 673 extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); 674 # undef sigprocmask 675 # define sigprocmask(a, b, c) _nc_sigprocmask(a, b, c) 676 # define GetThreadID() (((pthread_self)) ? pthread_self() : (pthread_t) getpid()) 677 # else 678 # define GetThreadID() pthread_self() 679 # endif 680 #endif 681 682 #if HAVE_NANOSLEEP 683 #undef HAVE_NANOSLEEP 684 #define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */ 685 #endif 686 687 #else /* !USE_PTHREADS */ 688 689 #if USE_PTHREADS_EINTR 690 # if USE_WEAK_SYMBOLS 691 #include <pthread.h> 692 weak_symbol(pthread_sigmask); 693 weak_symbol(pthread_kill); 694 weak_symbol(pthread_self); 695 weak_symbol(pthread_equal); 696 extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); 697 # undef sigprocmask 698 # define sigprocmask(a, b, c) _nc_sigprocmask(a, b, c) 699 # endif 700 #endif /* USE_PTHREADS_EINTR */ 701 702 #define _nc_init_pthreads() /* nothing */ 703 #define _nc_mutex_init(obj) /* nothing */ 704 705 #define _nc_lock_global(name) /* nothing */ 706 #define _nc_try_global(name) 0 707 #define _nc_unlock_global(name) /* nothing */ 708 #endif /* USE_PTHREADS */ 709 710 #if USE_PTHREADS_EINTR 711 extern NCURSES_EXPORT(void) _nc_set_read_thread(bool); 712 #else 713 #define _nc_set_read_thread(enable) /* nothing */ 714 #endif 715 716 /* 717 * When using sp-funcs, locks are targeted to SCREEN-level granularity. 718 * So the locking is done in the non-sp-func (which calls the sp-func) rather 719 * than in the sp-func itself. 720 * 721 * Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()". 722 * Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS". 723 */ 724 #if NCURSES_SP_FUNCS 725 726 #define _nc_nonsp_lock_global(name) /* nothing */ 727 #define _nc_nonsp_try_global(name) 0 728 #define _nc_nonsp_unlock_global(name) /* nothing */ 729 730 #define _nc_sp_lock_global(name) _nc_lock_global(name) 731 #define _nc_sp_try_global(name) _nc_try_global(name) 732 #define _nc_sp_unlock_global(name) _nc_unlock_global(name) 733 734 #else 735 736 #define _nc_nonsp_lock_global(name) _nc_lock_global(name) 737 #define _nc_nonsp_try_global(name) _nc_try_global(name) 738 #define _nc_nonsp_unlock_global(name) _nc_unlock_global(name) 739 740 #define _nc_sp_lock_global(name) /* nothing */ 741 #define _nc_sp_try_global(name) 0 742 #define _nc_sp_unlock_global(name) /* nothing */ 743 744 #endif 745 746 #if HAVE_CLOCK_GETTIME 747 # define PRECISE_GETTIME 1 748 # define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t) 749 # define TimeType struct timespec 750 # define TimeScale 1000000000L /* 1e9 */ 751 # define sub_secs tv_nsec 752 #elif HAVE_GETTIMEOFDAY 753 # define PRECISE_GETTIME 1 754 # define GetClockTime(t) gettimeofday(t, 0) 755 # define TimeType struct timeval 756 # define TimeScale 1000000L /* 1e6 */ 757 # define sub_secs tv_usec 758 #else 759 # define PRECISE_GETTIME 0 760 # define TimeType time_t 761 #endif 762 763 /* 764 * Definitions for color pairs 765 */ 766 767 #define MAX_OF_TYPE(t) (int)(((unsigned t)(~0))>>1) 768 769 #include <new_pair.h> 770 771 #define isDefaultColor(c) ((c) < 0) 772 #define COLOR_DEFAULT -1 773 774 #if defined(USE_BUILD_CC) || (defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)) 775 776 #undef NCURSES_CH_T /* this is not a termlib feature */ 777 #define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */ 778 779 #endif /* USE_TERMLIB */ 780 781 #ifndef USE_TERMLIB 782 struct ldat 783 { 784 NCURSES_CH_T *text; /* text of the line */ 785 NCURSES_SIZE_T firstchar; /* first changed character in the line */ 786 NCURSES_SIZE_T lastchar; /* last changed character in the line */ 787 NCURSES_SIZE_T oldindex; /* index of the line at last update */ 788 }; 789 #endif /* USE_TERMLIB */ 790 791 typedef enum { 792 M_XTERM = -1 /* use xterm's mouse tracking? */ 793 ,M_NONE = 0 /* no mouse device */ 794 #if USE_GPM_SUPPORT 795 ,M_GPM /* use GPM */ 796 #endif 797 #if USE_SYSMOUSE 798 ,M_SYSMOUSE /* FreeBSD sysmouse on console */ 799 #endif 800 #ifdef USE_TERM_DRIVER 801 ,M_TERM_DRIVER /* Win32 console, etc */ 802 #endif 803 } MouseType; 804 805 typedef enum { 806 MF_X10 = 0 /* conventional 3-byte format */ 807 , MF_SGR1006 /* xterm private mode 1006, SGR-style */ 808 #ifdef EXP_XTERM_1005 809 , MF_XTERM_1005 /* xterm UTF-8 private mode 1005 */ 810 #endif 811 } MouseFormat; 812 813 /* 814 * Structures for scrolling. 815 */ 816 817 typedef struct { 818 unsigned long hashval; 819 int oldcount, newcount; 820 int oldindex, newindex; 821 } HASHMAP; 822 823 /* 824 * Structures for soft labels. 825 */ 826 827 struct _SLK; 828 829 #if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 830 831 typedef struct 832 { 833 char *ent_text; /* text for the label */ 834 char *form_text; /* formatted text (left/center/...) */ 835 int ent_x; /* x coordinate of this field */ 836 char dirty; /* this label has changed */ 837 char visible; /* field is visible */ 838 } slk_ent; 839 840 typedef struct _SLK { 841 bool dirty; /* all labels have changed */ 842 bool hidden; /* soft labels are hidden */ 843 WINDOW *win; 844 slk_ent *ent; 845 short maxlab; /* number of available labels */ 846 short labcnt; /* number of allocated labels */ 847 short maxlen; /* length of labels */ 848 NCURSES_CH_T attr; /* soft label attribute */ 849 } SLK; 850 851 #endif /* USE_TERMLIB */ 852 853 #if USE_GPM_SUPPORT 854 #undef buttons /* term.h defines this, and gpm uses it! */ 855 #include <gpm.h> 856 #if USE_WEAK_SYMBOLS 857 weak_symbol(Gpm_Wgetch); 858 #endif 859 860 #ifdef HAVE_LIBDL 861 /* link dynamically to GPM */ 862 typedef int *TYPE_gpm_fd; 863 typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int); 864 typedef int (*TYPE_Gpm_Close) (void); 865 typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); 866 867 #define my_gpm_fd SP_PARM->_mouse_gpm_fd 868 #define my_Gpm_Open SP_PARM->_mouse_Gpm_Open 869 #define my_Gpm_Close SP_PARM->_mouse_Gpm_Close 870 #define my_Gpm_GetEvent SP_PARM->_mouse_Gpm_GetEvent 871 #else 872 /* link statically to GPM */ 873 #define my_gpm_fd &gpm_fd 874 #define my_Gpm_Open Gpm_Open 875 #define my_Gpm_Close Gpm_Close 876 #define my_Gpm_GetEvent Gpm_GetEvent 877 #endif /* HAVE_LIBDL */ 878 #endif /* USE_GPM_SUPPORT */ 879 880 /* 881 * When converting from terminfo to termcap, check for cases where we can trim 882 * octal escapes down to 2-character form. It is useful for terminfo format 883 * also, but not as important. 884 */ 885 #define MAX_TC_FIXUPS 10 886 #define MIN_TC_FIXUPS 4 887 888 #define isoctal(c) ((c) >= '0' && (c) <= '7') 889 890 /* 891 * The filesystem database normally uses a single-letter for the lower level 892 * of directories. Use a hexadecimal code for filesystems which do not 893 * preserve mixed-case names. 894 */ 895 #if MIXEDCASE_FILENAMES 896 #define LEAF_FMT "%c" 897 #define LEAF_LEN 1 898 #else 899 #define LEAF_FMT "%02x" 900 #define LEAF_LEN 2 901 #endif 902 903 /* 904 * TRACEMSE_FMT is no longer than 80 columns, there are 5 numbers that 905 * could at most have 10 digits, and the mask contains no more than 32 bits 906 * with each bit representing less than 15 characters. Usually the whole 907 * string is less than 80 columns, but this buffer size is an absolute 908 * limit. 909 */ 910 #define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15)) 911 #define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */ 912 913 #ifdef USE_TERM_DRIVER 914 struct DriverTCB; /* Terminal Control Block forward declaration */ 915 #define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver 916 #else 917 #define INIT_TERM_DRIVER() /* nothing */ 918 #endif 919 920 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; 921 922 /* The limit reserves one byte for a terminating NUL */ 923 #define my_getstr_limit (_nc_globals.getstr_limit - 1) 924 #define _nc_getstr_limit(n) \ 925 (((n) < 0) \ 926 ? my_getstr_limit \ 927 : (((n) > my_getstr_limit) \ 928 ? my_getstr_limit \ 929 : (n))) 930 931 /* 932 * Use screen-specific ripoff data (for softkeys) rather than global. 933 */ 934 #ifdef USE_SP_RIPOFF 935 #define safe_ripoff_sp (sp)->rsp 936 #define safe_ripoff_stack (sp)->rippedoff 937 #else 938 #define safe_ripoff_sp _nc_prescreen.rsp 939 #define safe_ripoff_stack _nc_prescreen.rippedoff 940 #endif 941 942 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; 943 944 typedef enum { 945 ewInitial = 0, 946 ewRunning, 947 ewSuspend 948 } ENDWIN; 949 950 typedef struct { 951 int _nl; /* True if NL -> CR/NL is on */ 952 int _raw; /* True if in raw mode */ 953 int _cbreak; /* 1 if in cbreak mode */ 954 /* > 1 if in halfdelay mode */ 955 int _echo; /* True if echo on */ 956 } TTY_FLAGS; 957 958 #define IsNl(sp) (sp)->_tty_flags._nl 959 #define IsRaw(sp) (sp)->_tty_flags._raw 960 #define IsCbreak(sp) (sp)->_tty_flags._cbreak 961 #define IsEcho(sp) (sp)->_tty_flags._echo 962 963 /* 964 * The SCREEN structure. 965 */ 966 typedef struct screen { 967 int _ifd; /* input file descriptor for screen */ 968 int _ofd; /* output file descriptor for screen */ 969 FILE *_ofp; /* output file ptr for screen */ 970 char *out_buffer; /* output buffer */ 971 size_t out_limit; /* output buffer size */ 972 size_t out_inuse; /* output buffer current use */ 973 bool _filtered; /* filter() was called */ 974 bool _prescreen; /* is in prescreen phase */ 975 bool _use_env; /* LINES & COLS from environment? */ 976 int _checkfd; /* filedesc for typeahead check */ 977 TERMINAL *_term; /* terminal type information */ 978 TTY _saved_tty; /* savetty/resetty information */ 979 NCURSES_SIZE_T _lines; /* screen lines */ 980 NCURSES_SIZE_T _columns; /* screen columns */ 981 982 NCURSES_SIZE_T _lines_avail; /* lines available for stdscr */ 983 NCURSES_SIZE_T _topstolen; /* lines stolen from top */ 984 985 WINDOW *_curscr; /* current screen */ 986 WINDOW *_newscr; /* virtual screen to be updated to */ 987 WINDOW *_stdscr; /* screen's full-window context */ 988 989 #define CurScreen(sp) (sp)->_curscr 990 #define NewScreen(sp) (sp)->_newscr 991 #define StdScreen(sp) (sp)->_stdscr 992 993 TRIES *_keytry; /* "Try" for use with keypad mode */ 994 TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */ 995 bool _tried; /* keypad mode was initialized */ 996 bool _keypad_on; /* keypad mode is currently on */ 997 998 bool _called_wgetch; /* check for recursion in wgetch() */ 999 int _fifo[FIFO_SIZE]; /* input push-back buffer */ 1000 short _fifohead, /* head of fifo queue */ 1001 _fifotail, /* tail of fifo queue */ 1002 _fifopeek, /* where to peek for next char */ 1003 _fifohold; /* set if breakout marked */ 1004 1005 int _endwin; /* are we out of window mode? */ 1006 NCURSES_CH_T *_current_attr; /* holds current attributes set */ 1007 int _coloron; /* is color enabled? */ 1008 int _color_defs; /* are colors modified */ 1009 int _cursor; /* visibility of the cursor */ 1010 int _cursrow; /* physical cursor row */ 1011 int _curscol; /* physical cursor column */ 1012 bool _notty; /* true if we cannot switch non-tty */ 1013 TTY_FLAGS _tty_flags; 1014 int _use_meta; /* use the meta key? */ 1015 struct _SLK *_slk; /* ptr to soft key struct / NULL */ 1016 int slk_format; /* selected format for this screen */ 1017 /* cursor movement costs; units are 10ths of milliseconds */ 1018 int _char_padding; /* cost of character put */ 1019 int _cr_cost; /* cost of (carriage_return) */ 1020 int _cup_cost; /* cost of (cursor_address) */ 1021 int _home_cost; /* cost of (cursor_home) */ 1022 int _ll_cost; /* cost of (cursor_to_ll) */ 1023 int _cub1_cost; /* cost of (cursor_left) */ 1024 int _cuf1_cost; /* cost of (cursor_right) */ 1025 int _cud1_cost; /* cost of (cursor_down) */ 1026 int _cuu1_cost; /* cost of (cursor_up) */ 1027 int _cub_cost; /* cost of (parm_cursor_left) */ 1028 int _cuf_cost; /* cost of (parm_cursor_right) */ 1029 int _cud_cost; /* cost of (parm_cursor_down) */ 1030 int _cuu_cost; /* cost of (parm_cursor_up) */ 1031 int _hpa_cost; /* cost of (column_address) */ 1032 int _vpa_cost; /* cost of (row_address) */ 1033 /* used in tty_update.c, must be chars */ 1034 int _ed_cost; /* cost of (clr_eos) */ 1035 int _el_cost; /* cost of (clr_eol) */ 1036 int _el1_cost; /* cost of (clr_bol) */ 1037 int _dch1_cost; /* cost of (delete_character) */ 1038 int _ich1_cost; /* cost of (insert_character) */ 1039 int _dch_cost; /* cost of (parm_dch) */ 1040 int _ich_cost; /* cost of (parm_ich) */ 1041 int _ech_cost; /* cost of (erase_chars) */ 1042 int _rep_cost; /* cost of (repeat_char) */ 1043 int _hpa_ch_cost; /* cost of (column_address) */ 1044 int _cup_ch_cost; /* cost of (cursor_address) */ 1045 int _cuf_ch_cost; /* cost of (parm_cursor_right) */ 1046 int _inline_cost; /* cost of inline-move */ 1047 int _smir_cost; /* cost of (enter_insert_mode) */ 1048 int _rmir_cost; /* cost of (exit_insert_mode) */ 1049 int _ip_cost; /* cost of (insert_padding) */ 1050 /* used in lib_mvcur.c */ 1051 char * _address_cursor; 1052 /* used in tty_update.c */ 1053 int _scrolling; /* 1 if terminal's smart enough to */ 1054 1055 /* used in lib_color.c */ 1056 rgb_bits_t _direct_color; /* RGB overrides color-table */ 1057 color_t *_color_table; /* screen's color palette */ 1058 int _color_count; /* count of colors in palette */ 1059 colorpair_t *_color_pairs; /* screen's color pair list */ 1060 int _pair_count; /* same as COLOR_PAIRS */ 1061 int _pair_limit; /* actual limit of color-pairs */ 1062 int _pair_alloc; /* current table-size of color-pairs */ 1063 chtype _ok_attributes; /* valid attributes for terminal */ 1064 chtype _xmc_suppress; /* attributes to suppress if xmc */ 1065 chtype _xmc_triggers; /* attributes to process if xmc */ 1066 chtype * _acs_map; /* the real alternate-charset map */ 1067 bool * _screen_acs_map; 1068 1069 1070 /* used in lib_vidattr.c */ 1071 bool _use_rmso; /* true if we may use 'rmso' */ 1072 bool _use_rmul; /* true if we may use 'rmul' */ 1073 1074 /* 1075 * These data correspond to the state of the idcok() and idlok() 1076 * functions. A caveat is in order here: the XSI and SVr4 1077 * documentation specify that these functions apply to the window which 1078 * is given as an argument. However, ncurses implements this logic 1079 * only for the newscr/curscr update process, _not_ per-window. 1080 */ 1081 bool _nc_sp_idlok; 1082 bool _nc_sp_idcok; 1083 1084 /* 1085 * These are the data that support the mouse interface. 1086 */ 1087 bool _mouse_initialized; 1088 MouseType _mouse_type; 1089 int _maxclick; 1090 bool (*_mouse_event) (SCREEN *); 1091 bool (*_mouse_inline)(SCREEN *); 1092 bool (*_mouse_parse) (SCREEN *, int); 1093 void (*_mouse_resume)(SCREEN *); 1094 void (*_mouse_wrap) (SCREEN *); 1095 int _mouse_fd; /* file-descriptor, if any */ 1096 bool _mouse_active; /* true if initialized */ 1097 mmask_t _mouse_mask; /* set via mousemask() */ 1098 mmask_t _mouse_mask2; /* OR's in press/release bits */ 1099 mmask_t _mouse_bstate; 1100 MouseFormat _mouse_format; /* type of xterm mouse protocol */ 1101 NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */ 1102 MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */ 1103 MEVENT *_mouse_eventp; /* next free slot in event queue */ 1104 1105 /* 1106 * These are data that support the proper handling of the panel stack on an 1107 * per screen basis. 1108 */ 1109 struct panelhook _panelHook; 1110 1111 bool _sig_winch; 1112 SCREEN *_next_screen; 1113 1114 /* hashes for old and new lines */ 1115 unsigned long *oldhash, *newhash; 1116 HASHMAP *hashtab; 1117 int hashtab_len; 1118 int *_oldnum_list; 1119 int _oldnum_size; 1120 1121 NCURSES_SP_OUTC _outch; /* output handler if not putc */ 1122 NCURSES_OUTC jump; 1123 1124 ripoff_t rippedoff[N_RIPS]; 1125 ripoff_t *rsp; 1126 1127 int _legacy_coding; /* see use_legacy_coding() */ 1128 1129 #if NCURSES_NO_PADDING 1130 bool _no_padding; /* flag to set if padding disabled */ 1131 #endif 1132 1133 #if USE_HARD_TABS 1134 int _ht_cost; /* cost of (tab) */ 1135 int _cbt_cost; /* cost of (backtab) */ 1136 #endif /* USE_HARD_TABS */ 1137 1138 /* used in lib_vidattr.c */ 1139 #if USE_ITALIC 1140 bool _use_ritm; /* true if we may use 'ritm' */ 1141 #endif 1142 1143 /* used in getch/twait */ 1144 #if USE_KLIBC_KBD 1145 bool _extended_key; /* true if an extended key */ 1146 #endif 1147 1148 /* used in lib_color.c */ 1149 #if NCURSES_EXT_FUNCS 1150 bool _assumed_color; /* use assumed colors */ 1151 bool _default_color; /* use default colors */ 1152 bool _has_sgr_39_49; /* has ECMA default color support */ 1153 int _default_fg; /* assumed default foreground */ 1154 int _default_bg; /* assumed default background */ 1155 int _default_pairs; /* count pairs using default color */ 1156 #endif 1157 1158 /* system-dependent mouse data */ 1159 #if USE_GPM_SUPPORT 1160 bool _mouse_gpm_loaded; 1161 bool _mouse_gpm_found; 1162 #ifdef HAVE_LIBDL 1163 void *_dlopen_gpm; 1164 TYPE_gpm_fd _mouse_gpm_fd; 1165 TYPE_Gpm_Open _mouse_Gpm_Open; 1166 TYPE_Gpm_Close _mouse_Gpm_Close; 1167 TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent; 1168 #endif 1169 Gpm_Connect _mouse_gpm_connect; 1170 #endif /* USE_GPM_SUPPORT */ 1171 1172 #if USE_EMX_MOUSE 1173 int _emxmouse_wfd; 1174 int _emxmouse_thread; 1175 int _emxmouse_activated; 1176 char _emxmouse_buttons[4]; 1177 #endif 1178 1179 #if USE_SYSMOUSE 1180 MEVENT _sysmouse_fifo[FIFO_SIZE]; 1181 int _sysmouse_head; 1182 int _sysmouse_tail; 1183 int _sysmouse_char_width; /* character width */ 1184 int _sysmouse_char_height; /* character height */ 1185 int _sysmouse_old_buttons; 1186 int _sysmouse_new_buttons; 1187 #endif 1188 1189 #if defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER) 1190 MEVENT _drv_mouse_fifo[FIFO_SIZE]; 1191 int _drv_mouse_head; 1192 int _drv_mouse_tail; 1193 int _drv_mouse_old_buttons; 1194 int _drv_mouse_new_buttons; 1195 #endif 1196 /* 1197 * This supports automatic resizing 1198 */ 1199 #if USE_SIZECHANGE 1200 int (*_resize)(NCURSES_SP_DCLx int y, int x); 1201 int (*_ungetch)(SCREEN *, int); 1202 #endif 1203 1204 #ifdef USE_SP_WINDOWLIST 1205 WINDOWLIST* _windowlist; 1206 #define WindowList(sp) (sp)->_windowlist 1207 #endif 1208 1209 #if USE_REENTRANT 1210 char _ttytype[NAMESIZE]; 1211 int _ESCDELAY; 1212 int _TABSIZE; 1213 int _LINES; 1214 int _COLS; 1215 #endif 1216 1217 #if NCURSES_SP_FUNCS 1218 bool use_tioctl; 1219 #endif 1220 1221 /* 1222 * ncurses/ncursesw are the same up to this point. 1223 */ 1224 #if USE_WIDEC_SUPPORT 1225 /* recent versions of 'screen' have partially-working support for 1226 * UTF-8, but do not permit ACS at the same time (see tty_update.c). 1227 */ 1228 bool _screen_acs_fix; 1229 bool _screen_unicode; 1230 #endif 1231 1232 #if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS 1233 void *_ordered_pairs; /* index used by alloc_pair() */ 1234 int _pairs_used; /* actual number of color-pairs used */ 1235 int _recent_pair; /* number for most recent free-pair */ 1236 #endif 1237 1238 #ifdef TRACE 1239 char tracechr_buf[40]; 1240 char tracemse_buf[TRACEMSE_MAX]; 1241 #if USE_REENTRANT 1242 long _outchars; 1243 const char *_tputs_trace; 1244 #endif 1245 #endif 1246 #undef SCREEN 1247 } SCREEN; 1248 1249 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; 1250 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; 1251 1252 WINDOWLIST { 1253 WINDOWLIST *next; 1254 SCREEN *screen; /* screen containing the window */ 1255 WINDOW win; /* WINDOW_EXT() needs to account for offset */ 1256 #if NCURSES_WIDECHAR 1257 char addch_work[(MB_LEN_MAX * 9) + 1]; 1258 unsigned addch_used; /* number of bytes in addch_work[] */ 1259 int addch_x; /* x-position for addch_work[] */ 1260 int addch_y; /* y-position for addch_work[] */ 1261 #endif 1262 }; 1263 1264 #define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m) 1265 1266 #ifdef USE_SP_WINDOWLIST 1267 #define SP_INIT_WINDOWLIST(sp) WindowList(sp) = 0 1268 #else 1269 #define SP_INIT_WINDOWLIST(sp) /* nothing */ 1270 #endif 1271 1272 #define SP_PRE_INIT(sp) \ 1273 sp->_cursrow = -1; \ 1274 sp->_curscol = -1; \ 1275 IsNl(sp) = TRUE; \ 1276 IsRaw(sp) = FALSE; \ 1277 IsCbreak(sp) = 0; \ 1278 IsEcho(sp) = TRUE; \ 1279 sp->_fifohead = -1; \ 1280 sp->_endwin = ewSuspend; \ 1281 sp->_cursor = -1; \ 1282 SP_INIT_WINDOWLIST(sp); \ 1283 sp->_outch = NCURSES_OUTC_FUNC; \ 1284 sp->jump = 0 \ 1285 1286 /* usually in <limits.h> */ 1287 #ifndef UCHAR_MAX 1288 #define UCHAR_MAX 255 1289 #endif 1290 1291 /* The terminfo source is assumed to be 7-bit ASCII */ 1292 #define is7bits(c) ((unsigned)(c) < 128) 1293 1294 /* Checks for isprint() should be done on 8-bit characters (non-wide) */ 1295 #define is8bits(c) ((unsigned)(c) <= UCHAR_MAX) 1296 1297 #ifndef min 1298 #define min(a,b) ((a) > (b) ? (b) : (a)) 1299 #endif 1300 1301 #ifndef max 1302 #define max(a,b) ((a) < (b) ? (b) : (a)) 1303 #endif 1304 1305 /* usually in <unistd.h> */ 1306 #ifndef STDIN_FILENO 1307 #define STDIN_FILENO 0 1308 #endif 1309 1310 #ifndef STDOUT_FILENO 1311 #define STDOUT_FILENO 1 1312 #endif 1313 1314 #ifndef STDERR_FILENO 1315 #define STDERR_FILENO 2 1316 #endif 1317 1318 #ifndef EXIT_SUCCESS 1319 #define EXIT_SUCCESS 0 1320 #endif 1321 1322 #ifndef EXIT_FAILURE 1323 #define EXIT_FAILURE 1 1324 #endif 1325 1326 #ifndef R_OK 1327 #define R_OK 4 /* Test for read permission. */ 1328 #endif 1329 #ifndef W_OK 1330 #define W_OK 2 /* Test for write permission. */ 1331 #endif 1332 #ifndef X_OK 1333 #define X_OK 1 /* Test for execute permission. */ 1334 #endif 1335 #ifndef F_OK 1336 #define F_OK 0 /* Test for existence. */ 1337 #endif 1338 1339 #if HAVE_FCNTL_H 1340 #include <fcntl.h> /* may define O_BINARY */ 1341 #endif 1342 1343 #ifndef O_BINARY 1344 #define O_BINARY 0 1345 #endif 1346 1347 #ifdef TRACE 1348 #if USE_REENTRANT 1349 #define COUNT_OUTCHARS(n) _nc_count_outchars(n); 1350 #else 1351 #define COUNT_OUTCHARS(n) _nc_outchars += (n); 1352 #endif 1353 #else 1354 #define COUNT_OUTCHARS(n) /* nothing */ 1355 #endif 1356 1357 #define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars) 1358 1359 #define UChar(c) ((unsigned char)(c)) 1360 #define UShort(c) ((unsigned short)(c)) 1361 #define ChCharOf(c) ((chtype)(c) & (chtype)A_CHARTEXT) 1362 #define ChAttrOf(c) ((chtype)(c) & (chtype)A_ATTRIBUTES) 1363 1364 #define TR_PUTC(c) TR(TRACE_CHARPUT, ("PUTC %#x", UChar(c))) 1365 1366 #ifndef MB_LEN_MAX 1367 #define MB_LEN_MAX 16 /* should be >= MB_CUR_MAX, but that may be a function */ 1368 #endif 1369 1370 #if USE_WIDEC_SUPPORT /* { */ 1371 /* true if the status/errno indicate an illegal multibyte sequence */ 1372 #define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ)) 1373 1374 #define init_mb(state) memset(&(state), 0, sizeof(state)) 1375 1376 #if NCURSES_EXT_COLORS 1377 #define NulColor , 0 1378 #else 1379 #define NulColor /* nothing */ 1380 #endif 1381 1382 #define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */ 1383 #define CharOf(c) ((c).chars[0]) 1384 #define AttrOf(c) ((c).attr) 1385 1386 #define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES) 1387 #define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES) 1388 #define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c) 1389 1390 #define NewChar2(c,a) { a, { c, NulChar } NulColor } 1391 #define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch)) 1392 1393 #if CCHARW_MAX == 5 1394 #define CharEq(a,b) (((a).attr == (b).attr) \ 1395 && (a).chars[0] == (b).chars[0] \ 1396 && (a).chars[1] == (b).chars[1] \ 1397 && (a).chars[2] == (b).chars[2] \ 1398 && (a).chars[3] == (b).chars[3] \ 1399 && (a).chars[4] == (b).chars[4] \ 1400 if_EXT_COLORS(&& (a).ext_color == (b).ext_color)) 1401 #elif CCHARW_MAX > 0 1402 #error Inconsistent values for CCHARW_MAX 1403 #else 1404 #define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a))) 1405 #endif 1406 1407 #define SetChar(ch,c,a) do { \ 1408 NCURSES_CH_T *_cp = &(ch); \ 1409 memset(_cp, 0, sizeof(ch)); \ 1410 _cp->chars[0] = (wchar_t) (c); \ 1411 _cp->attr = (a); \ 1412 if_EXT_COLORS(SetPair(ch, PairNumber(a))); \ 1413 } while (0) 1414 #define CHREF(wch) (&(wch)) 1415 #define CHDEREF(wch) (*(wch)) 1416 #define ARG_CH_T NCURSES_CH_T * 1417 #define CARG_CH_T const NCURSES_CH_T * 1418 #define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \ 1419 mbstate_t PUT_st; wchar_t PUTC_ch 1420 #define PUTC_INIT init_mb (PUT_st) 1421 #define PUTC(ch) do { if(!isWidecExt(ch)) { \ 1422 if (Charable(ch)) { \ 1423 TR_PUTC(CharOf(ch)); \ 1424 NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ 1425 COUNT_OUTCHARS(1); \ 1426 } else { \ 1427 for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \ 1428 PUTC_ch = (ch).chars[PUTC_i]; \ 1429 if (PUTC_ch == L'\0') \ 1430 break; \ 1431 PUTC_INIT; \ 1432 PUTC_n = (int) wcrtomb(PUTC_buf, \ 1433 (ch).chars[PUTC_i], &PUT_st); \ 1434 if (PUTC_n <= 0) { \ 1435 if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \ 1436 TR_PUTC(CharOf(ch)); \ 1437 NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ 1438 } \ 1439 break; \ 1440 } else { \ 1441 int PUTC_j; \ 1442 for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \ 1443 TR_PUTC(PUTC_buf[PUTC_j]); \ 1444 NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \ 1445 } \ 1446 } \ 1447 } \ 1448 COUNT_OUTCHARS(PUTC_i); \ 1449 } } } while (0) 1450 1451 #define BLANK NewChar2(' ', WA_NORMAL) 1452 #define ZEROS NewChar2('\0', WA_NORMAL) 1453 #define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0') 1454 1455 /* 1456 * Wide characters cannot be represented in the A_CHARTEXT mask of 1457 * attr_t's but an application might have set a narrow character there. 1458 * But even in that case, it would only be a printable character, or 1459 * zero. Otherwise we can use those bits to tell if a cell is the 1460 * first or extension part of a wide character. 1461 */ 1462 #define WidecExt(ch) (int) (AttrOf(ch) & A_CHARTEXT) 1463 #define isWidecBase(ch) (WidecExt(ch) == 1) 1464 #define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32) 1465 #define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \ 1466 AttrOf(dst) |= (attr_t) (ext + 1) 1467 1468 #define if_WIDEC(code) code 1469 #define Charable(ch) (((SP_PARM->_legacy_coding) \ 1470 || (AttrOf(ch) & A_ALTCHARSET) \ 1471 || (!isWidecExt(ch))) && \ 1472 (ch).chars[1] == L'\0' && \ 1473 _nc_is_charable(CharOf(ch))) 1474 1475 #define L(ch) L ## ch 1476 #else /* }{ */ 1477 #define CharOf(c) ChCharOf(c) 1478 #define AttrOf(c) ChAttrOf(c) 1479 #define AddAttr(c,a) c |= (a) 1480 #define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES) 1481 #define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a) 1482 #define NewChar(ch) (ch) 1483 #define NewChar2(c,a) ((c) | (a)) 1484 #define CharEq(a,b) ((a) == (b)) 1485 #define SetChar(ch,c,a) ch = (c) | (a) 1486 #define CHREF(wch) wch 1487 #define CHDEREF(wch) wch 1488 #define ARG_CH_T NCURSES_CH_T 1489 #define CARG_CH_T NCURSES_CH_T 1490 #define PUTC_DATA /* nothing */ 1491 #define PUTC(ch) { \ 1492 TR_PUTC(ch); \ 1493 NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) ch); \ 1494 } 1495 1496 #define BLANK (' '|A_NORMAL) 1497 #define ZEROS ('\0'|A_NORMAL) 1498 #define ISBLANK(ch) (CharOf(ch) == ' ') 1499 1500 #define isWidecExt(ch) (0) 1501 #define if_WIDEC(code) /* nothing */ 1502 1503 #define Charable(ch) (CharOf(ch) >= ' ' && CharOf(ch) <= '~') 1504 #define L(ch) ch 1505 #endif /* } */ 1506 1507 #define AttrOfD(ch) AttrOf(CHDEREF(ch)) 1508 #define CharOfD(ch) CharOf(CHDEREF(ch)) 1509 #define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch)) 1510 1511 #define BLANK_ATTR A_NORMAL 1512 #define BLANK_TEXT L(' ') 1513 1514 #define CHANGED -1 1515 1516 #define LEGALYX(w, y, x) \ 1517 ((w) != 0 && \ 1518 ((x) >= 0 && (x) <= (w)->_maxx && \ 1519 (y) >= 0 && (y) <= (w)->_maxy)) 1520 1521 #define CHANGED_CELL(line,col) \ 1522 if (line->firstchar == _NOCHANGE) \ 1523 line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \ 1524 else if ((col) < line->firstchar) \ 1525 line->firstchar = (NCURSES_SIZE_T) (col); \ 1526 else if ((col) > line->lastchar) \ 1527 line->lastchar = (NCURSES_SIZE_T) (col) 1528 1529 #define CHANGED_RANGE(line,start,end) \ 1530 if (line->firstchar == _NOCHANGE \ 1531 || line->firstchar > (start)) \ 1532 line->firstchar = (NCURSES_SIZE_T) (start); \ 1533 if (line->lastchar == _NOCHANGE \ 1534 || line->lastchar < (end)) \ 1535 line->lastchar = (NCURSES_SIZE_T) (end) 1536 1537 #define CHANGED_TO_EOL(line,start,end) \ 1538 if (line->firstchar == _NOCHANGE \ 1539 || line->firstchar > (start)) \ 1540 line->firstchar = (NCURSES_SIZE_T) (start); \ 1541 line->lastchar = (NCURSES_SIZE_T) (end) 1542 1543 #define SIZEOF(v) (sizeof(v)/sizeof(v[0])) 1544 1545 #include <nc_alloc.h> 1546 #include <nc_access.h> 1547 1548 #define FreeIfNeeded(p) if ((p) != 0) free(p) 1549 1550 /* FreeAndNull() is not a comma-separated expression because some compilers 1551 * do not accept a mixture of void with values. 1552 */ 1553 #define FreeAndNull(p) do { free(p); p = 0; } while (0) 1554 1555 #ifdef EXP_OOM_TESTING 1556 extern NCURSES_EXPORT(void *) _nc_oom_malloc(size_t size); 1557 extern NCURSES_EXPORT(void *) _nc_oom_calloc(size_t nmemb, size_t size); 1558 extern NCURSES_EXPORT(void *) _nc_oom_realloc(void *ptr, size_t size); 1559 extern NCURSES_EXPORT(void) _nc_oom_free(void *ptr); 1560 extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr); 1561 #define malloc(size) _nc_oom_malloc(size) 1562 #define calloc(nmemb, size) _nc_oom_calloc(nmemb, size) 1563 #define realloc(ptr, size) _nc_oom_realloc(ptr, size) 1564 #define free(ptr) _nc_oom_free(ptr) 1565 #define strdup(ptr) _nc_oom_strdup(ptr) 1566 #endif 1567 1568 /* 1569 * Use these for tic/infocmp malloc failures. Generally the ncurses library 1570 * tries to limp along after a failure. 1571 */ 1572 #define TYPE_MALLOC(type, size, name) \ 1573 do { \ 1574 name = typeMalloc(type, size); \ 1575 if (name == 0) \ 1576 _nc_err_abort(MSG_NO_MEMORY); \ 1577 } while (0) 1578 1579 #define TYPE_CALLOC(type, size, name) \ 1580 do { \ 1581 name = typeCalloc(type, size); \ 1582 if (name == 0) \ 1583 _nc_err_abort(MSG_NO_MEMORY); \ 1584 } while (0) 1585 1586 #define TYPE_REALLOC(type, size, name) \ 1587 do { \ 1588 name = typeRealloc(type, size, name); \ 1589 if (name == 0) \ 1590 _nc_err_abort(MSG_NO_MEMORY); \ 1591 } while (0) 1592 1593 /* 1594 * TTY bit definition for converting tabs to spaces. 1595 */ 1596 #ifdef TAB3 1597 # define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */ 1598 #else 1599 # ifdef XTABS 1600 # define OFLAGS_TABS XTABS /* XTABS is usually the "same" */ 1601 # else 1602 # ifdef OXTABS 1603 # define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */ 1604 # else 1605 # define OFLAGS_TABS 0 1606 # endif 1607 # endif 1608 #endif 1609 1610 #ifdef __TANDEM 1611 #define ROOT_UID 65535 1612 #endif 1613 1614 #ifndef ROOT_UID 1615 #define ROOT_UID 0 1616 #endif 1617 1618 /* 1619 * Standardize/simplify common loops 1620 */ 1621 #define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen 1622 #define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next 1623 #define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p 1624 1625 /* 1626 * Prefixes for call/return points of library function traces. We use these to 1627 * instrument the public functions so that the traces can be easily transformed 1628 * into regression scripts. 1629 */ 1630 #define T_CALLED(fmt) "called {" fmt 1631 #define T_CREATE(fmt) "create :" fmt 1632 #define T_RETURN(fmt) "return }" fmt 1633 1634 #define NonNull(s) ((s) != 0 ? s : "<null>") 1635 #define NonEmpty(s) ((s) != 0 && *(s) != '\0') 1636 1637 #ifdef TRACE 1638 1639 #if USE_REENTRANT 1640 #define TPUTS_TRACE(s) _nc_set_tputs_trace(s); 1641 #else 1642 #define TPUTS_TRACE(s) _nc_tputs_trace = s; 1643 #endif 1644 1645 #ifdef HAVE_CONSISTENT_GETENV 1646 #define START_TRACE() \ 1647 if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \ 1648 int t = _nc_getenv_num("NCURSES_TRACE"); \ 1649 if (t >= 0) \ 1650 curses_trace((unsigned) t); \ 1651 } 1652 #else 1653 #define START_TRACE() /* nothing */ 1654 #endif 1655 1656 /* 1657 * Many of the _tracef() calls use static buffers; lock the trace state before 1658 * trying to fill them. 1659 */ 1660 #if USE_REENTRANT 1661 #define USE_TRACEF(mask) _nc_use_tracef(mask) 1662 extern NCURSES_EXPORT(int) _nc_use_tracef (unsigned); 1663 extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2); 1664 #else 1665 #define USE_TRACEF(mask) (_nc_tracing & (mask)) 1666 #define _nc_locked_tracef _tracef 1667 #endif 1668 1669 #define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a 1670 #define T(a) TR(TRACE_CALLS, a) 1671 #define TRACE_RETURN(value,type) return _nc_retrace_##type((type)(value)) 1672 #define TRACE_RETURN1(value,dst) return _nc_retrace_##dst(value) 1673 #define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value) 1674 #define TRACE_RETURN_SP(value,type) return _nc_retrace_##type(SP_PARM, value) 1675 1676 typedef void VoidFunc(void); 1677 1678 #define TR_FUNC_LEN ((sizeof(void *) + sizeof(void (*)(void))) * 2 + 4) 1679 #define TR_FUNC_BFR(max) char tr_func_data[max][TR_FUNC_LEN] 1680 #define TR_FUNC_ARG(num,func) _nc_fmt_funcptr(&tr_func_data[num][0], (const char *)&(func), sizeof((func))) 1681 1682 #define returnAttr(code) TRACE_RETURN(code,attr_t) 1683 #define returnBits(code) TRACE_RETURN(code,unsigned) 1684 #define returnBool(code) TRACE_RETURN(code,bool) 1685 #define returnCPtr(code) TRACE_RETURN1(code,cptr) 1686 #define returnCVoidPtr(code) TRACE_RETURN1(code,cvoid_ptr) 1687 #define returnChar(code) TRACE_RETURN(code,char) 1688 #define returnChtype(code) TRACE_RETURN(code,chtype) 1689 #define returnCode(code) TRACE_RETURN(code,int) 1690 #define returnIntAttr(code) TRACE_RETURN2(code,int,attr_t) 1691 #define returnMMask(code) TRACE_RETURN_SP(code,mmask_t) 1692 #define returnPtr(code) TRACE_RETURN1(code,ptr) 1693 #define returnSP(code) TRACE_RETURN1(code,sp) 1694 #define returnVoid { T((T_RETURN(""))); return; } 1695 #define returnVoidPtr(code) TRACE_RETURN1(code,void_ptr) 1696 #define returnWin(code) TRACE_RETURN1(code,win) 1697 1698 #define returnDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0) 1699 #define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0) 1700 #define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0) 1701 1702 extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int); 1703 extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *); 1704 extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *); 1705 extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *); 1706 extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t); 1707 extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *); 1708 extern NCURSES_EXPORT(char *) _nc_trace_ttymode(const TTY *tty); 1709 extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list); 1710 extern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype); 1711 extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype); 1712 extern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *); 1713 extern NCURSES_EXPORT(char) _nc_retrace_char (int); 1714 extern NCURSES_EXPORT(int) _nc_retrace_int (int); 1715 extern NCURSES_EXPORT(int) _nc_retrace_int_attr_t (attr_t); 1716 extern NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t (SCREEN *, mmask_t); 1717 extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned); 1718 extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *); 1719 extern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *); 1720 1721 extern NCURSES_EXPORT(char *) _nc_fmt_funcptr(char *, const char *, size_t); 1722 1723 #if USE_REENTRANT 1724 NCURSES_WRAPPED_VAR(long, _nc_outchars); 1725 NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace); 1726 #define _nc_outchars NCURSES_PUBLIC_VAR(_nc_outchars()) 1727 #define _nc_tputs_trace NCURSES_PUBLIC_VAR(_nc_tputs_trace()) 1728 extern NCURSES_EXPORT(void) _nc_set_tputs_trace (const char *); 1729 extern NCURSES_EXPORT(void) _nc_count_outchars (long); 1730 #else 1731 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace; 1732 extern NCURSES_EXPORT_VAR(long) _nc_outchars; 1733 #endif 1734 1735 extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; 1736 1737 extern NCURSES_EXPORT(char *) _nc_tracebits (void); 1738 extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *); 1739 extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *); 1740 1741 #if USE_WIDEC_SUPPORT 1742 extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *); 1743 extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int); 1744 #endif 1745 1746 extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int); 1747 extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int); 1748 1749 #else /* !TRACE */ 1750 1751 #define START_TRACE() /* nothing */ 1752 1753 #define T(a) 1754 #define TR(n, a) 1755 #define TPUTS_TRACE(s) 1756 #define TR_FUNC_BFR(max) 1757 1758 #define returnAttr(code) return code 1759 #define returnBits(code) return code 1760 #define returnBool(code) return code 1761 #define returnCPtr(code) return code 1762 #define returnCVoidPtr(code) return code 1763 #define returnChar(code) return ((char) code) 1764 #define returnChtype(code) return code 1765 #define returnCode(code) return code 1766 #define returnIntAttr(code) return code 1767 #define returnMMask(code) return code 1768 #define returnPtr(code) return code 1769 #define returnSP(code) return code 1770 #define returnVoid return 1771 #define returnVoidPtr(code) return code 1772 #define returnWin(code) return code 1773 1774 #define returnDB(code) return code 1775 #define returnPtrDB(rc) return rc 1776 #define returnVoidDB return 1777 1778 #endif /* TRACE/!TRACE */ 1779 1780 /* 1781 * Workaround for defective implementation of gcc attribute warn_unused_result 1782 */ 1783 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE) 1784 #define IGNORE_RC(func) errno = (int) func 1785 #else 1786 #define IGNORE_RC(func) (void) func 1787 #endif /* gcc workarounds */ 1788 1789 /* 1790 * Return-codes for tgetent() and friends. 1791 */ 1792 #define TGETENT_YES 1 /* entry is found */ 1793 #define TGETENT_NO 0 /* entry is not found */ 1794 #define TGETENT_ERR -1 /* an error occurred */ 1795 1796 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); 1797 extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int); 1798 1799 #define EMPTY_MODULE(name) \ 1800 extern NCURSES_EXPORT(void) name (void); \ 1801 NCURSES_EXPORT(void) name (void) { } 1802 1803 #define ALL_BUT_COLOR ((chtype)~(A_COLOR)) 1804 #define NONBLANK_ATTR (A_BOLD | A_DIM | A_BLINK | A_ITALIC) 1805 #define TPARM_ATTR (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_ALTCHARSET | A_INVIS | A_PROTECT) 1806 #define XMC_CONFLICT (A_STANDOUT | A_UNDERLINE | A_REVERSE | A_BLINK | A_DIM | A_BOLD | A_INVIS | A_PROTECT | A_ITALIC) 1807 #define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress) 1808 1809 #define toggle_attr_on(S,at) {\ 1810 if (PairNumber(at) > 0) {\ 1811 (S) = ((S) & ALL_BUT_COLOR) | (attr_t) (at);\ 1812 } else {\ 1813 (S) |= (attr_t) (at);\ 1814 }\ 1815 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} 1816 1817 1818 #define toggle_attr_off(S,at) {\ 1819 if (PairNumber(at) > 0) {\ 1820 (S) &= ~(at|A_COLOR);\ 1821 } else {\ 1822 (S) &= ~(at);\ 1823 }\ 1824 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} 1825 1826 #define DelCharCost(sp,count) \ 1827 ((parm_dch != 0) \ 1828 ? sp->_dch_cost \ 1829 : ((delete_character != 0) \ 1830 ? (sp->_dch1_cost * count) \ 1831 : INFINITY)) 1832 1833 #define InsCharCost(sp,count) \ 1834 ((parm_ich != 0) \ 1835 ? sp->_ich_cost \ 1836 : ((enter_insert_mode && exit_insert_mode) \ 1837 ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \ 1838 : ((insert_character != 0) \ 1839 ? ((sp->_ich1_cost + sp->_ip_cost) * count) \ 1840 : INFINITY))) 1841 1842 #if USE_XMC_SUPPORT 1843 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ 1844 attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \ 1845 VIDPUTS(sp, AttrOf(c), GetPair(c)); \ 1846 if (magic_cookie_glitch > 0 \ 1847 && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(sp))))) { \ 1848 T(("%s @%d before glitch %d,%d", \ 1849 __FILE__, __LINE__, \ 1850 sp->_cursrow, \ 1851 sp->_curscol)); \ 1852 NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \ 1853 } \ 1854 } 1855 #else 1856 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ 1857 VIDPUTS(sp, AttrOf(c), GetPair(c)); \ 1858 } 1859 #endif 1860 1861 /* 1862 * Macros to make additional parameter to implement wgetch_events() 1863 */ 1864 #ifdef NCURSES_WGETCH_EVENTS 1865 #define EVENTLIST_0th(param) param 1866 #define EVENTLIST_1st(param) param 1867 #define EVENTLIST_2nd(param) , param 1868 #define TWAIT_MASK (TW_ANY | TW_EVENT) 1869 #else 1870 #define EVENTLIST_0th(param) void 1871 #define EVENTLIST_1st(param) /* nothing */ 1872 #define EVENTLIST_2nd(param) /* nothing */ 1873 #define TWAIT_MASK TW_ANY 1874 #endif 1875 1876 #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS 1877 1878 #undef toggle_attr_on 1879 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at) 1880 extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t); 1881 1882 #undef toggle_attr_off 1883 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at) 1884 extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t); 1885 1886 #undef DelCharCost 1887 #define DelCharCost(sp, count) NCURSES_SP_NAME(_nc_DelCharCost)(NCURSES_SP_ARGx count) 1888 1889 #undef InsCharCost 1890 #define InsCharCost(sp, count) NCURSES_SP_NAME(_nc_InsCharCost)(NCURSES_SP_ARGx count) 1891 1892 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int _c); 1893 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int _c); 1894 1895 #undef UpdateAttrs 1896 #define UpdateAttrs(sp,c) NCURSES_SP_NAME(_nc_UpdateAttrs)(NCURSES_SP_ARGx CHREF(c)) 1897 1898 #if USE_WIDEC_SUPPORT || defined(NEED_NCURSES_CH_T) 1899 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T _c); 1900 #else 1901 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx chtype c); 1902 #endif 1903 1904 #if NCURSES_SP_FUNCS 1905 extern NCURSES_EXPORT(int) _nc_DelCharCost (int); 1906 extern NCURSES_EXPORT(int) _nc_InsCharCost (int); 1907 extern NCURSES_EXPORT(void) _nc_UpdateAttrs (CARG_CH_T); 1908 #endif /* NCURSES_SP_FUNCS */ 1909 1910 #else 1911 1912 extern NCURSES_EXPORT(void) _nc_expanded (void); 1913 1914 #endif 1915 1916 #if !NCURSES_EXT_FUNCS 1917 #define set_escdelay(value) ESCDELAY = value 1918 #endif 1919 1920 #if !HAVE_GETCWD 1921 #define getcwd(buf,len) getwd(buf) 1922 #endif 1923 1924 #define save_ttytype(termp) \ 1925 if (TerminalType(termp).term_names != 0) { \ 1926 _nc_STRNCPY(ttytype, \ 1927 TerminalType(termp).term_names, \ 1928 NAMESIZE - 1); \ 1929 ttytype[NAMESIZE - 1] = '\0'; \ 1930 } 1931 1932 #if !NCURSES_WCWIDTH_GRAPHICS 1933 extern NCURSES_EXPORT(int) _nc_wacs_width(unsigned); 1934 #else 1935 #define _nc_wacs_width(ch) wcwidth(ch) 1936 #endif 1937 1938 /* charable.c */ 1939 #if USE_WIDEC_SUPPORT 1940 extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t); 1941 extern NCURSES_EXPORT(int) _nc_to_char(wint_t); 1942 extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int); 1943 #endif 1944 1945 /* comp_captab.c */ 1946 typedef struct { 1947 short nte_name; /* offset of name to hash on */ 1948 int nte_type; /* BOOLEAN, NUMBER or STRING */ 1949 short nte_index; /* index of associated variable in its array */ 1950 short nte_link; /* index in table of next hash, or -1 */ 1951 } name_table_data; 1952 1953 typedef struct 1954 { 1955 short from; 1956 short to; 1957 short source; 1958 } alias_table_data; 1959 1960 /* comp_userdefs.c */ 1961 typedef struct { 1962 short ute_name; /* offset of name to hash on */ 1963 unsigned ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ 1964 unsigned ute_argc; /* number of parameters */ 1965 unsigned ute_args; /* bit-mask for string parameters */ 1966 short ute_index; /* index of associated variable in its array */ 1967 short ute_link; /* index in table of next hash, or -1 */ 1968 } user_table_data; 1969 1970 /* doupdate.c */ 1971 #if USE_XMC_SUPPORT 1972 extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t); 1973 #endif 1974 1975 /* hardscroll.c */ 1976 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 1977 extern NCURSES_EXPORT(void) _nc_linedump (void); 1978 #endif 1979 1980 /* lib_acs.c */ 1981 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */ 1982 extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); 1983 1984 /* lib_addch.c */ 1985 #if USE_WIDEC_SUPPORT 1986 extern NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch); 1987 #endif 1988 1989 /* lib_addstr.c */ 1990 #if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 1991 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *); 1992 #endif 1993 1994 /* lib_color.c */ 1995 extern NCURSES_EXPORT(int) _nc_init_color(SCREEN *, int, int, int, int); 1996 extern NCURSES_EXPORT(int) _nc_init_pair(SCREEN *, int, int, int); 1997 extern NCURSES_EXPORT(int) _nc_pair_content(SCREEN *, int, int *, int *); 1998 extern NCURSES_EXPORT(bool) _nc_reset_colors(void); 1999 extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int); 2000 extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int); 2001 2002 #define ReservePairs(sp,want) \ 2003 if ((sp->_color_pairs == 0) || (want >= sp->_pair_alloc)) \ 2004 _nc_reserve_pairs(sp, want) 2005 2006 /* lib_getch.c */ 2007 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *)); 2008 2009 /* lib_insch.c */ 2010 extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype); 2011 2012 /* lib_mvcur.c */ 2013 #define INFINITY 1000000 /* cost: too high to use */ 2014 2015 extern NCURSES_EXPORT(int) _nc_mvcur(int yold, int xold, int ynew, int xnew); 2016 2017 extern NCURSES_EXPORT(void) _nc_mvcur_init (void); 2018 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void); 2019 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void); 2020 2021 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int); 2022 2023 extern NCURSES_EXPORT(void) _nc_screen_init (void); 2024 extern NCURSES_EXPORT(void) _nc_screen_resume (void); 2025 extern NCURSES_EXPORT(void) _nc_screen_wrap (void); 2026 2027 /* lib_mouse.c */ 2028 extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *); 2029 2030 /* lib_mvcur.c */ 2031 #define INFINITY 1000000 /* cost: too high to use */ 2032 #define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */ 2033 2034 /* lib_setup.c */ 2035 extern NCURSES_EXPORT(char *) _nc_get_locale(void); 2036 extern NCURSES_EXPORT(int) _nc_unicode_locale(void); 2037 extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); 2038 extern NCURSES_EXPORT(int) _nc_setupterm(const char *, int, int *, int); 2039 extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); 2040 2041 #ifdef USE_PTHREADS 2042 extern NCURSES_EXPORT(SCREEN *) _nc_find_prescr(void); 2043 extern NCURSES_EXPORT(void) _nc_forget_prescr(void); 2044 #else 2045 #define _nc_find_prescr() _nc_prescreen.allocated 2046 #define _nc_forget_prescr() _nc_prescreen.allocated = 0 2047 #endif 2048 2049 /* lib_set_term.c */ 2050 extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); 2051 2052 /* lib_setup.c */ 2053 #define ExitTerminfo(code) exit_terminfo(code) 2054 2055 #define SETUP_FAIL ERR 2056 2057 #define ret_error(rc, fmt, p, q) if (errret) {\ 2058 *errret = rc;\ 2059 q;\ 2060 returnCode(SETUP_FAIL);\ 2061 } else {\ 2062 fprintf(stderr, fmt, p);\ 2063 q;\ 2064 ExitTerminfo(EXIT_FAILURE);\ 2065 } 2066 2067 #define ret_error1(rc, fmt, p, q) ret_error(rc, "'%s': " fmt, p, q) 2068 2069 #define ret_error0(rc, msg) if (errret) {\ 2070 *errret = rc;\ 2071 returnCode(SETUP_FAIL);\ 2072 } else {\ 2073 fprintf(stderr, msg);\ 2074 ExitTerminfo(EXIT_FAILURE);\ 2075 } 2076 2077 /* lib_tstp.c */ 2078 #if USE_SIGWINCH 2079 extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *); 2080 #else 2081 #define _nc_handle_sigwinch(a) /* nothing */ 2082 #endif 2083 2084 /* lib_wacs.c */ 2085 #if USE_WIDEC_SUPPORT 2086 extern NCURSES_EXPORT(void) _nc_init_wacs(void); 2087 #endif 2088 2089 typedef struct { 2090 char *s_head; /* beginning of the string (may be null) */ 2091 char *s_tail; /* end of the string (may be null) */ 2092 size_t s_size; /* current remaining size available */ 2093 size_t s_init; /* total size available */ 2094 } string_desc; 2095 2096 /* strings.c */ 2097 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t); 2098 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t); 2099 extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, const string_desc *); 2100 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *); 2101 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *); 2102 2103 #if !HAVE_STRSTR 2104 #define strstr _nc_strstr 2105 extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *); 2106 #endif 2107 2108 /* safe_sprintf.c */ 2109 extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list); 2110 2111 /* tries.c */ 2112 extern NCURSES_EXPORT(int) _nc_add_to_try (TRIES **, const char *, unsigned); 2113 extern NCURSES_EXPORT(char *) _nc_expand_try (TRIES *, unsigned, int *, size_t); 2114 extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned); 2115 extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); 2116 2117 /* elsewhere ... */ 2118 extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *); 2119 extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void); 2120 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); 2121 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t); 2122 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *); 2123 extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int); 2124 extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *); 2125 extern NCURSES_EXPORT(char *) _nc_trace_mmask_t (SCREEN *, mmask_t); 2126 extern NCURSES_EXPORT(int) _nc_access (const char *, int); 2127 extern NCURSES_EXPORT(int) _nc_baudrate (int); 2128 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *); 2129 extern NCURSES_EXPORT(int) _nc_getenv_num (const char *); 2130 extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int); 2131 extern NCURSES_EXPORT(int) _nc_ospeed (int); 2132 extern NCURSES_EXPORT(int) _nc_outch (int); 2133 extern NCURSES_EXPORT(int) _nc_putchar (int); 2134 extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *); 2135 extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *); 2136 extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 *const); 2137 extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *); 2138 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); 2139 extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); 2140 extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *); 2141 extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const); 2142 extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); 2143 extern NCURSES_EXPORT(void) _nc_flush (void); 2144 extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE2 *); 2145 extern NCURSES_EXPORT(void) _nc_freeall (void); 2146 extern NCURSES_EXPORT(void) _nc_hash_map (void); 2147 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *); 2148 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *); 2149 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i); 2150 extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *); 2151 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot); 2152 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void); 2153 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int); 2154 extern NCURSES_EXPORT(void) _nc_setenv_num (const char *, int); 2155 extern NCURSES_EXPORT(void) _nc_signal_handler (int); 2156 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *); 2157 extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *); 2158 2159 #if NCURSES_EXT_NUMBERS 2160 extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *); 2161 #else 2162 #define _nc_fallback2(tp) _nc_fallback(tp) 2163 #endif 2164 2165 extern NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *, const TERMTYPE *); 2166 2167 #if NCURSES_EXT_NUMBERS 2168 extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *); 2169 extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *); 2170 #else 2171 #define _nc_copy_termtype2(dst,src) _nc_copy_termtype((dst),(src)) 2172 #define _nc_export_termtype2(dst,src) /* nothing */ 2173 #define _nc_free_termtype2(t) _nc_free_termtype(t) 2174 /* also... */ 2175 #define _nc_read_entry2 _nc_read_entry 2176 #endif 2177 2178 #if NO_LEAKS 2179 extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void); 2180 extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void); 2181 extern NCURSES_EXPORT(void) _nc_codes_leaks(void); 2182 extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void); 2183 extern NCURSES_EXPORT(void) _nc_comp_error_leaks(void); 2184 extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void); 2185 extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void); 2186 extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void); 2187 extern NCURSES_EXPORT(void) _nc_keyname_leaks(void); 2188 extern NCURSES_EXPORT(void) _nc_names_leaks(void); 2189 extern NCURSES_EXPORT(void) _nc_tgetent_leak(const TERMINAL *); 2190 extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void); 2191 #endif 2192 2193 #if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 2194 extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T); 2195 extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T); 2196 extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, int const, int const, NCURSES_CH_T); 2197 #endif 2198 2199 #if USE_WIDEC_SUPPORT 2200 extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *); 2201 #endif 2202 2203 #if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) 2204 extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *); 2205 #endif 2206 2207 #if USE_SIZECHANGE 2208 extern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *); 2209 #endif 2210 2211 #if HAVE_RESIZETERM 2212 extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *); 2213 #else 2214 #define _nc_resize_margins(wp) /* nothing */ 2215 #endif 2216 2217 #ifdef NCURSES_WGETCH_EVENTS 2218 extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); 2219 #else 2220 #define wgetch_events(win, evl) wgetch(win) 2221 #define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen) 2222 #endif 2223 2224 /* 2225 * Wide-character macros to hide some platform-differences. 2226 */ 2227 #if USE_WIDEC_SUPPORT 2228 2229 #if defined(_NC_WINDOWS) && !defined(_NC_MSC) && !defined(EXP_WIN32_DRIVER) 2230 /* 2231 * MinGW has wide-character functions, but they do not work correctly. 2232 */ 2233 extern int __MINGW_NOTHROW _nc_wctomb(char *, wchar_t); 2234 #define wctomb(s,wc) _nc_wctomb(s,wc) 2235 #define wcrtomb(s,wc,n) _nc_wctomb(s,wc) 2236 2237 extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); 2238 #define mbtowc(pwc,s,n) _nc_mbtowc(pwc,s,n) 2239 2240 extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); 2241 #define mblen(s,n) _nc_mblen(s, n) 2242 2243 #endif /* _NC_WINDOWS && !_NC_MSC */ 2244 2245 #if defined(_NC_WINDOWS) || defined(_NC_MINGW) 2246 /* see wcwidth.c */ 2247 extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t); 2248 #define wcwidth(ucs) _nc_wcwidth(ucs) 2249 #endif 2250 2251 #if HAVE_MBTOWC && HAVE_MBLEN 2252 #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) 2253 #define count_mbytes(buffer,length,state) mblen(buffer,length) 2254 #define check_mbytes(wch,buffer,length,state) \ 2255 (int) mbtowc(&(wch), buffer, length) 2256 #define state_unused 2257 #elif HAVE_MBRTOWC && HAVE_MBRLEN 2258 #define reset_mbytes(state) init_mb(state) 2259 #define count_mbytes(buffer,length,state) mbrlen(buffer,length,&(state)) 2260 #define check_mbytes(wch,buffer,length,state) \ 2261 (int) mbrtowc(&(wch), buffer, length, &(state)) 2262 #else 2263 make an error 2264 #endif 2265 2266 #endif /* USE_WIDEC_SUPPORT */ 2267 2268 /* 2269 * Not everyone has vsscanf(), but we'd like to use it for scanw(). 2270 */ 2271 #if !HAVE_VSSCANF 2272 extern int vsscanf(const char *str, const char *format, va_list __arg); 2273 #endif 2274 2275 /* scroll indices */ 2276 extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; 2277 2278 #define USE_SETBUF_0 0 2279 2280 #define NC_OUTPUT(sp) ((sp != 0 && sp->_ofp != 0) ? sp->_ofp : stdout) 2281 2282 /* 2283 * On systems with a broken linker, define 'SP' as a function to force the 2284 * linker to pull in the data-only module with 'SP'. 2285 */ 2286 #define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1) 2287 2288 #if BROKEN_LINKER 2289 #define SP _nc_screen() 2290 extern NCURSES_EXPORT(SCREEN *) _nc_screen (void); 2291 extern NCURSES_EXPORT(int) _nc_alloc_screen (void); 2292 extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); 2293 #define CURRENT_SCREEN _nc_screen() 2294 #else 2295 /* current screen is private data; avoid possible linking conflicts too */ 2296 extern NCURSES_EXPORT_VAR(SCREEN *) SP; 2297 #define CURRENT_SCREEN SP 2298 #define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0) 2299 #define _nc_set_screen(sp) SP = sp 2300 #endif 2301 2302 #if NCURSES_SP_FUNCS 2303 #define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr()) 2304 #else 2305 #define CURRENT_SCREEN_PRE CURRENT_SCREEN 2306 #endif 2307 2308 /* 2309 * We don't want to use the lines or columns capabilities internally, because 2310 * if the application is running multiple screens under X, it is quite possible 2311 * they could all have type xterm but have different sizes! So... 2312 */ 2313 #define screen_lines(sp) (sp)->_lines 2314 #define screen_columns(sp) (sp)->_columns 2315 2316 extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int); 2317 extern NCURSES_EXPORT(int) _nc_format_slks (NCURSES_SP_DCLx int _c); 2318 2319 /* 2320 * Some constants related to SLK's 2321 */ 2322 #define MAX_SKEY_OLD 8 /* count of soft keys */ 2323 #define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */ 2324 #define MAX_SKEY_PC 12 /* This is what most PC's have */ 2325 #define MAX_SKEY_LEN_PC 5 2326 2327 /* Macro to check whether or not we use a standard format */ 2328 #define SLK_STDFMT(fmt) (fmt < 3) 2329 /* Macro to determine height of label window */ 2330 #define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2)) 2331 2332 #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) 2333 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) 2334 2335 /* 2336 * Common error messages 2337 */ 2338 #define MSG_NO_MEMORY "Out of memory" 2339 #define MSG_NO_INPUTS "Premature EOF" 2340 2341 extern NCURSES_EXPORT(int) _nc_set_tty_mode(TTY *); 2342 extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); 2343 2344 /* timed_wait flag definitions */ 2345 #define TW_NONE 0 2346 #define TW_INPUT 1 2347 #define TW_MOUSE 2 2348 #define TW_ANY (TW_INPUT | TW_MOUSE) 2349 #define TW_EVENT 4 2350 2351 #define SetSafeOutcWrapper(outc) \ 2352 SCREEN* sp = CURRENT_SCREEN; \ 2353 struct screen outc_wrapper; \ 2354 if (sp==0) { \ 2355 sp = &outc_wrapper; \ 2356 memset(sp,0,sizeof(struct screen)); \ 2357 sp->_outch = _nc_outc_wrapper; \ 2358 }\ 2359 sp->jump = outc 2360 2361 #ifdef USE_TERM_DRIVER 2362 2363 typedef struct _termInfo 2364 { 2365 bool caninit; 2366 2367 bool hascolor; 2368 bool initcolor; 2369 bool canchange; 2370 2371 int tabsize; 2372 2373 int maxcolors; 2374 int maxpairs; 2375 int nocolorvideo; 2376 2377 int numbuttons; 2378 int numlabels; 2379 int labelwidth; 2380 int labelheight; 2381 2382 const color_t* defaultPalette; 2383 } TerminalInfo; 2384 2385 typedef struct term_driver { 2386 bool isTerminfo; 2387 const char* (*td_name)(struct DriverTCB*); 2388 bool (*td_CanHandle)(struct DriverTCB*, const char*, int*); 2389 void (*td_init)(struct DriverTCB*); 2390 void (*td_release)(struct DriverTCB*); 2391 int (*td_size)(struct DriverTCB*, int* Line, int *Cols); 2392 int (*td_sgmode)(struct DriverTCB*, int setFlag, TTY*); 2393 chtype (*td_conattr)(struct DriverTCB*); 2394 int (*td_hwcur)(struct DriverTCB*, int yold, int xold, int y, int x); 2395 int (*td_mode)(struct DriverTCB*, int progFlag, int defFlag); 2396 bool (*td_rescol)(struct DriverTCB*); 2397 bool (*td_rescolors)(struct DriverTCB*); 2398 void (*td_color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int)); 2399 int (*td_doBeepOrFlash)(struct DriverTCB*, int); 2400 void (*td_initpair)(struct DriverTCB*, int, int, int); 2401 void (*td_initcolor)(struct DriverTCB*, int, int, int, int); 2402 void (*td_docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int)); 2403 void (*td_initmouse)(struct DriverTCB*); 2404 int (*td_testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*)); 2405 void (*td_setfilter)(struct DriverTCB*); 2406 void (*td_hwlabel)(struct DriverTCB*, int, char*); 2407 void (*td_hwlabelOnOff)(struct DriverTCB*, int); 2408 int (*td_update)(struct DriverTCB*); 2409 int (*td_defaultcolors)(struct DriverTCB*, int, int); 2410 int (*td_print)(struct DriverTCB*, char*, int); 2411 int (*td_getsize)(struct DriverTCB*, int*, int*); 2412 int (*td_setsize)(struct DriverTCB*, int, int); 2413 void (*td_initacs)(struct DriverTCB*, chtype*, chtype*); 2414 void (*td_scinit)(SCREEN *); 2415 void (*td_scexit)(SCREEN *); 2416 int (*td_twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*)); 2417 int (*td_read)(struct DriverTCB*, int*); 2418 int (*td_nap)(struct DriverTCB*, int); 2419 int (*td_kpad)(struct DriverTCB*, int); 2420 int (*td_kyOk)(struct DriverTCB*, int, int); 2421 bool (*td_kyExist)(struct DriverTCB*, int); 2422 int (*td_cursorSet)(struct DriverTCB*, int); 2423 } TERM_DRIVER; 2424 2425 typedef struct DriverTCB 2426 { 2427 TERMINAL term; /* needs to be the first Element !!! */ 2428 TERM_DRIVER* drv; /* The driver for that Terminal */ 2429 SCREEN* csp; /* The screen that owns that Terminal */ 2430 TerminalInfo info; /* Driver independent core capabilities of the Terminal */ 2431 void* prop; /* Driver dependent property storage to be used by the Driver */ 2432 long magic; 2433 } TERMINAL_CONTROL_BLOCK; 2434 2435 #define NCDRV_MAGIC(id) (0x47110000 | (id&0xffff)) 2436 #define NCDRV_TINFO 0x01 2437 #define NCDRV_WINCONSOLE 0x02 2438 2439 #define TCBOf(sp) ((TERMINAL_CONTROL_BLOCK*)(TerminalOf(sp))) 2440 #define InfoOf(sp) TCBOf(sp)->info 2441 #define CallDriver(sp,method) TCBOf(sp)->drv->method(TCBOf(sp)) 2442 #define CallDriver_1(sp,method,arg1) TCBOf(sp)->drv->method(TCBOf(sp),arg1) 2443 #define CallDriver_2(sp,method,arg1,arg2) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2) 2444 #define CallDriver_3(sp,method,arg1,arg2,arg3) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3) 2445 #define CallDriver_4(sp,method,arg1,arg2,arg3,arg4) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3,arg4) 2446 2447 extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette; 2448 extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette; 2449 2450 extern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*); 2451 extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *); 2452 #endif /* USE_TERM_DRIVER */ 2453 2454 /* 2455 * Entrypoints which are actually provided in the terminal driver, which would 2456 * be an sp-name otherwise. 2457 */ 2458 #ifdef USE_TERM_DRIVER 2459 #define TINFO_HAS_KEY _nc_tinfo_has_key 2460 #define TINFO_DOUPDATE _nc_tinfo_doupdate 2461 #define TINFO_MVCUR _nc_tinfo_mvcur 2462 extern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int); 2463 extern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *); 2464 extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); 2465 #else 2466 #define TINFO_HAS_KEY NCURSES_SP_NAME(has_key) 2467 #define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate) 2468 #define TINFO_MVCUR NCURSES_SP_NAME(_nc_mvcur) 2469 #endif 2470 2471 #if defined(EXP_WIN32_DRIVER) 2472 #include <nc_win32.h> 2473 #endif 2474 2475 /* 2476 * Entrypoints using an extra parameter with the terminal driver. 2477 */ 2478 #ifdef USE_TERM_DRIVER 2479 extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); 2480 extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int); 2481 #define TINFO_GET_SIZE(sp, tp, lp, cp) \ 2482 _nc_get_screensize(sp, tp, lp, cp) 2483 #define TINFO_SET_CURTERM(sp, tp) \ 2484 NCURSES_SP_NAME(set_curterm)(sp, tp) 2485 #define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ 2486 _nc_setupterm_ex(tpp, name, fd, err, reuse) 2487 #else /* !USE_TERM_DRIVER */ 2488 extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); 2489 #define TINFO_GET_SIZE(sp, tp, lp, cp) \ 2490 _nc_get_screensize(sp, lp, cp) 2491 #define TINFO_SET_CURTERM(sp, tp) \ 2492 set_curterm(tp) 2493 #define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \ 2494 _nc_setupterm(name, fd, err, reuse) 2495 #endif /* !USE_TERM_DRIVER */ 2496 2497 #ifdef EXP_WIN32_DRIVER 2498 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; 2499 #else 2500 #ifdef USE_TERM_DRIVER 2501 #if defined(USE_WIN32CON_DRIVER) 2502 #include <nc_mingw.h> 2503 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; 2504 extern NCURSES_EXPORT(int) _nc_mingw_isatty(int fd); 2505 extern NCURSES_EXPORT(int) _nc_mingw_isconsole(int fd); 2506 extern NCURSES_EXPORT(int) _nc_mingw_console_read( 2507 SCREEN *sp, 2508 HANDLE fd, 2509 int *buf); 2510 extern NCURSES_EXPORT(int) _nc_mingw_testmouse( 2511 SCREEN * sp, 2512 HANDLE fd, 2513 int delay EVENTLIST_2nd(_nc_eventlist*)); 2514 #else 2515 #endif 2516 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; 2517 #endif /* USE_TERM_DRIVER */ 2518 #endif /* EXP_WIN32_DRIVER */ 2519 2520 #if defined(USE_TERM_DRIVER) && defined(EXP_WIN32_DRIVER) 2521 #define NC_ISATTY(fd) (0 != _nc_console_isatty(fd)) 2522 #elif defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER) 2523 #define NC_ISATTY(fd) _nc_mingw_isatty(fd) 2524 #else 2525 #define NC_ISATTY(fd) isatty(fd) 2526 #endif 2527 2528 #ifdef USE_TERM_DRIVER 2529 # define IsTermInfo(sp) ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo))) 2530 # define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp)) 2531 # if defined(EXP_WIN32_DRIVER) 2532 # define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes)) 2533 # elif defined(USE_WIN32CON_DRIVER) 2534 # define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_mingw_isconsole(TerminalOf(sp)->Filedes)) 2535 # else 2536 # define IsTermInfoOnConsole(sp) FALSE 2537 # endif 2538 #else 2539 # define IsTermInfo(sp) TRUE 2540 # define HasTInfoTerminal(sp) (0 != TerminalOf(sp)) 2541 # if defined(EXP_WIN32_DRIVER) 2542 # define IsTermInfoOnConsole(sp) _nc_console_test(TerminalOf(sp)->Filedes) 2543 # else 2544 # define IsTermInfoOnConsole(sp) FALSE 2545 # endif 2546 #endif 2547 2548 #define IsValidTIScreen(sp) (HasTInfoTerminal(sp)) 2549 2550 /* 2551 * Exported entrypoints beyond the published API 2552 */ 2553 #if NCURSES_SP_FUNCS 2554 extern NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN*); 2555 extern NCURSES_EXPORT(WINDOW *) _nc_newscr_of(SCREEN*); 2556 extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*); 2557 extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int); 2558 2559 #if USE_REENTRANT 2560 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*); 2561 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*); 2562 #endif 2563 2564 #if NCURSES_EXT_FUNCS 2565 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int); 2566 #endif 2567 2568 /* 2569 * We put the safe versions of various calls here as they are not published 2570 * part of the API up to now 2571 */ 2572 extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp); 2573 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int); 2574 extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*); 2575 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list); 2576 extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int); 2577 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*); 2578 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int); 2579 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int); 2580 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mvcur)(SCREEN*, int, int, int, int); 2581 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int); 2582 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putchar)(SCREEN*, int); 2583 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*); 2584 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *); 2585 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int)); 2586 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int); 2587 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*); 2588 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int); 2589 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *); 2590 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC); 2591 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t); 2592 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*); 2593 extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int); 2594 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall)(SCREEN*); 2595 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_hash_map)(SCREEN*); 2596 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_init_acs)(SCREEN*); 2597 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i); 2598 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init)(SCREEN*); 2599 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume)(SCREEN*); 2600 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_wrap)(SCREEN*); 2601 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_init)(SCREEN*); 2602 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_resume)(SCREEN*); 2603 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*); 2604 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot); 2605 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*); 2606 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, int); 2607 2608 extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp); 2609 2610 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 2611 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*); 2612 #endif 2613 2614 #if USE_WIDEC_SUPPORT 2615 extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *); 2616 #endif 2617 2618 #endif /* NCURSES_SP_FUNCS */ 2619 2620 #if NCURSES_SP_FUNCS 2621 2622 #define safe_keyname NCURSES_SP_NAME(keyname) 2623 #define safe_unctrl NCURSES_SP_NAME(unctrl) 2624 #define safe_ungetch NCURSES_SP_NAME(ungetch) 2625 2626 #else 2627 2628 #define safe_keyname _nc_keyname 2629 #define safe_unctrl _nc_unctrl 2630 #define safe_ungetch _nc_ungetch 2631 2632 extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int); 2633 extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int); 2634 extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype); 2635 2636 #endif 2637 2638 #ifdef EXP_XTERM_1005 2639 extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned); 2640 extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned); 2641 #endif 2642 2643 #ifdef __cplusplus 2644 } 2645 #endif 2646 2647 /* *INDENT-ON* */ 2648 2649 #endif /* CURSES_PRIV_H */ 2650