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