1 /* $OpenBSD: curses.priv.h,v 1.25 2000/03/10 01:35:01 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.153 2000/02/19 23:31:39 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 lib_doupdate.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 _smir_cost; /* cost of (enter_insert_mode) */ 328 int _rmir_cost; /* cost of (exit_insert_mode) */ 329 int _ip_cost; /* cost of (insert_padding) */ 330 /* used in lib_mvcur.c */ 331 char * _address_cursor; 332 int _carriage_return_length; 333 int _cursor_home_length; 334 int _cursor_to_ll_length; 335 int _scrolling; /* 1 if terminal's smart enough to */ 336 337 /* used in lib_color.c */ 338 color_t *_color_table; /* screen's color palette */ 339 int _color_count; /* count of colors in palette */ 340 unsigned short *_color_pairs; /* screen's color pair list */ 341 int _pair_count; /* count of color pairs */ 342 #ifdef NCURSES_EXT_FUNCS 343 int _default_color; /* use default colors */ 344 int _default_fg; /* assumed default foreground */ 345 int _default_bg; /* assumed default background */ 346 #endif 347 chtype _xmc_suppress; /* attributes to suppress if xmc */ 348 chtype _xmc_triggers; /* attributes to process if xmc */ 349 chtype _acs_map[ACS_LEN]; 350 351 /* used in lib_vidattr.c */ 352 bool _use_rmso; /* true if we may use 'rmso' */ 353 bool _use_rmul; /* true if we may use 'rmul' */ 354 355 /* 356 * These data correspond to the state of the idcok() and idlok() 357 * functions. A caveat is in order here: the XSI and SVr4 358 * documentation specify that these functions apply to the window which 359 * is given as an argument. However, ncurses implements this logic 360 * only for the newscr/curscr update process, _not_ per-window. 361 */ 362 bool _nc_sp_idlok; 363 bool _nc_sp_idcok; 364 #define _nc_idlok SP->_nc_sp_idlok 365 #define _nc_idcok SP->_nc_sp_idcok 366 367 /* 368 * These are the data that support the mouse interface. 369 */ 370 int _maxclick; 371 bool (*_mouse_event) (SCREEN *); 372 bool (*_mouse_inline)(SCREEN *); 373 bool (*_mouse_parse) (int); 374 void (*_mouse_resume)(SCREEN *); 375 void (*_mouse_wrap) (SCREEN *); 376 int _mouse_fd; /* file-descriptor, if any */ 377 378 /* 379 * This supports automatic resizing 380 */ 381 #if USE_SIZECHANGE 382 int (*_resize)(int,int); 383 #endif 384 385 /* 386 * These are data that support the proper handling of the panel stack on an 387 * per screen basis. 388 */ 389 struct panelhook _panelHook; 390 /* 391 * Linked-list of all windows, to support '_nc_resizeall()' and 392 * '_nc_freeall()' 393 */ 394 WINDOWLIST *_nc_sp_windows; 395 #define _nc_windows SP->_nc_sp_windows 396 397 bool _sig_winch; 398 SCREEN *_next_screen; 399 400 /* hashes for old and new lines */ 401 unsigned long *oldhash, *newhash; 402 403 bool _cleanup; /* cleanup after int/quit signal */ 404 }; 405 406 extern SCREEN *_nc_screen_chain; 407 408 #ifdef NCURSES_NOMACROS 409 #include <nomacros.h> 410 #endif 411 412 WINDOWLIST { 413 WINDOWLIST *next; 414 WINDOW *win; 415 }; 416 417 typedef struct { 418 int line; /* lines to take, < 0 => from bottom*/ 419 int (*hook)(struct _win_st *, int); /* callback for user */ 420 struct _win_st *w; /* maybe we need this for cleanup */ 421 } ripoff_t; 422 423 /* The terminfo source is assumed to be 7-bit ASCII */ 424 #define is7bits(c) ((unsigned)(c) < 128) 425 426 #ifndef min 427 #define min(a,b) ((a) > (b) ? (b) : (a)) 428 #endif 429 430 #ifndef max 431 #define max(a,b) ((a) < (b) ? (b) : (a)) 432 #endif 433 434 /* usually in <unistd.h> */ 435 #ifndef STDIN_FILENO 436 #define STDIN_FILENO 0 437 #endif 438 439 #ifndef STDOUT_FILENO 440 #define STDOUT_FILENO 1 441 #endif 442 443 #ifndef STDERR_FILENO 444 #define STDERR_FILENO 2 445 #endif 446 447 #ifndef EXIT_SUCCESS 448 #define EXIT_SUCCESS 0 449 #endif 450 451 #ifndef EXIT_FAILURE 452 #define EXIT_FAILURE 1 453 #endif 454 455 #ifndef R_OK 456 #define R_OK 4 /* Test for read permission. */ 457 #endif 458 #ifndef W_OK 459 #define W_OK 2 /* Test for write permission. */ 460 #endif 461 #ifndef X_OK 462 #define X_OK 1 /* Test for execute permission. */ 463 #endif 464 #ifndef F_OK 465 #define F_OK 0 /* Test for existence. */ 466 #endif 467 468 #if HAVE_FCNTL_H 469 #include <fcntl.h> /* may define O_BINARY */ 470 #endif 471 472 #ifndef O_BINARY 473 #define O_BINARY 0 474 #endif 475 476 #define TextOf(c) ((c) & (chtype)A_CHARTEXT) 477 #define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES) 478 479 #define BLANK (' '|A_NORMAL) 480 481 #define CHANGED -1 482 483 #define CHANGED_CELL(line,col) \ 484 if (line->firstchar == _NOCHANGE) \ 485 line->firstchar = line->lastchar = col; \ 486 else if ((col) < line->firstchar) \ 487 line->firstchar = col; \ 488 else if ((col) > line->lastchar) \ 489 line->lastchar = col 490 491 #define CHANGED_RANGE(line,start,end) \ 492 if (line->firstchar == _NOCHANGE \ 493 || line->firstchar > (start)) \ 494 line->firstchar = start; \ 495 if (line->lastchar == _NOCHANGE \ 496 || line->lastchar < (end)) \ 497 line->lastchar = end 498 499 #define CHANGED_TO_EOL(line,start,end) \ 500 if (line->firstchar == _NOCHANGE \ 501 || line->firstchar > (start)) \ 502 line->firstchar = start; \ 503 line->lastchar = end 504 505 #define SIZEOF(v) (sizeof(v)/sizeof(v[0])) 506 507 #define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type)) 508 #define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type)) 509 #define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type)) 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 #ifdef NCURSES_EXPANDED 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 /* doalloc.c */ 657 extern void *_nc_doalloc(void *, size_t); 658 #if !HAVE_STRDUP 659 #define strdup _nc_strdup 660 extern char *_nc_strdup(const char *); 661 #endif 662 663 /* doupdate.c */ 664 #if USE_XMC_SUPPORT 665 extern void _nc_do_xmc_glitch(attr_t); 666 #endif 667 668 /* hardscroll.c */ 669 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) 670 extern void _nc_linedump(void); 671 #endif 672 673 /* lib_acs.c */ 674 extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */ 675 extern int _nc_msec_cost(const char *const, int); /* used by 'tack' program */ 676 677 /* lib_mvcur.c */ 678 #define INFINITY 1000000 /* cost: too high to use */ 679 680 extern void _nc_mvcur_init(void); 681 extern void _nc_mvcur_resume(void); 682 extern void _nc_mvcur_wrap(void); 683 684 extern int _nc_scrolln(int, int, int, int); 685 686 extern void _nc_screen_init(void); 687 extern void _nc_screen_resume(void); 688 extern void _nc_screen_wrap(void); 689 690 #if !HAVE_STRSTR 691 #define strstr _nc_strstr 692 extern char *_nc_strstr(const char *, const char *); 693 #endif 694 695 /* lib_mouse.c */ 696 extern int _nc_has_mouse(void); 697 698 /* safe_sprintf.c */ 699 extern char * _nc_printf_string(const char *fmt, va_list ap); 700 701 /* tries.c */ 702 extern void _nc_add_to_try(struct tries **tree, char *str, unsigned short code); 703 extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len); 704 extern int _nc_remove_key(struct tries **tree, unsigned short code); 705 extern int _nc_remove_string(struct tries **tree, char *string); 706 707 /* elsewhere ... */ 708 extern WINDOW *_nc_makenew(int, int, int, int, int); 709 extern char *_nc_home_terminfo(void); 710 extern char *_nc_trace_buf(int, size_t); 711 extern chtype _nc_background(WINDOW *); 712 extern chtype _nc_render(WINDOW *, chtype); 713 extern int _nc_access(const char *, int); 714 extern int _nc_baudrate(int); 715 extern int _nc_getenv_num(const char *); 716 extern int _nc_keypad(bool); 717 extern int _nc_ospeed(int); 718 extern int _nc_outch(int); 719 extern int _nc_setupscreen(short, short const, FILE *); 720 extern int _nc_timed_wait(int, int, int *); 721 extern int _nc_waddch_nosync(WINDOW *, const chtype); 722 extern void _nc_do_color(int, bool, int (*)(int)); 723 extern void _nc_freeall(void); 724 extern void _nc_freewin(WINDOW *win); 725 extern void _nc_hash_map(void); 726 extern void _nc_init_keytry(void); 727 extern void _nc_keep_tic_dir(const char *); 728 extern void _nc_make_oldhash(int i); 729 extern void _nc_outstr(const char *str); 730 extern void _nc_scroll_oldhash(int n, int top, int bot); 731 extern void _nc_scroll_optimize(void); 732 extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype); 733 extern void _nc_set_buffer(FILE *ofp, bool buffered); 734 extern void _nc_signal_handler(bool); 735 extern void _nc_synchook(WINDOW *win); 736 extern void _nc_trace_tries(struct tries *tree); 737 738 #if USE_SIZECHANGE 739 extern void _nc_update_screensize(void); 740 #endif 741 742 /* scroll indices */ 743 extern int *_nc_oldnums; 744 745 #define USE_SETBUF_0 0 746 747 #define NC_BUFFERED(flag) \ 748 if ((SP->_buffered != 0) != flag) \ 749 _nc_set_buffer(SP->_ofp, flag) 750 751 #define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout) 752 #define _nc_flush() (void)fflush(NC_OUTPUT) 753 754 /* 755 * On systems with a broken linker, define 'SP' as a function to force the 756 * linker to pull in the data-only module with 'SP'. 757 */ 758 #ifndef BROKEN_LINKER 759 #define BROKEN_LINKER 0 760 #endif 761 762 #if BROKEN_LINKER 763 #define SP _nc_screen() 764 extern SCREEN *_nc_screen(void); 765 extern int _nc_alloc_screen(void); 766 extern void _nc_set_screen(SCREEN *); 767 #else 768 /* current screen is private data; avoid possible linking conflicts too */ 769 extern SCREEN *SP; 770 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0) 771 #define _nc_set_screen(sp) SP = sp 772 #endif 773 774 /* 775 * We don't want to use the lines or columns capabilities internally, 776 * because if the application is running multiple screens under 777 * X windows, it's quite possible they could all have type xterm 778 * but have different sizes! So... 779 */ 780 #define screen_lines SP->_lines 781 #define screen_columns SP->_columns 782 783 extern int _nc_slk_format; /* != 0 if slk_init() called */ 784 extern int _nc_slk_initialize(WINDOW *, int); 785 786 /* 787 * Some constants related to SLK's 788 */ 789 #define MAX_SKEY_OLD 8 /* count of soft keys */ 790 #define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */ 791 #define MAX_SKEY_PC 12 /* This is what most PC's have */ 792 #define MAX_SKEY_LEN_PC 5 793 794 /* Macro to check whether or not we use a standard format */ 795 #define SLK_STDFMT(fmt) (fmt < 3) 796 /* Macro to determine height of label window */ 797 #define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2)) 798 799 #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC) 800 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC) 801 802 extern int _nc_ripoffline(int line, int (*init)(WINDOW *,int)); 803 804 #ifdef __cplusplus 805 } 806 #endif 807 808 #endif /* CURSES_PRIV_H */ 809