1 /* $OpenBSD: curses.priv.h,v 1.28 2000/07/10 03:06:10 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * 5 * * 6 * Permission is hereby granted, free of charge, to any person obtaining a * 7 * copy of this software and associated documentation files (the * 8 * "Software"), to deal in the Software without restriction, including * 9 * without limitation the rights to use, copy, modify, merge, publish, * 10 * distribute, distribute with modifications, sublicense, and/or sell * 11 * copies of the Software, and to permit persons to whom the Software is * 12 * furnished to do so, subject to the following conditions: * 13 * * 14 * The above copyright notice and this permission notice shall be included * 15 * in all copies or substantial portions of the Software. * 16 * * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 24 * * 25 * Except as contained in this notice, the name(s) of the above copyright * 26 * holders shall not be used in advertising or otherwise to promote the * 27 * sale, use or other dealings in this Software without prior written * 28 * authorization. * 29 ****************************************************************************/ 30 31 /**************************************************************************** 32 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 33 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 34 ****************************************************************************/ 35 36 37 /* 38 * $From: curses.priv.h,v 1.162 2000/06/24 21:06:10 tom Exp $ 39 * 40 * curses.priv.h 41 * 42 * Header file for curses library objects which are private to 43 * the library. 44 * 45 */ 46 47 #ifndef CURSES_PRIV_H 48 #define CURSES_PRIV_H 1 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 #include <ncurses_cfg.h> 55 56 #if USE_RCS_IDS 57 #define MODULE_ID(id) static const char Ident[] = id; 58 #else 59 #define MODULE_ID(id) /*nothing*/ 60 #endif 61 62 #include <stdlib.h> 63 #include <string.h> 64 #include <sys/types.h> 65 66 #if HAVE_UNISTD_H 67 #include <unistd.h> 68 #endif 69 70 #if HAVE_SYS_BSDTYPES_H 71 #include <sys/bsdtypes.h> /* needed for ISC */ 72 #endif 73 74 #if HAVE_LIMITS_H 75 # include <limits.h> 76 #elif HAVE_SYS_PARAM_H 77 # include <sys/param.h> 78 #endif 79 80 #ifndef PATH_MAX 81 # if defined(_POSIX_PATH_MAX) 82 # define PATH_MAX _POSIX_PATH_MAX 83 # elif defined(MAXPATHLEN) 84 # define PATH_MAX MAXPATHLEN 85 # else 86 # define PATH_MAX 255 /* the Posix minimum path-size */ 87 # endif 88 #endif 89 90 #include <assert.h> 91 #include <stdio.h> 92 93 #include <errno.h> 94 95 #if DECL_ERRNO 96 extern int errno; 97 #endif 98 99 #include <nc_panel.h> 100 101 /* Some systems have a broken 'select()', but workable 'poll()'. Use that */ 102 #if HAVE_WORKING_POLL 103 #define USE_FUNC_POLL 1 104 #ifdef HAVE_POLL_H 105 #include <poll.h> 106 #else 107 #include <sys/poll.h> 108 #endif 109 #else 110 #define USE_FUNC_POLL 0 111 #endif 112 113 /* Alessandro Rubini's GPM (general-purpose mouse) */ 114 #if HAVE_LIBGPM && HAVE_GPM_H 115 #define USE_GPM_SUPPORT 1 116 #else 117 #define USE_GPM_SUPPORT 0 118 #endif 119 120 /* QNX mouse support */ 121 #if defined(__QNX__) && !defined(__QNXNTO__) 122 #define USE_QNX_MOUSE 1 123 #else 124 #define USE_QNX_MOUSE 0 125 #endif 126 127 /* EMX mouse support */ 128 #ifdef __EMX__ 129 #define USE_EMX_MOUSE 130 #endif 131 132 #define DEFAULT_MAXCLICK 166 133 #define EV_MAX 8 /* size of mouse circular event queue */ 134 135 /* 136 * If we don't have signals to support it, don't add a sigwinch handler. 137 * In any case, resizing is an extended feature. Use it if we've got it. 138 */ 139 #ifndef NCURSES_EXT_FUNCS 140 #undef HAVE_SIZECHANGE 141 #endif 142 143 #if HAVE_SIZECHANGE 144 #define USE_SIZECHANGE 1 145 #else 146 #undef USE_SIGWINCH 147 #endif 148 149 /* 150 * Not all platforms have memmove; some have an equivalent bcopy. (Some may 151 * have neither). 152 */ 153 #if USE_OK_BCOPY 154 #define memmove(d,s,n) bcopy(s,d,n) 155 #elif USE_MY_MEMMOVE 156 #define memmove(d,s,n) _nc_memmove(d,s,n) 157 extern void * _nc_memmove(void *, const void *, size_t); 158 #endif 159 160 /* 161 * Scroll hints are useless when hashmap is used 162 */ 163 #if !USE_SCROLL_HINTS 164 #if !USE_HASHMAP 165 #define USE_SCROLL_HINTS 1 166 #else 167 #define USE_SCROLL_HINTS 0 168 #endif 169 #endif 170 171 #if USE_SCROLL_HINTS 172 #define if_USE_SCROLL_HINTS(stmt) stmt 173 #else 174 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/ 175 #endif 176 177 /* 178 * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only 179 * when we're throwing control codes at the screen at high volume. To see 180 * this, re-enable USE_HARD_TABS and run worm for a while. Other systems 181 * probably don't want to define this either due to uncertainties about tab 182 * delays and expansion in raw mode. 183 */ 184 185 struct tries { 186 struct tries *child; /* ptr to child. NULL if none */ 187 struct tries *sibling; /* ptr to sibling. NULL if none */ 188 unsigned char ch; /* character at this node */ 189 unsigned short value; /* code of string so far. 0 if none. */ 190 }; 191 192 /* 193 * Definitions for color pairs 194 */ 195 #define C_SHIFT 8 /* we need more bits than there are colors */ 196 #define C_MASK ((1 << C_SHIFT) - 1) 197 198 #define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK)) 199 200 /* 201 * Common/troublesome character definitions 202 */ 203 #define L_BRACE '{' 204 #define R_BRACE '}' 205 #define S_QUOTE '\'' 206 207 /* 208 * Structure for palette tables 209 */ 210 211 typedef struct 212 { 213 short red, green, blue; 214 } 215 color_t; 216 217 #define MAXCOLUMNS 135 218 #define MAXLINES 66 219 #define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */ 220 221 #define ACS_LEN 128 222 223 #define WINDOWLIST struct _win_list 224 225 #include <curses.h> /* we'll use -Ipath directive to get the right one! */ 226 227 /* 228 * Structure for soft labels. 229 */ 230 231 typedef struct 232 { 233 char *text; /* text for the label */ 234 char *form_text; /* formatted text (left/center/...) */ 235 int x; /* x coordinate of this field */ 236 char dirty; /* this label has changed */ 237 char visible; /* field is visible */ 238 } slk_ent; 239 240 typedef struct { 241 char dirty; /* all labels have changed */ 242 char hidden; /* soft labels are hidden */ 243 struct _win_st *win; 244 slk_ent *ent; 245 char* buffer; /* buffer for labels */ 246 short maxlab; /* number of available labels */ 247 short labcnt; /* number of allocated labels */ 248 short maxlen; /* length of labels */ 249 chtype attr; /* soft label attribute */ 250 } SLK; 251 252 struct screen { 253 int _ifd; /* input file ptr for screen */ 254 FILE *_ofp; /* output file ptr for screen */ 255 char *_setbuf; /* buffered I/O for output */ 256 int _buffered; /* setvbuf uses _setbuf data */ 257 int _checkfd; /* filedesc for typeahead check */ 258 struct term *_term; /* terminal type information */ 259 short _lines; /* screen lines */ 260 short _columns; /* screen columns */ 261 short _lines_avail; /* lines available for stdscr */ 262 short _topstolen; /* lines stolen from top */ 263 264 WINDOW *_curscr; /* current screen */ 265 WINDOW *_newscr; /* virtual screen to be updated to */ 266 WINDOW *_stdscr; /* screen's full-window context */ 267 268 struct tries *_keytry; /* "Try" for use with keypad mode */ 269 struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */ 270 int _tried; /* keypad mode was initialized */ 271 272 unsigned int _fifo[FIFO_SIZE]; /* input push-back buffer */ 273 short _fifohead, /* head of fifo queue */ 274 _fifotail, /* tail of fifo queue */ 275 _fifopeek, /* where to peek for next char */ 276 _fifohold; /* set if breakout marked */ 277 278 int _endwin; /* are we out of window mode? */ 279 unsigned long _current_attr; /* terminal attribute current set */ 280 int _coloron; /* is color enabled? */ 281 int _cursor; /* visibility of the cursor */ 282 int _cursrow; /* physical cursor row */ 283 int _curscol; /* physical cursor column */ 284 int _nl; /* True if NL -> CR/NL is on */ 285 int _raw; /* True if in raw mode */ 286 int _cbreak; /* 1 if in cbreak mode */ 287 /* > 1 if in halfdelay mode */ 288 int _echo; /* True if echo on */ 289 int _use_meta; /* use the meta key? */ 290 SLK *_slk; /* ptr to soft key struct / NULL */ 291 int slk_format; /* selected format for this screen */ 292 /* cursor movement costs; units are 10ths of milliseconds */ 293 #ifdef NCURSES_NO_PADDING 294 int _no_padding; /* flag to set if padding disabled */ 295 #endif 296 int _char_padding; /* cost of character put */ 297 int _cr_cost; /* cost of (carriage_return) */ 298 int _cup_cost; /* cost of (cursor_address) */ 299 int _home_cost; /* cost of (cursor_home) */ 300 int _ll_cost; /* cost of (cursor_to_ll) */ 301 #if USE_HARD_TABS 302 int _ht_cost; /* cost of (tab) */ 303 int _cbt_cost; /* cost of (backtab) */ 304 #endif /* USE_HARD_TABS */ 305 int _cub1_cost; /* cost of (cursor_left) */ 306 int _cuf1_cost; /* cost of (cursor_right) */ 307 int _cud1_cost; /* cost of (cursor_down) */ 308 int _cuu1_cost; /* cost of (cursor_up) */ 309 int _cub_cost; /* cost of (parm_cursor_left) */ 310 int _cuf_cost; /* cost of (parm_cursor_right) */ 311 int _cud_cost; /* cost of (parm_cursor_down) */ 312 int _cuu_cost; /* cost of (parm_cursor_up) */ 313 int _hpa_cost; /* cost of (column_address) */ 314 int _vpa_cost; /* cost of (row_address) */ 315 /* used in tty_update.c, must be chars */ 316 int _ed_cost; /* cost of (clr_eos) */ 317 int _el_cost; /* cost of (clr_eol) */ 318 int _el1_cost; /* cost of (clr_bol) */ 319 int _dch1_cost; /* cost of (delete_character) */ 320 int _ich1_cost; /* cost of (insert_character) */ 321 int _dch_cost; /* cost of (parm_dch) */ 322 int _ich_cost; /* cost of (parm_ich) */ 323 int _ech_cost; /* cost of (erase_chars) */ 324 int _rep_cost; /* cost of (repeat_char) */ 325 int _hpa_ch_cost; /* cost of (column_address) */ 326 int _cup_ch_cost; /* cost of (cursor_address) */ 327 int _cuf_ch_cost; /* cost of (parm_cursor_right) */ 328 int _inline_cost; /* cost of inline-move */ 329 int _smir_cost; /* cost of (enter_insert_mode) */ 330 int _rmir_cost; /* cost of (exit_insert_mode) */ 331 int _ip_cost; /* cost of (insert_padding) */ 332 /* used in lib_mvcur.c */ 333 char * _address_cursor; 334 int _carriage_return_length; 335 int _cursor_home_length; 336 int _cursor_to_ll_length; 337 int _scrolling; /* 1 if terminal's smart enough to */ 338 339 /* used in lib_color.c */ 340 color_t *_color_table; /* screen's color palette */ 341 int _color_count; /* count of colors in palette */ 342 unsigned short *_color_pairs; /* screen's color pair list */ 343 int _pair_count; /* count of color pairs */ 344 #ifdef NCURSES_EXT_FUNCS 345 bool _default_color; /* use default colors */ 346 bool _has_sgr_39_49; /* has ECMA default color support */ 347 int _default_fg; /* assumed default foreground */ 348 int _default_bg; /* assumed default background */ 349 #endif 350 chtype _xmc_suppress; /* attributes to suppress if xmc */ 351 chtype _xmc_triggers; /* attributes to process if xmc */ 352 chtype _acs_map[ACS_LEN]; 353 354 /* used in lib_vidattr.c */ 355 bool _use_rmso; /* true if we may use 'rmso' */ 356 bool _use_rmul; /* true if we may use 'rmul' */ 357 358 /* 359 * These data correspond to the state of the idcok() and idlok() 360 * functions. A caveat is in order here: the XSI and SVr4 361 * documentation specify that these functions apply to the window which 362 * is given as an argument. However, ncurses implements this logic 363 * only for the newscr/curscr update process, _not_ per-window. 364 */ 365 bool _nc_sp_idlok; 366 bool _nc_sp_idcok; 367 #define _nc_idlok SP->_nc_sp_idlok 368 #define _nc_idcok SP->_nc_sp_idcok 369 370 /* 371 * These are the data that support the mouse interface. 372 */ 373 int _maxclick; 374 bool (*_mouse_event) (SCREEN *); 375 bool (*_mouse_inline)(SCREEN *); 376 bool (*_mouse_parse) (int); 377 void (*_mouse_resume)(SCREEN *); 378 void (*_mouse_wrap) (SCREEN *); 379 int _mouse_fd; /* file-descriptor, if any */ 380 381 /* 382 * This supports automatic resizing 383 */ 384 #if USE_SIZECHANGE 385 int (*_resize)(int,int); 386 #endif 387 388 /* 389 * These are data that support the proper handling of the panel stack on an 390 * per screen basis. 391 */ 392 struct panelhook _panelHook; 393 /* 394 * Linked-list of all windows, to support '_nc_resizeall()' and 395 * '_nc_freeall()' 396 */ 397 WINDOWLIST *_nc_sp_windows; 398 #define _nc_windows SP->_nc_sp_windows 399 400 bool _sig_winch; 401 SCREEN *_next_screen; 402 403 /* hashes for old and new lines */ 404 unsigned long *oldhash, *newhash; 405 406 bool _cleanup; /* cleanup after int/quit signal */ 407 int (*_outch)(int); /* output handler if not putc */ 408 }; 409 410 extern SCREEN *_nc_screen_chain; 411 412 #ifdef NCURSES_NOMACROS 413 #include <nomacros.h> 414 #endif 415 416 WINDOWLIST { 417 WINDOWLIST *next; 418 WINDOW *win; 419 }; 420 421 typedef struct { 422 int line; /* lines to take, < 0 => from bottom*/ 423 int (*hook)(struct _win_st *, int); /* callback for user */ 424 struct _win_st *w; /* maybe we need this for cleanup */ 425 } ripoff_t; 426 427 /* The terminfo source is assumed to be 7-bit ASCII */ 428 #define is7bits(c) ((unsigned)(c) < 128) 429 430 #ifndef min 431 #define min(a,b) ((a) > (b) ? (b) : (a)) 432 #endif 433 434 #ifndef max 435 #define max(a,b) ((a) < (b) ? (b) : (a)) 436 #endif 437 438 /* usually in <unistd.h> */ 439 #ifndef STDIN_FILENO 440 #define STDIN_FILENO 0 441 #endif 442 443 #ifndef STDOUT_FILENO 444 #define STDOUT_FILENO 1 445 #endif 446 447 #ifndef STDERR_FILENO 448 #define STDERR_FILENO 2 449 #endif 450 451 #ifndef EXIT_SUCCESS 452 #define EXIT_SUCCESS 0 453 #endif 454 455 #ifndef EXIT_FAILURE 456 #define EXIT_FAILURE 1 457 #endif 458 459 #ifndef R_OK 460 #define R_OK 4 /* Test for read permission. */ 461 #endif 462 #ifndef W_OK 463 #define W_OK 2 /* Test for write permission. */ 464 #endif 465 #ifndef X_OK 466 #define X_OK 1 /* Test for execute permission. */ 467 #endif 468 #ifndef F_OK 469 #define F_OK 0 /* Test for existence. */ 470 #endif 471 472 #if HAVE_FCNTL_H 473 #include <fcntl.h> /* may define O_BINARY */ 474 #endif 475 476 #ifndef O_BINARY 477 #define O_BINARY 0 478 #endif 479 480 #define TextOf(c) ((c) & (chtype)A_CHARTEXT) 481 #define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES) 482 483 #define BLANK (' '|A_NORMAL) 484 485 #define CHANGED -1 486 487 #define CHANGED_CELL(line,col) \ 488 if (line->firstchar == _NOCHANGE) \ 489 line->firstchar = line->lastchar = col; \ 490 else if ((col) < line->firstchar) \ 491 line->firstchar = col; \ 492 else if ((col) > line->lastchar) \ 493 line->lastchar = col 494 495 #define CHANGED_RANGE(line,start,end) \ 496 if (line->firstchar == _NOCHANGE \ 497 || line->firstchar > (start)) \ 498 line->firstchar = start; \ 499 if (line->lastchar == _NOCHANGE \ 500 || line->lastchar < (end)) \ 501 line->lastchar = end 502 503 #define CHANGED_TO_EOL(line,start,end) \ 504 if (line->firstchar == _NOCHANGE \ 505 || line->firstchar > (start)) \ 506 line->firstchar = start; \ 507 line->lastchar = end 508 509 #define SIZEOF(v) (sizeof(v)/sizeof(v[0])) 510 511 #define FreeIfNeeded(p) if ((p) != 0) free(p) 512 513 /* FreeAndNull() is not a comma-separated expression because some compilers 514 * do not accept a mixture of void with values. 515 */ 516 #define FreeAndNull(p) free(p); p = 0 517 518 #include <nc_alloc.h> 519 520 /* 521 * Prefixes for call/return points of library function traces. We use these to 522 * instrument the public functions so that the traces can be easily transformed 523 * into regression scripts. 524 */ 525 #define T_CALLED(fmt) "called " fmt 526 #define T_CREATE(fmt) "create " fmt 527 #define T_RETURN(fmt) "return " fmt 528 529 #ifdef TRACE 530 #define TR(n, a) if (_nc_tracing & (n)) _tracef a 531 #define T(a) TR(TRACE_CALLS, a) 532 #define TPUTS_TRACE(s) _nc_tputs_trace = s; 533 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value) 534 #define returnAttr(code) TRACE_RETURN(code,attr_t) 535 #define returnCode(code) TRACE_RETURN(code,int) 536 #define returnPtr(code) TRACE_RETURN(code,ptr) 537 #define returnVoid T((T_RETURN(""))); return 538 #define returnWin(code) TRACE_RETURN(code,win) 539 extern WINDOW * _nc_retrace_win(WINDOW *); 540 extern attr_t _nc_retrace_attr_t(attr_t); 541 extern char *_nc_retrace_ptr(char *); 542 extern const char *_nc_tputs_trace; 543 extern int _nc_retrace_int(int); 544 extern long _nc_outchars; 545 extern void _nc_fifo_dump(void); 546 #else 547 #define T(a) 548 #define TR(n, a) 549 #define TPUTS_TRACE(s) 550 #define returnAttr(code) return code 551 #define returnCode(code) return code 552 #define returnPtr(code) return code 553 #define returnVoid return 554 #define returnWin(code) return code 555 #endif 556 557 extern unsigned _nc_tracing; 558 extern const char *_nc_visbuf2(int, const char *); 559 560 #define _trace_key(ch) ((ch > KEY_MIN) ? keyname(ch) : _tracechar((unsigned char)ch)) 561 562 #define ALL_BUT_COLOR ((chtype)~(A_COLOR)) 563 #define IGNORE_COLOR_OFF FALSE 564 #define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK) 565 #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress) 566 567 568 #define toggle_attr_on(S,at) {\ 569 if (PAIR_NUMBER(at) > 0)\ 570 (S) = ((S) & ALL_BUT_COLOR) | (at);\ 571 else\ 572 (S) |= (at);\ 573 T(("new attribute is %s", _traceattr((S))));} 574 575 576 #define toggle_attr_off(S,at) {\ 577 if (IGNORE_COLOR_OFF == TRUE) {\ 578 if (PAIR_NUMBER(at) == 0xff) /* turn off color */\ 579 (S) &= ~(at);\ 580 else /* leave color alone */\ 581 (S) &= ~((at)&ALL_BUT_COLOR);\ 582 } else {\ 583 if (PAIR_NUMBER(at) > 0x00) /* turn off color */\ 584 (S) &= ~(at|A_COLOR);\ 585 else /* leave color alone */\ 586 (S) &= ~(at);\ 587 }\ 588 T(("new attribute is %s", _traceattr((S))));} 589 590 #define DelCharCost(count) \ 591 ((parm_dch != 0) \ 592 ? SP->_dch_cost \ 593 : ((delete_character != 0) \ 594 ? (SP->_dch1_cost * count) \ 595 : INFINITY)) 596 597 #define InsCharCost(count) \ 598 ((parm_ich != 0) \ 599 ? SP->_ich_cost \ 600 : ((enter_insert_mode && exit_insert_mode) \ 601 ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \ 602 : ((insert_character != 0) \ 603 ? (SP->_ich1_cost * count) \ 604 : INFINITY))) 605 606 #if USE_XMC_SUPPORT 607 #define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) { \ 608 attr_t chg = SP->_current_attr; \ 609 vidattr(AttrOf(c)); \ 610 if (magic_cookie_glitch > 0 \ 611 && XMC_CHANGES((chg ^ SP->_current_attr))) { \ 612 T(("%s @%d before glitch %d,%d", \ 613 __FILE__, __LINE__, \ 614 SP->_cursrow, \ 615 SP->_curscol)); \ 616 _nc_do_xmc_glitch(chg); \ 617 } \ 618 } 619 #else 620 #define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) \ 621 vidattr(AttrOf(c)) 622 #endif 623 624 #if defined(NCURSES_EXPANDED) && defined(NCURSES_EXT_FUNCS) 625 626 #undef toggle_attr_on 627 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at) 628 extern void _nc_toggle_attr_on(attr_t *, attr_t); 629 630 #undef toggle_attr_off 631 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at) 632 extern void _nc_toggle_attr_off(attr_t *, attr_t); 633 634 #undef DelCharCost 635 #define DelCharCost(count) _nc_DelCharCost(count) 636 extern int _nc_DelCharCost(int); 637 638 #undef InsCharCost 639 #define InsCharCost(count) _nc_InsCharCost(count) 640 extern int _nc_InsCharCost(int); 641 642 #undef UpdateAttrs 643 #define UpdateAttrs(c) _nc_UpdateAttrs(c) 644 extern void _nc_UpdateAttrs(chtype); 645 646 #else 647 648 extern void _nc_expanded(void); 649 650 #endif 651 652 #if !HAVE_GETCWD 653 #define getcwd(buf,len) getwd(buf) 654 #endif 655 656 /* doupdate.c */ 657 #if USE_XMC_SUPPORT 658 extern void _nc_do_xmc_glitch(attr_t); 659 #endif 660 661 /* hardscroll.c */ 662 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 663 extern void _nc_linedump(void); 664 #endif 665 666 /* lib_acs.c */ 667 extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */ 668 extern int _nc_msec_cost(const char *const, int); /* used by 'tack' program */ 669 670 /* lib_mvcur.c */ 671 #define INFINITY 1000000 /* cost: too high to use */ 672 673 extern void _nc_mvcur_init(void); 674 extern void _nc_mvcur_resume(void); 675 extern void _nc_mvcur_wrap(void); 676 677 extern int _nc_scrolln(int, int, int, int); 678 679 extern void _nc_screen_init(void); 680 extern void _nc_screen_resume(void); 681 extern void _nc_screen_wrap(void); 682 683 #if !HAVE_STRSTR 684 #define strstr _nc_strstr 685 extern char *_nc_strstr(const char *, const char *); 686 #endif 687 688 /* lib_mouse.c */ 689 extern int _nc_has_mouse(void); 690 691 /* safe_sprintf.c */ 692 extern char * _nc_printf_string(const char *fmt, va_list ap); 693 694 /* tries.c */ 695 extern void _nc_add_to_try(struct tries **tree, const char *str, unsigned short code); 696 extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len); 697 extern int _nc_remove_key(struct tries **tree, unsigned short code); 698 extern int _nc_remove_string(struct tries **tree, char *string); 699 700 /* elsewhere ... */ 701 extern WINDOW *_nc_makenew(int, int, int, int, int); 702 extern char *_nc_home_terminfo(void); 703 extern char *_nc_trace_buf(int, size_t); 704 extern chtype _nc_background(WINDOW *); 705 extern chtype _nc_render(WINDOW *, chtype); 706 extern int _nc_access(const char *, int); 707 extern int _nc_baudrate(int); 708 extern int _nc_getenv_num(const char *); 709 extern int _nc_keypad(bool); 710 extern int _nc_ospeed(int); 711 extern int _nc_outch(int); 712 extern int _nc_setupscreen(short, short const, FILE *); 713 extern int _nc_timed_wait(int, int, int *); 714 extern int _nc_waddch_nosync(WINDOW *, const chtype); 715 extern void _nc_do_color(int, int, bool, int (*)(int)); 716 extern void _nc_freeall(void); 717 extern void _nc_freewin(WINDOW *win); 718 extern void _nc_hash_map(void); 719 extern void _nc_init_keytry(void); 720 extern void _nc_keep_tic_dir(const char *); 721 extern void _nc_make_oldhash(int i); 722 extern void _nc_flush(void); 723 extern void _nc_outstr(const char *str); 724 extern void _nc_scroll_oldhash(int n, int top, int bot); 725 extern void _nc_scroll_optimize(void); 726 extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype); 727 extern void _nc_set_buffer(FILE *, bool); 728 extern void _nc_signal_handler(bool); 729 extern void _nc_synchook(WINDOW *win); 730 extern void _nc_trace_tries(struct tries *tree); 731 732 #if USE_SIZECHANGE 733 extern void _nc_update_screensize(void); 734 #endif 735 736 #ifdef USE_WIDEC_SUPPORT 737 extern int _nc_utf8_outch(int); 738 #endif 739 740 /* scroll indices */ 741 extern int *_nc_oldnums; 742 743 #define USE_SETBUF_0 0 744 745 #define NC_BUFFERED(flag) \ 746 if ((SP->_buffered != 0) != flag) \ 747 _nc_set_buffer(SP->_ofp, flag) 748 749 #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout) 750 751 /* 752 * On systems with a broken linker, define 'SP' as a function to force the 753 * linker to pull in the data-only module with 'SP'. 754 */ 755 #ifndef BROKEN_LINKER 756 #define BROKEN_LINKER 0 757 #endif 758 759 #if BROKEN_LINKER 760 #define SP _nc_screen() 761 extern SCREEN *_nc_screen(void); 762 extern int _nc_alloc_screen(void); 763 extern void _nc_set_screen(SCREEN *); 764 #else 765 /* current screen is private data; avoid possible linking conflicts too */ 766 extern SCREEN *SP; 767 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0) 768 #define _nc_set_screen(sp) SP = sp 769 #endif 770 771 /* 772 * We don't want to use the lines or columns capabilities internally, 773 * because if the application is running multiple screens under 774 * X windows, it's quite possible they could all have type xterm 775 * but have different sizes! So... 776 */ 777 #define screen_lines SP->_lines 778 #define screen_columns SP->_columns 779 780 extern int _nc_slk_format; /* != 0 if slk_init() called */ 781 extern int _nc_slk_initialize(WINDOW *, int); 782 783 /* 784 * Some constants related to SLK's 785 */ 786 #define MAX_SKEY_OLD 8 /* count of soft keys */ 787 #define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */ 788 #define MAX_SKEY_PC 12 /* This is what most PC's have */ 789 #define MAX_SKEY_LEN_PC 5 790 791 /* Macro to check whether or not we use a standard format */ 792 #define SLK_STDFMT(fmt) (fmt < 3) 793 /* Macro to determine height of label window */ 794 #define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2)) 795 796 #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) 797 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) 798 799 extern int _nc_ripoffline(int line, int (*init)(WINDOW *,int)); 800 801 #ifdef __cplusplus 802 } 803 #endif 804 805 #endif /* CURSES_PRIV_H */ 806