1 /****************************************************************************
2 * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996-on *
33 * and: Juergen Pfeifer *
34 ****************************************************************************/
38 * $Id: curses.priv.h,v 1.416 2009/05/10 01:01:51 tom Exp $
42 * Header file for curses library objects which are private to
48 #define CURSES_PRIV_H 1
50 #include <ncurses_dll.h>
56 #include <ncurses_cfg.h>
59 #define MODULE_ID(id) static const char Ident[] = id;
61 #define MODULE_ID(id) /*nothing*/
66 #include <sys/types.h>
72 #if HAVE_SYS_BSDTYPES_H
73 #include <sys/bsdtypes.h> /* needed for ISC */
78 #elif HAVE_SYS_PARAM_H
79 # include <sys/param.h>
88 # if defined(_POSIX_PATH_MAX)
89 # define PATH_MAX _POSIX_PATH_MAX
90 # elif defined(MAXPATHLEN)
91 # define PATH_MAX MAXPATHLEN
93 # define PATH_MAX 255 /* the Posix minimum path-size */
101 /* Some systems have a broken 'select()', but workable 'poll()'. Use that */
102 #if HAVE_WORKING_POLL
103 #define USE_FUNC_POLL 1
107 #include <sys/poll.h>
110 #define USE_FUNC_POLL 0
113 /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
116 /* Alessandro Rubini's GPM (general-purpose mouse) */
117 #if HAVE_LIBGPM && HAVE_GPM_H
118 #define USE_GPM_SUPPORT 1
120 #define USE_GPM_SUPPORT 0
123 /* QNX mouse support */
124 #if defined(__QNX__) && !defined(__QNXNTO__)
125 #define USE_QNX_MOUSE 1
127 #define USE_QNX_MOUSE 0
130 /* EMX mouse support */
132 #define USE_EMX_MOUSE 1
134 #define USE_EMX_MOUSE 0
137 #define DEFAULT_MAXCLICK 166
138 #define EV_MAX 8 /* size of mouse circular event queue */
141 * If we don't have signals to support it, don't add a sigwinch handler.
142 * In any case, resizing is an extended feature. Use it if we've got it.
144 #if !NCURSES_EXT_FUNCS
145 #undef HAVE_SIZECHANGE
146 #define HAVE_SIZECHANGE 0
149 #if HAVE_SIZECHANGE && USE_SIGWINCH && defined(SIGWINCH)
150 #define USE_SIZECHANGE 1
152 #define USE_SIZECHANGE 0
154 #define USE_SIGWINCH 0
158 * If desired, one can configure this, disabling environment variables that
159 * point to custom terminfo/termcap locations.
161 #ifdef USE_ROOT_ENVIRON
162 #define use_terminfo_vars() 1
164 #define use_terminfo_vars() _nc_env_access()
165 extern NCURSES_EXPORT(int) _nc_env_access (void);
169 * Not all platforms have memmove; some have an equivalent bcopy. (Some may
173 #define memmove(d,s,n) bcopy(s,d,n)
175 #define memmove(d,s,n) _nc_memmove(d,s,n)
176 extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
180 * Scroll hints are useless when hashmap is used
182 #if !USE_SCROLL_HINTS
184 #define USE_SCROLL_HINTS 1
186 #define USE_SCROLL_HINTS 0
191 #define if_USE_SCROLL_HINTS(stmt) stmt
193 #define if_USE_SCROLL_HINTS(stmt) /*nothing*/
197 * Terminal drivers...
199 #define USE_TERM_DRIVER 0
202 * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
203 * when we're throwing control codes at the screen at high volume. To see
204 * this, re-enable USE_HARD_TABS and run worm for a while. Other systems
205 * probably don't want to define this either due to uncertainties about tab
206 * delays and expansion in raw mode.
209 #define TRIES struct tries
211 TRIES *child; /* ptr to child. NULL if none */
212 TRIES *sibling; /* ptr to sibling. NULL if none */
213 unsigned char ch; /* character at this node */
214 unsigned short value; /* code of string so far. 0 if none. */
219 * Common/troublesome character definitions
221 #define StringOf(ch) {ch, 0}
228 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
231 * Structure for palette tables
236 short red, green, blue; /* what color_content() returns */
237 short r, g, b; /* params to init_color() */
238 int init; /* true if we called init_color() */
242 #define MAXCOLUMNS 135
244 #define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */
248 #define WINDOWLIST struct _win_list
250 #if USE_WIDEC_SUPPORT
251 #define _nc_bkgd _bkgrnd
253 #undef _XOPEN_SOURCE_EXTENDED
254 #define _nc_bkgd _bkgd
255 #define wgetbkgrnd(win, wch) *wch = win->_bkgd
256 #define wbkgrnd wbkgd
259 #undef NCURSES_OPAQUE
260 #define NCURSES_INTERNALS 1
261 #define NCURSES_OPAQUE 0
263 #include <curses.h> /* we'll use -Ipath directive to get the right one! */
266 * If curses.h did not expose the SCREEN-functions, then we do not need the
267 * parameter in the corresponding unextended functions.
270 #define SP_PARM sp /* use parameter */
271 #define NCURSES_SP_ARG SP_PARM
272 #define NCURSES_SP_DCL SCREEN *NCURSES_SP_ARG
273 #define NCURSES_SP_DCL0 NCURSES_SP_DCL
274 #define NCURSES_SP_ARGx NCURSES_SP_ARG,
275 #define NCURSES_SP_DCLx SCREEN *NCURSES_SP_ARGx
277 #define SP_PARM SP /* use global variable */
278 #define NCURSES_SP_ARG
279 #define NCURSES_SP_DCL
280 #define NCURSES_SP_DCL0 void
281 #define NCURSES_SP_ARGx
282 #define NCURSES_SP_DCLx
285 #include <nc_panel.h>
287 #define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen)
288 #define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term)))
289 #define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp))
291 #if BROKEN_LINKER || USE_REENTRANT
292 #define CurTerm _nc_prescreen._cur_term
294 #define CurTerm cur_term
298 #define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm)
300 #define TerminalOf(sp) CurTerm
306 * Reduce dependency on cur_term global by using terminfo data from SCREEN's
307 * pointer to this data.
309 #ifdef USE_SP_TERMTYPE
313 #define SP_TERMTYPE TerminalOf(sp)->type.
315 #include <term_entry.h>
317 #include <nc_tparm.h>
319 #if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
320 #define if_EXT_COLORS(stmt) stmt
321 #define NetPair(value,p) (value).ext_color = (p), \
322 AttrOf(value) &= ALL_BUT_COLOR, \
323 AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
324 #define SetPair(value,p) (value).ext_color = (p)
325 #define GetPair(value) (value).ext_color
326 #define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
327 #define GET_WINDOW_PAIR(w) (w)->_color
328 #define SET_WINDOW_PAIR(w,p) (w)->_color = (p)
329 #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
332 #define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, pair, 0)
334 #define VIDATTR(sp,attr,pair) vid_attr(attr, pair, 0)
337 #else /* !(NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT) */
338 #define if_EXT_COLORS(stmt) /* nothing */
339 #define SetPair(value,p) RemAttr(value, A_COLOR), \
340 SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
341 #define GetPair(value) PAIR_NUMBER(AttrOf(value))
342 #define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
343 #define GET_WINDOW_PAIR(w) PAIR_NUMBER(WINDOW_ATTRS(w))
344 #define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
345 WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p))
346 #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
349 #define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vidattr)(sp, attr)
351 #define VIDATTR(sp,attr,pair) vidattr(attr)
354 #endif /* NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT */
356 #if NCURSES_NO_PADDING
357 #define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding)
358 #define SetNoPadding(sp) _nc_set_no_padding(sp)
359 extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *);
361 #define GetNoPadding(sp) FALSE
362 #define SetNoPadding(sp) /*nothing*/
365 #define WINDOW_ATTRS(w) ((w)->_attrs)
367 #define SCREEN_ATTRS(s) (*((s)->_current_attr))
368 #define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))
369 #define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
372 NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
373 NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
374 #define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES))
375 #define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS))
376 #define SET_LINES(value) *_nc_ptr_Lines() = value
377 #define SET_COLS(value) *_nc_ptr_Cols() = value
379 #define ptrLines(sp) &LINES
380 #define ptrCols(sp) &COLS
381 #define SET_LINES(value) LINES = value
382 #define SET_COLS(value) COLS = value
385 #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
386 __FILE__, __LINE__, \
387 (unsigned long) (pthread_self()), \
388 data.__data.__lock, \
389 data.__data.__count, \
390 data.__data.__owner, \
391 data.__data.__kind, \
392 (data.__data.__nusers > 5) ? " OOPS " : "", \
393 data.__data.__nusers)
394 #define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name)
400 extern NCURSES_EXPORT(void) _nc_init_pthreads(void);
401 extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *);
402 extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *);
403 extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *);
404 extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
405 #define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name)
406 #define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name)
407 #define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name)
410 #error POSIX threads requires --enable-reentrant option
414 #if defined(__GNUC__)
415 # if defined __USE_ISOC99
416 # define _cat_pragma(exp) _Pragma(#exp)
417 # define _weak_pragma(exp) _cat_pragma(weak name)
419 # define _weak_pragma(exp)
421 # define _declare(name) __extension__ extern __typeof__(name) name
422 # define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak))
427 # if USE_WEAK_SYMBOLS
428 weak_symbol(pthread_sigmask);
429 weak_symbol(pthread_self);
430 weak_symbol(pthread_equal);
431 weak_symbol(pthread_mutex_init);
432 weak_symbol(pthread_mutex_lock);
433 weak_symbol(pthread_mutex_unlock);
434 weak_symbol(pthread_mutex_trylock);
435 weak_symbol(pthread_mutexattr_settype);
436 weak_symbol(pthread_mutexattr_init);
437 extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
439 # define sigprocmask _nc_sigprocmask
444 #undef HAVE_NANOSLEEP
445 #define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */
448 #else /* !USE_PTHREADS */
450 #define _nc_init_pthreads() /* nothing */
451 #define _nc_mutex_init(obj) /* nothing */
453 #define _nc_lock_global(name) /* nothing */
454 #define _nc_try_global(name) 0
455 #define _nc_unlock_global(name) /* nothing */
457 #endif /* USE_PTHREADS */
459 #if HAVE_GETTIMEOFDAY
460 # define PRECISE_GETTIME 1
461 # define TimeType struct timeval
463 # define PRECISE_GETTIME 0
464 # define TimeType time_t
468 * Definitions for color pairs
470 typedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */
471 #define C_SHIFT 9 /* we need more bits than there are colors */
472 #define C_MASK ((1 << C_SHIFT) - 1)
473 #define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
474 #define FORE_OF(c) (((c) >> C_SHIFT) & C_MASK)
475 #define BACK_OF(c) ((c) & C_MASK)
476 #define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0)
478 #define COLOR_DEFAULT C_MASK
480 #if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)
482 #undef NCURSES_CH_T /* this is not a termlib feature */
483 #define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */
485 #endif /* USE_TERMLIB */
490 NCURSES_CH_T *text; /* text of the line */
491 NCURSES_SIZE_T firstchar; /* first changed character in the line */
492 NCURSES_SIZE_T lastchar; /* last changed character in the line */
493 NCURSES_SIZE_T oldindex; /* index of the line at last update */
495 #endif /* USE_TERMLIB */
498 M_XTERM = -1 /* use xterm's mouse tracking? */
499 ,M_NONE = 0 /* no mouse device */
504 ,M_SYSMOUSE /* FreeBSD sysmouse on console */
509 * Structures for scrolling.
513 unsigned long hashval;
514 int oldcount, newcount;
515 int oldindex, newindex;
519 * Structures for soft labels.
528 char *ent_text; /* text for the label */
529 char *form_text; /* formatted text (left/center/...) */
530 int ent_x; /* x coordinate of this field */
531 char dirty; /* this label has changed */
532 char visible; /* field is visible */
535 typedef struct _SLK {
536 bool dirty; /* all labels have changed */
537 bool hidden; /* soft labels are hidden */
540 short maxlab; /* number of available labels */
541 short labcnt; /* number of allocated labels */
542 short maxlen; /* length of labels */
543 NCURSES_CH_T attr; /* soft label attribute */
546 #endif /* USE_TERMLIB */
549 WINDOW *win; /* the window used in the hook */
550 int line; /* lines to take, < 0 => from bottom*/
551 int (*hook)(WINDOW *, int); /* callback for user */
555 #undef buttons /* term.h defines this, and gpm uses it! */
559 /* link dynamically to GPM */
560 typedef int *TYPE_gpm_fd;
561 typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
562 typedef int (*TYPE_Gpm_Close) (void);
563 typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
565 #define my_gpm_fd SP_PARM->_mouse_gpm_fd
566 #define my_Gpm_Open SP_PARM->_mouse_Gpm_Open
567 #define my_Gpm_Close SP_PARM->_mouse_Gpm_Close
568 #define my_Gpm_GetEvent SP_PARM->_mouse_Gpm_GetEvent
570 /* link statically to GPM */
571 #define my_gpm_fd &gpm_fd
572 #define my_Gpm_Open Gpm_Open
573 #define my_Gpm_Close Gpm_Close
574 #define my_Gpm_GetEvent Gpm_GetEvent
575 #endif /* HAVE_LIBDL */
576 #endif /* USE_GPM_SUPPORT */
581 char *fix_sgr0; /* this holds the filtered sgr0 string */
582 char *last_bufp; /* help with fix_sgr0 leak */
586 #define TGETENT_MAX 4
607 const char *tparam_base;
609 STACK_FRAME stack[STACKSIZE];
619 int dynamic_var[NUM_VARS];
620 int static_vars[NUM_VARS];
629 * The filesystem database normally uses a single-letter for the lower level
630 * of directories. Use a hexadecimal code for filesystems which do not
631 * preserve mixed-case names.
633 #if MIXEDCASE_FILENAMES
634 #define LEAF_FMT "%c"
636 #define LEAF_FMT "%02x"
640 * TRACEMSE_FMT is no longer than 80 columns, there are 5 numbers that
641 * could at most have 10 digits, and the mask contains no more than 32 bits
642 * with each bit representing less than 15 characters. Usually the whole
643 * string is less than 80 columns, but this buffer size is an absolute
646 #define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15))
647 #define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */
650 * Global data which is not specific to a screen.
653 SIG_ATOMIC_T have_sigwinch;
654 SIG_ATOMIC_T cleanup_nested;
659 const char *comp_sourcename;
662 bool have_tic_directory;
663 bool keep_tic_directory;
664 const char *tic_directory;
670 char **keyname_table;
675 size_t safeprint_used;
677 TGETENT_CACHE tgetent_cache[TGETENT_MAX];
679 long tgetent_sequence;
681 WINDOWLIST *_nc_windowlist;
682 #define WindowList(sp) _nc_globals._nc_windowlist
684 #if USE_HOME_TERMINFO
688 #if !USE_SAFE_SPRINTF
695 char trace_fname[PATH_MAX];
700 size_t tracearg_used;
702 TRACEBUF *tracebuf_ptr;
703 size_t tracebuf_used;
705 char tracechr_buf[40];
708 size_t tracedmp_used;
710 unsigned char *tracetry_buf;
711 size_t tracetry_used;
713 char traceatr_color_buf[2][80];
714 int traceatr_color_sel;
715 int traceatr_color_last;
716 #if !defined(USE_PTHREADS) && USE_REENTRANT
722 pthread_mutex_t mutex_curses;
723 pthread_mutex_t mutex_tst_tracef;
724 pthread_mutex_t mutex_tracef;
727 #define _nc_use_pthreads _nc_globals.use_pthreads
731 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
736 * Global data which can be swept up into a SCREEN when one is created.
737 * It may be modified before the next SCREEN is created.
742 attr_t previous_attr;
743 ripoff_t rippedoff[N_RIPS];
745 TPARM_STATE tparm_state;
746 TTY *saved_tty; /* savetty/resetty information */
747 #if NCURSES_NO_PADDING
748 bool _no_padding; /* flag to set if padding disabled */
750 #if BROKEN_LINKER || USE_REENTRANT
751 chtype *real_acs_map;
757 const char *_tputs_trace;
763 * Use screen-specific ripoff data (for softkeys) rather than global.
766 #define safe_ripoff_sp (sp)->rsp
767 #define safe_ripoff_stack (sp)->rippedoff
769 #define safe_ripoff_sp _nc_prescreen.rsp
770 #define safe_ripoff_stack _nc_prescreen.rippedoff
773 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
776 * The SCREEN structure.
780 int _ifd; /* input file ptr for screen */
781 FILE *_ofp; /* output file ptr for screen */
782 char *_setbuf; /* buffered I/O for output */
783 bool _filtered; /* filter() was called */
784 bool _buffered; /* setvbuf uses _setbuf data */
785 bool _prescreen; /* is in prescreen phase */
786 bool _use_env; /* LINES & COLS from environment? */
787 int _checkfd; /* filedesc for typeahead check */
788 TERMINAL *_term; /* terminal type information */
789 TTY _saved_tty; /* savetty/resetty information */
790 NCURSES_SIZE_T _lines; /* screen lines */
791 NCURSES_SIZE_T _columns; /* screen columns */
793 NCURSES_SIZE_T _lines_avail; /* lines available for stdscr */
794 NCURSES_SIZE_T _topstolen; /* lines stolen from top */
796 WINDOW *_curscr; /* current screen */
797 WINDOW *_newscr; /* virtual screen to be updated to */
798 WINDOW *_stdscr; /* screen's full-window context */
800 #define CurScreen(sp) (sp)->_curscr
801 #define NewScreen(sp) (sp)->_newscr
802 #define StdScreen(sp) (sp)->_stdscr
804 TRIES *_keytry; /* "Try" for use with keypad mode */
805 TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */
806 bool _tried; /* keypad mode was initialized */
807 bool _keypad_on; /* keypad mode is currently on */
809 bool _called_wgetch; /* check for recursion in wgetch() */
810 int _fifo[FIFO_SIZE]; /* input push-back buffer */
811 short _fifohead, /* head of fifo queue */
812 _fifotail, /* tail of fifo queue */
813 _fifopeek, /* where to peek for next char */
814 _fifohold; /* set if breakout marked */
816 int _endwin; /* are we out of window mode? */
817 NCURSES_CH_T *_current_attr; /* holds current attributes set */
818 int _coloron; /* is color enabled? */
819 int _color_defs; /* are colors modified */
820 int _cursor; /* visibility of the cursor */
821 int _cursrow; /* physical cursor row */
822 int _curscol; /* physical cursor column */
823 bool _notty; /* true if we cannot switch non-tty */
824 int _nl; /* True if NL -> CR/NL is on */
825 int _raw; /* True if in raw mode */
826 int _cbreak; /* 1 if in cbreak mode */
827 /* > 1 if in halfdelay mode */
828 int _echo; /* True if echo on */
829 int _use_meta; /* use the meta key? */
830 struct _SLK *_slk; /* ptr to soft key struct / NULL */
831 int slk_format; /* selected format for this screen */
832 /* cursor movement costs; units are 10ths of milliseconds */
833 #if NCURSES_NO_PADDING
834 bool _no_padding; /* flag to set if padding disabled */
836 int _char_padding; /* cost of character put */
837 int _cr_cost; /* cost of (carriage_return) */
838 int _cup_cost; /* cost of (cursor_address) */
839 int _home_cost; /* cost of (cursor_home) */
840 int _ll_cost; /* cost of (cursor_to_ll) */
842 int _ht_cost; /* cost of (tab) */
843 int _cbt_cost; /* cost of (backtab) */
844 #endif /* USE_HARD_TABS */
845 int _cub1_cost; /* cost of (cursor_left) */
846 int _cuf1_cost; /* cost of (cursor_right) */
847 int _cud1_cost; /* cost of (cursor_down) */
848 int _cuu1_cost; /* cost of (cursor_up) */
849 int _cub_cost; /* cost of (parm_cursor_left) */
850 int _cuf_cost; /* cost of (parm_cursor_right) */
851 int _cud_cost; /* cost of (parm_cursor_down) */
852 int _cuu_cost; /* cost of (parm_cursor_up) */
853 int _hpa_cost; /* cost of (column_address) */
854 int _vpa_cost; /* cost of (row_address) */
855 /* used in tty_update.c, must be chars */
856 int _ed_cost; /* cost of (clr_eos) */
857 int _el_cost; /* cost of (clr_eol) */
858 int _el1_cost; /* cost of (clr_bol) */
859 int _dch1_cost; /* cost of (delete_character) */
860 int _ich1_cost; /* cost of (insert_character) */
861 int _dch_cost; /* cost of (parm_dch) */
862 int _ich_cost; /* cost of (parm_ich) */
863 int _ech_cost; /* cost of (erase_chars) */
864 int _rep_cost; /* cost of (repeat_char) */
865 int _hpa_ch_cost; /* cost of (column_address) */
866 int _cup_ch_cost; /* cost of (cursor_address) */
867 int _cuf_ch_cost; /* cost of (parm_cursor_right) */
868 int _inline_cost; /* cost of inline-move */
869 int _smir_cost; /* cost of (enter_insert_mode) */
870 int _rmir_cost; /* cost of (exit_insert_mode) */
871 int _ip_cost; /* cost of (insert_padding) */
872 /* used in lib_mvcur.c */
873 char * _address_cursor;
874 /* used in tty_update.c */
875 int _scrolling; /* 1 if terminal's smart enough to */
877 /* used in lib_color.c */
878 color_t *_color_table; /* screen's color palette */
879 int _color_count; /* count of colors in palette */
880 colorpair_t *_color_pairs; /* screen's color pair list */
881 int _pair_count; /* count of color pairs */
882 int _pair_limit; /* actual limit of color-pairs */
883 #if NCURSES_EXT_FUNCS
884 bool _default_color; /* use default colors */
885 bool _has_sgr_39_49; /* has ECMA default color support */
886 int _default_fg; /* assumed default foreground */
887 int _default_bg; /* assumed default background */
888 int _default_pairs; /* count pairs using default color */
890 chtype _ok_attributes; /* valid attributes for terminal */
891 chtype _xmc_suppress; /* attributes to suppress if xmc */
892 chtype _xmc_triggers; /* attributes to process if xmc */
893 chtype * _acs_map; /* the real alternate-charset map */
894 bool * _screen_acs_map;
897 /* used in lib_vidattr.c */
898 bool _use_rmso; /* true if we may use 'rmso' */
899 bool _use_rmul; /* true if we may use 'rmul' */
902 * These data correspond to the state of the idcok() and idlok()
903 * functions. A caveat is in order here: the XSI and SVr4
904 * documentation specify that these functions apply to the window which
905 * is given as an argument. However, ncurses implements this logic
906 * only for the newscr/curscr update process, _not_ per-window.
910 #define _nc_idlok SP->_nc_sp_idlok
911 #define _nc_idcok SP->_nc_sp_idcok
914 * These are the data that support the mouse interface.
916 bool _mouse_initialized;
917 MouseType _mouse_type;
919 bool (*_mouse_event) (SCREEN *);
920 bool (*_mouse_inline)(SCREEN *);
921 bool (*_mouse_parse) (SCREEN *, int);
922 void (*_mouse_resume)(SCREEN *);
923 void (*_mouse_wrap) (SCREEN *);
924 int _mouse_fd; /* file-descriptor, if any */
925 bool _mouse_active; /* true if initialized */
927 NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
928 MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
929 MEVENT *_mouse_eventp; /* next free slot in event queue */
932 bool _mouse_gpm_loaded;
933 bool _mouse_gpm_found;
936 TYPE_gpm_fd _mouse_gpm_fd;
937 TYPE_Gpm_Open _mouse_Gpm_Open;
938 TYPE_Gpm_Close _mouse_Gpm_Close;
939 TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent;
941 Gpm_Connect _mouse_gpm_connect;
942 #endif /* USE_GPM_SUPPORT */
946 int _emxmouse_thread;
947 int _emxmouse_activated;
948 char _emxmouse_buttons[4];
952 MEVENT _sysmouse_fifo[FIFO_SIZE];
955 int _sysmouse_char_width; /* character width */
956 int _sysmouse_char_height; /* character height */
957 int _sysmouse_old_buttons;
958 int _sysmouse_new_buttons;
962 * This supports automatic resizing
965 int (*_resize)(int,int);
969 * These are data that support the proper handling of the panel stack on an
972 struct panelhook _panelHook;
975 SCREEN *_next_screen;
977 /* hashes for old and new lines */
978 unsigned long *oldhash, *newhash;
984 bool _cleanup; /* cleanup after int/quit signal */
985 NCURSES_SP_OUTC _outch; /* output handler if not putc */
987 int _legacy_coding; /* see use_legacy_coding() */
990 char _ttytype[NAMESIZE];
997 const char *_tputs_trace;
1002 char tracechr_buf[40];
1003 char tracemse_buf[TRACEMSE_MAX];
1006 WINDOWLIST* _windowlist;
1007 #define WindowList(sp) (sp)->_windowlist
1011 ripoff_t rippedoff[N_RIPS];
1015 * ncurses/ncursesw are the same up to this point.
1017 #if USE_WIDEC_SUPPORT
1018 /* recent versions of 'screen' have partially-working support for
1019 * UTF-8, but do not permit ACS at the same time (see tty_update.c).
1021 bool _screen_acs_fix;
1025 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
1026 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
1029 WINDOW win; /* first, so WINDOW_EXT() works */
1031 SCREEN *screen; /* screen containing the window */
1032 #ifdef _XOPEN_SOURCE_EXTENDED
1033 char addch_work[(MB_LEN_MAX * 9) + 1];
1034 unsigned addch_used; /* number of bytes in addch_work[] */
1035 int addch_x; /* x-position for addch_work[] */
1036 int addch_y; /* y-position for addch_work[] */
1040 #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
1042 #define SP_PRE_INIT(sp) \
1043 sp->_cursrow = -1; \
1044 sp->_curscol = -1; \
1049 sp->_fifohead = -1; \
1050 sp->_endwin = TRUE; \
1052 WindowList(sp) = 0; \
1053 sp->_outch = NCURSES_SP_NAME(_nc_outch); \
1056 /* usually in <limits.h> */
1058 #define UCHAR_MAX 255
1061 /* The terminfo source is assumed to be 7-bit ASCII */
1062 #define is7bits(c) ((unsigned)(c) < 128)
1064 /* Checks for isprint() should be done on 8-bit characters (non-wide) */
1065 #define is8bits(c) ((unsigned)(c) <= UCHAR_MAX)
1068 #define min(a,b) ((a) > (b) ? (b) : (a))
1072 #define max(a,b) ((a) < (b) ? (b) : (a))
1075 /* usually in <unistd.h> */
1076 #ifndef STDIN_FILENO
1077 #define STDIN_FILENO 0
1080 #ifndef STDOUT_FILENO
1081 #define STDOUT_FILENO 1
1084 #ifndef STDERR_FILENO
1085 #define STDERR_FILENO 2
1088 #ifndef EXIT_SUCCESS
1089 #define EXIT_SUCCESS 0
1092 #ifndef EXIT_FAILURE
1093 #define EXIT_FAILURE 1
1097 #define R_OK 4 /* Test for read permission. */
1100 #define W_OK 2 /* Test for write permission. */
1103 #define X_OK 1 /* Test for execute permission. */
1106 #define F_OK 0 /* Test for existence. */
1110 #include <fcntl.h> /* may define O_BINARY */
1119 #define COUNT_OUTCHARS(n) _nc_count_outchars(n);
1121 #define COUNT_OUTCHARS(n) _nc_outchars += (n);
1124 #define COUNT_OUTCHARS(n) /* nothing */
1127 #define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars)
1129 #define UChar(c) ((unsigned char)(c))
1130 #define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
1131 #define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
1134 #define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
1137 #if USE_WIDEC_SUPPORT /* { */
1138 #define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ))
1140 #define init_mb(state) memset(&state, 0, sizeof(state))
1142 #if NCURSES_EXT_COLORS
1143 #define NulColor , 0
1145 #define NulColor /* nothing */
1148 #define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */
1149 #define CharOf(c) ((c).chars[0])
1150 #define AttrOf(c) ((c).attr)
1152 #define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES)
1153 #define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
1154 #define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c)
1156 #define NewChar2(c,a) { a, { c, NulChar } NulColor }
1157 #define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch))
1160 #define CharEq(a,b) (((a).attr == (b).attr) \
1161 && (a).chars[0] == (b).chars[0] \
1162 && (a).chars[1] == (b).chars[1] \
1163 && (a).chars[2] == (b).chars[2] \
1164 && (a).chars[3] == (b).chars[3] \
1165 && (a).chars[4] == (b).chars[4] \
1166 if_EXT_COLORS(&& (a).ext_color == (b).ext_color))
1168 #define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a)))
1171 #define SetChar(ch,c,a) do { \
1172 NCURSES_CH_T *_cp = &ch; \
1173 memset(_cp, 0, sizeof(ch)); \
1174 _cp->chars[0] = (c); \
1176 if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a))); \
1178 #define CHREF(wch) (&wch)
1179 #define CHDEREF(wch) (*wch)
1180 #define ARG_CH_T NCURSES_CH_T *
1181 #define CARG_CH_T const NCURSES_CH_T *
1182 #define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
1183 mbstate_t PUT_st; wchar_t PUTC_ch
1184 #define PUTC_INIT init_mb (PUT_st)
1185 #define PUTC(ch,b) do { if(!isWidecExt(ch)) { \
1186 if (Charable(ch)) { \
1187 fputc(CharOf(ch), b); \
1188 COUNT_OUTCHARS(1); \
1191 for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \
1192 PUTC_ch = (ch).chars[PUTC_i]; \
1193 if (PUTC_ch == L'\0') \
1195 PUTC_n = wcrtomb(PUTC_buf, \
1196 (ch).chars[PUTC_i], &PUT_st); \
1197 if (PUTC_n <= 0) { \
1198 if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
1202 fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
1204 COUNT_OUTCHARS(PUTC_i); \
1207 #define BLANK NewChar2(' ', WA_NORMAL)
1208 #define ZEROS NewChar2('\0', WA_NORMAL)
1209 #define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
1212 * Wide characters cannot be represented in the A_CHARTEXT mask of
1213 * attr_t's but an application might have set a narrow character there.
1214 * But even in that case, it would only be a printable character, or
1215 * zero. Otherwise we can use those bits to tell if a cell is the
1216 * first or extension part of a wide character.
1218 #define WidecExt(ch) (AttrOf(ch) & A_CHARTEXT)
1219 #define isWidecBase(ch) (WidecExt(ch) == 1)
1220 #define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
1221 #define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \
1222 AttrOf(dst) |= (ext + 1)
1224 #define if_WIDEC(code) code
1225 #define Charable(ch) ((SP_PARM != 0 && SP_PARM->_legacy_coding) \
1226 || (AttrOf(ch) & A_ALTCHARSET) \
1227 || (!isWidecExt(ch) && \
1228 (ch).chars[1] == L'\0' && \
1229 _nc_is_charable(CharOf(ch))))
1231 #define L(ch) L ## ch
1233 #define CharOf(c) ChCharOf(c)
1234 #define AttrOf(c) ChAttrOf(c)
1235 #define AddAttr(c,a) c |= (a)
1236 #define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES)
1237 #define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a)
1238 #define NewChar(ch) (ch)
1239 #define NewChar2(c,a) ((c) | (a))
1240 #define CharEq(a,b) ((a) == (b))
1241 #define SetChar(ch,c,a) ch = (c) | (a)
1242 #define CHREF(wch) wch
1243 #define CHDEREF(wch) wch
1244 #define ARG_CH_T NCURSES_CH_T
1245 #define CARG_CH_T NCURSES_CH_T
1246 #define PUTC_DATA int data = 0
1247 #define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0)
1249 #define BLANK (' '|A_NORMAL)
1250 #define ZEROS ('\0'|A_NORMAL)
1251 #define ISBLANK(ch) (CharOf(ch) == ' ')
1253 #define isWidecExt(ch) (0)
1254 #define if_WIDEC(code) /* nothing */
1259 #define AttrOfD(ch) AttrOf(CHDEREF(ch))
1260 #define CharOfD(ch) CharOf(CHDEREF(ch))
1261 #define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch))
1263 #define BLANK_ATTR A_NORMAL
1264 #define BLANK_TEXT L(' ')
1268 #define LEGALYX(w, y, x) \
1270 ((x) >= 0 && (x) <= (w)->_maxx && \
1271 (y) >= 0 && (y) <= (w)->_maxy))
1273 #define CHANGED_CELL(line,col) \
1274 if (line->firstchar == _NOCHANGE) \
1275 line->firstchar = line->lastchar = col; \
1276 else if ((col) < line->firstchar) \
1277 line->firstchar = col; \
1278 else if ((col) > line->lastchar) \
1279 line->lastchar = col
1281 #define CHANGED_RANGE(line,start,end) \
1282 if (line->firstchar == _NOCHANGE \
1283 || line->firstchar > (start)) \
1284 line->firstchar = start; \
1285 if (line->lastchar == _NOCHANGE \
1286 || line->lastchar < (end)) \
1287 line->lastchar = end
1289 #define CHANGED_TO_EOL(line,start,end) \
1290 if (line->firstchar == _NOCHANGE \
1291 || line->firstchar > (start)) \
1292 line->firstchar = start; \
1293 line->lastchar = end
1295 #define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
1297 #define FreeIfNeeded(p) if ((p) != 0) free(p)
1299 /* FreeAndNull() is not a comma-separated expression because some compilers
1300 * do not accept a mixture of void with values.
1302 #define FreeAndNull(p) free(p); p = 0
1304 #include <nc_alloc.h>
1307 * TTY bit definition for converting tabs to spaces.
1310 # define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */
1313 # define OFLAGS_TABS XTABS /* XTABS is usually the "same" */
1316 # define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */
1318 # define OFLAGS_TABS 0
1324 * Standardize/simplify common loops
1326 #define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen
1327 #define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next
1328 #define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p
1331 * Prefixes for call/return points of library function traces. We use these to
1332 * instrument the public functions so that the traces can be easily transformed
1333 * into regression scripts.
1335 #define T_CALLED(fmt) "called {" fmt
1336 #define T_CREATE(fmt) "create :" fmt
1337 #define T_RETURN(fmt) "return }" fmt
1342 #define TPUTS_TRACE(s) _nc_set_tputs_trace(s);
1344 #define TPUTS_TRACE(s) _nc_tputs_trace = s;
1347 #define START_TRACE() \
1348 if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
1349 int t = _nc_getenv_num("NCURSES_TRACE"); \
1351 trace((unsigned) t); \
1355 * Many of the _tracef() calls use static buffers; lock the trace state before
1356 * trying to fill them.
1359 #define USE_TRACEF(mask) _nc_use_tracef(mask)
1360 extern NCURSES_EXPORT(int) _nc_use_tracef (unsigned);
1361 extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
1363 #define USE_TRACEF(mask) (_nc_tracing & (mask))
1364 #define _nc_locked_tracef _tracef
1367 #define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a
1368 #define T(a) TR(TRACE_CALLS, a)
1369 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
1371 #define returnAttr(code) TRACE_RETURN(code,attr_t)
1372 #define returnBits(code) TRACE_RETURN(code,unsigned)
1373 #define returnBool(code) TRACE_RETURN(code,bool)
1374 #define returnCPtr(code) TRACE_RETURN(code,cptr)
1375 #define returnCVoidPtr(code) TRACE_RETURN(code,cvoid_ptr)
1376 #define returnChtype(code) TRACE_RETURN(code,chtype)
1377 #define returnCode(code) TRACE_RETURN(code,int)
1378 #define returnPtr(code) TRACE_RETURN(code,ptr)
1379 #define returnSP(code) TRACE_RETURN(code,sp)
1380 #define returnVoid T((T_RETURN(""))); return
1381 #define returnVoidPtr(code) TRACE_RETURN(code,void_ptr)
1382 #define returnWin(code) TRACE_RETURN(code,win)
1384 extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
1385 extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
1386 extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
1387 extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
1388 extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
1389 extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
1390 extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
1391 extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
1392 extern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype);
1393 extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
1394 extern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *);
1395 extern NCURSES_EXPORT(int) _nc_retrace_int (int);
1396 extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
1397 extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *);
1398 extern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *);
1401 NCURSES_WRAPPED_VAR(long, _nc_outchars);
1402 NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace);
1403 #define _nc_outchars NCURSES_PUBLIC_VAR(_nc_outchars())
1404 #define _nc_tputs_trace NCURSES_PUBLIC_VAR(_nc_tputs_trace())
1405 extern NCURSES_EXPORT(void) _nc_set_tputs_trace (const char *);
1406 extern NCURSES_EXPORT(void) _nc_count_outchars (long);
1408 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
1409 extern NCURSES_EXPORT_VAR(long) _nc_outchars;
1412 extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
1414 #if USE_WIDEC_SUPPORT
1415 extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
1416 extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
1419 extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int);
1420 extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
1424 #define START_TRACE() /* nothing */
1428 #define TPUTS_TRACE(s)
1430 #define returnAttr(code) return code
1431 #define returnBits(code) return code
1432 #define returnBool(code) return code
1433 #define returnCPtr(code) return code
1434 #define returnCVoidPtr(code) return code
1435 #define returnChtype(code) return code
1436 #define returnCode(code) return code
1437 #define returnPtr(code) return code
1438 #define returnSP(code) return code
1439 #define returnVoid return
1440 #define returnVoidPtr(code) return code
1441 #define returnWin(code) return code
1443 #endif /* TRACE/!TRACE */
1446 * Return-codes for tgetent() and friends.
1448 #define TGETENT_YES 1 /* entry is found */
1449 #define TGETENT_NO 0 /* entry is not found */
1450 #define TGETENT_ERR -1 /* an error occurred */
1452 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
1453 extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
1455 #define EMPTY_MODULE(name) \
1456 extern NCURSES_EXPORT(void) name (void); \
1457 NCURSES_EXPORT(void) name (void) { }
1459 #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
1460 #define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
1461 #define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress)
1463 #define toggle_attr_on(S,at) {\
1464 if (PAIR_NUMBER(at) > 0) {\
1465 (S) = ((S) & ALL_BUT_COLOR) | (at);\
1469 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
1472 #define toggle_attr_off(S,at) {\
1473 if (PAIR_NUMBER(at) > 0) {\
1474 (S) &= ~(at|A_COLOR);\
1478 TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
1480 #define DelCharCost(sp,count) \
1483 : ((delete_character != 0) \
1484 ? (sp->_dch1_cost * count) \
1487 #define InsCharCost(sp,count) \
1490 : ((enter_insert_mode && exit_insert_mode) \
1491 ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \
1492 : ((insert_character != 0) \
1493 ? ((sp->_ich1_cost + sp->_ip_cost) * count) \
1497 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
1498 attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \
1499 VIDATTR(sp, AttrOf(c), GetPair(c)); \
1500 if (magic_cookie_glitch > 0 \
1501 && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(sp))))) { \
1502 T(("%s @%d before glitch %d,%d", \
1503 __FILE__, __LINE__, \
1506 NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \
1510 #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) \
1511 VIDATTR(sp, AttrOf(c), GetPair(c));
1515 * Macros to make additional parameter to implement wgetch_events()
1517 #ifdef NCURSES_WGETCH_EVENTS
1518 #define EVENTLIST_0th(param) param
1519 #define EVENTLIST_1st(param) param
1520 #define EVENTLIST_2nd(param) , param
1522 #define EVENTLIST_0th(param) void
1523 #define EVENTLIST_1st(param) /* nothing */
1524 #define EVENTLIST_2nd(param) /* nothing */
1527 #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
1529 #undef toggle_attr_on
1530 #define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
1531 extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t);
1533 #undef toggle_attr_off
1534 #define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
1535 extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t);
1538 #define DelCharCost(count) _nc_DelCharCost(count)
1539 extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
1542 #define InsCharCost(count) _nc_InsCharCost(count)
1543 extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
1546 #define UpdateAttrs(c) _nc_UpdateAttrs(c)
1547 extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
1551 extern NCURSES_EXPORT(void) _nc_expanded (void);
1555 #if !NCURSES_EXT_FUNCS
1556 #define set_escdelay(value) ESCDELAY = value
1560 #define getcwd(buf,len) getwd(buf)
1564 #if USE_WIDEC_SUPPORT
1565 extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
1566 extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
1567 extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
1572 short nte_name; /* offset of name to hash on */
1573 int nte_type; /* BOOLEAN, NUMBER or STRING */
1574 short nte_index; /* index of associated variable in its array */
1575 short nte_link; /* index in table of next hash, or -1 */
1587 extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
1591 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
1592 extern NCURSES_EXPORT(void) _nc_linedump (void);
1596 extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
1597 extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
1600 #if USE_WIDEC_SUPPORT
1601 NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
1605 #if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
1606 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
1610 extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
1613 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
1616 extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
1619 #define INFINITY 1000000 /* cost: too high to use */
1621 extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
1622 extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
1623 extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
1625 extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
1627 extern NCURSES_EXPORT(void) _nc_screen_init (void);
1628 extern NCURSES_EXPORT(void) _nc_screen_resume (void);
1629 extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
1632 extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *);
1635 #define INFINITY 1000000 /* cost: too high to use */
1636 #define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
1639 extern NCURSES_EXPORT(char *) _nc_get_locale(void);
1640 extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
1641 extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
1642 extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
1643 extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
1647 extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *);
1649 #define _nc_handle_sigwinch(a) /* nothing */
1653 #if USE_WIDEC_SUPPORT
1654 extern NCURSES_EXPORT(void) _nc_init_wacs(void);
1658 char *s_head; /* beginning of the string (may be null) */
1659 char *s_tail; /* end of the string (may be null) */
1660 size_t s_size; /* current remaining size available */
1661 size_t s_init; /* total size available */
1665 extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
1666 extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
1667 extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
1668 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
1669 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
1672 #define strstr _nc_strstr
1673 extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
1676 /* safe_sprintf.c */
1677 extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
1680 extern NCURSES_EXPORT(int) _nc_add_to_try (TRIES **, const char *, unsigned);
1681 extern NCURSES_EXPORT(char *) _nc_expand_try (TRIES *, unsigned, int *, size_t);
1682 extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned);
1683 extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
1686 extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
1687 extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
1688 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
1689 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
1690 extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
1691 extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
1692 extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
1693 extern NCURSES_EXPORT(int) _nc_access (const char *, int);
1694 extern NCURSES_EXPORT(int) _nc_baudrate (int);
1695 extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
1696 extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
1697 extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, bool);
1698 extern NCURSES_EXPORT(int) _nc_ospeed (int);
1699 extern NCURSES_EXPORT(int) _nc_outch (int);
1700 extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *);
1701 extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *);
1702 extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
1703 extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
1704 extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
1705 extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, NCURSES_OUTC);
1706 extern NCURSES_EXPORT(void) _nc_flush (void);
1707 extern NCURSES_EXPORT(void) _nc_free_and_exit (int) GCC_NORETURN;
1708 extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *);
1709 extern NCURSES_EXPORT(void) _nc_freeall (void);
1710 extern NCURSES_EXPORT(void) _nc_hash_map (void);
1711 extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
1712 extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
1713 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
1714 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
1715 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
1716 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
1717 extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
1718 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
1719 extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *);
1722 extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void);
1723 extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
1724 extern NCURSES_EXPORT(void) _nc_codes_leaks(void);
1725 extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void);
1726 extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
1727 extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
1728 extern NCURSES_EXPORT(void) _nc_names_leaks(void);
1729 extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
1733 extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
1734 extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
1735 extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T);
1738 #if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
1739 extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
1743 extern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *);
1747 extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
1749 #define _nc_resize_margins(wp) /* nothing */
1752 #ifdef NCURSES_WGETCH_EVENTS
1753 extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
1755 #define wgetch_events(win, evl) wgetch(win)
1756 #define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
1760 * Not everyone has vsscanf(), but we'd like to use it for scanw().
1763 extern int vsscanf(const char *str, const char *format, va_list __arg);
1766 /* scroll indices */
1767 extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
1769 #define USE_SETBUF_0 0
1771 #define NC_BUFFERED(sp,flag) NCURSES_SP_NAME(_nc_set_buffer)(NCURSES_SP_ARGx sp->_ofp, flag)
1773 #define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout)
1776 * On systems with a broken linker, define 'SP' as a function to force the
1777 * linker to pull in the data-only module with 'SP'.
1780 #define SP _nc_screen()
1781 extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
1782 extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
1783 extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
1784 #define CURRENT_SCREEN _nc_screen()
1786 /* current screen is private data; avoid possible linking conflicts too */
1787 extern NCURSES_EXPORT_VAR(SCREEN *) SP;
1788 #define CURRENT_SCREEN SP
1789 #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
1790 #define _nc_set_screen(sp) SP = sp
1793 #if NCURSES_SP_FUNCS && 0
1794 #define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr())
1796 #define CURRENT_SCREEN_PRE CURRENT_SCREEN
1800 * We don't want to use the lines or columns capabilities internally, because
1801 * if the application is running multiple screens under X, it's quite possible
1802 * they could all have type xterm but have different sizes! So...
1804 #define screen_lines(sp) (sp)->_lines
1805 #define screen_columns(sp) (sp)->_columns
1807 extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
1810 * Some constants related to SLK's
1812 #define MAX_SKEY_OLD 8 /* count of soft keys */
1813 #define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */
1814 #define MAX_SKEY_PC 12 /* This is what most PC's have */
1815 #define MAX_SKEY_LEN_PC 5
1817 /* Macro to check whether or not we use a standard format */
1818 #define SLK_STDFMT(fmt) (fmt < 3)
1819 /* Macro to determine height of label window */
1820 #define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
1822 #define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
1823 #define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
1825 extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
1828 * Common error messages
1830 #define MSG_NO_MEMORY "Out of memory"
1831 #define MSG_NO_INPUTS "Premature EOF"
1833 /* timed_wait flag definitions */
1837 #define TW_ANY (TW_INPUT | TW_MOUSE)
1840 #define SetSafeOutcWrapper(outc) \
1841 SCREEN* sp = CURRENT_SCREEN; \
1843 struct screen dummy; \
1845 memset(sp,0,sizeof(struct screen)); \
1846 sp->_outch = _nc_outc_wrapper; \
1850 struct DriverTCB; /* Terminal Control Block forward declaration */
1851 typedef void* TERM_HANDLE;
1853 typedef struct _termInfo
1871 const color_t* defaultPalette;
1874 typedef struct term_driver {
1876 bool (*CanHandle)(struct DriverTCB*,const char*,int*);
1877 void (*init)(struct DriverTCB*);
1878 void (*release)(struct DriverTCB*);
1879 int (*size)(struct DriverTCB*, int* Line, int *Cols);
1880 int (*sgmode)(struct DriverTCB*, bool setFlag, TTY*);
1881 chtype (*conattr)(struct DriverTCB*);
1882 int (*hwcur)(struct DriverTCB*, int yold, int xold, int y, int x);
1883 int (*mode)(struct DriverTCB*, bool progFlag, bool defFlag);
1884 bool (*rescol)(struct DriverTCB*);
1885 bool (*rescolors)(struct DriverTCB*);
1886 void (*color)(struct DriverTCB*,bool fore, int color, int(*)(SCREEN*,int));
1887 int (*doBeepOrFlash)(struct DriverTCB*, bool);
1888 void (*initpair)(struct DriverTCB*,short,short,short);
1889 void (*initcolor)(struct DriverTCB*,short,short,short,short);
1890 void (*docolor)(struct DriverTCB*,short,short,bool,int(*)(SCREEN*,int));
1891 void (*initmouse)(struct DriverTCB*);
1892 void (*setfilter)(struct DriverTCB*);
1893 void (*hwlabel)(struct DriverTCB*,int,char*);
1894 void (*hwlabelOnOff)(struct DriverTCB*,bool);
1895 int (*update)(struct DriverTCB*);
1896 int (*defaultcolors)(struct DriverTCB*,int,int);
1897 int (*print)(struct DriverTCB*,char*,int);
1898 int (*getsize)(struct DriverTCB*,int*,int*);
1899 int (*setsize)(struct DriverTCB*,int,int);
1900 void (*initacs)(struct DriverTCB*,chtype*,chtype*);
1901 void (*scinit)(SCREEN *);
1902 void (*scexit)(SCREEN *);
1903 int (*twait)(struct DriverTCB*,int,int,int* EVENTLIST_2nd(_nc_eventlist*));
1904 int (*read)(struct DriverTCB*,int*);
1905 int (*nap)(struct DriverTCB*,int);
1906 int (*kpad)(struct DriverTCB*, bool);
1907 int (*kyOk)(struct DriverTCB*, int, bool);
1908 bool (*kyExist)(struct DriverTCB*, int);
1912 typedef struct DriverTCB
1914 TERMINAL term; /* needs to be the first Element !!! */
1915 TERM_HANDLE inp; /* The input handle of the Terminal */
1916 TERM_HANDLE out; /* The output handle of the Terminal in shell mode */
1917 TERM_HANDLE hdl; /* The output handle of the Terminal in prog mode */
1918 TERM_DRIVER* drv; /* The driver for that Terminal */
1919 SCREEN* csp; /* The screen that owns that Terminal */
1920 TerminalInfo info; /* Driver independent core capabilities of the Terminal */
1921 void* prop; /* Driver dependent property storage to be used by the Driver */
1923 } TERMINAL_CONTROL_BLOCK;
1925 #define NCDRV_MAGIC(id) (0x47110000 | (id&0xffff))
1926 #define NCDRV_TINFO 0x01
1927 #define NCDRV_WINCONSOLE 0x02
1929 #define TCBOf(sp) ((TERMINAL_CONTROL_BLOCK*)(TerminalOf(sp)))
1930 #define InfoOf(sp) TCBOf(sp)->info
1931 #define CallDriver(sp,method) TCBOf(sp)->drv->method(TCBOf(sp))
1932 #define CallDriver_1(sp,method,arg1) TCBOf(sp)->drv->method(TCBOf(sp),arg1)
1933 #define CallDriver_2(sp,method,arg1,arg2) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2)
1934 #define CallDriver_3(sp,method,arg1,arg2,arg3) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3)
1935 #define CallDriver_4(sp,method,arg1,arg2,arg3,arg4) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3,arg4)
1937 extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette;
1938 extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette;
1941 #include <nc_mingw.h>
1942 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
1944 extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
1947 #define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo)))
1949 #define IsTermInfo(sp) TRUE
1952 #define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
1953 #define IsValidTIScreen(sp) (HasTInfoTerminal(sp))
1956 * Exported entrypoints beyond the published API
1958 #if NCURSES_SP_FUNCS
1959 extern NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN*);
1960 extern NCURSES_EXPORT(WINDOW *) _nc_newscr_of(SCREEN*);
1961 extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*);
1962 extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int);
1965 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_ttytype)(SCREEN*);
1966 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*);
1967 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*);
1970 #if NCURSES_EXT_FUNCS
1971 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int);
1975 * We put the safe versions of various calls here as they are not published
1976 * part of the API up to now
1978 extern NCURSES_EXPORT(SCREEN*) _nc_SP(void);
1980 extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_set_curterm)(SCREEN*,TERMINAL*);
1981 extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(cur_term)(SCREEN *sp);
1982 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int);
1983 extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*);
1984 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);
1985 extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int);
1986 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_curs_set)(SCREEN*,int);
1987 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*);
1988 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int);
1989 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int);
1990 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int);
1991 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char *);
1992 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *);
1993 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resetty)(SCREEN*);
1994 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int);
1995 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int));
1996 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_savetty)(SCREEN*);
1997 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*);
1998 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const char*);
1999 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int);
2000 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*);
2001 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, bool, int);
2002 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
2003 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*);
2004 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, short, void *);
2005 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int));
2006 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, short, short, bool, NCURSES_SP_OUTC);
2007 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
2008 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*);
2009 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
2010 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall)(SCREEN*);
2011 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_hash_map)(SCREEN*);
2012 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_init_acs)(SCREEN*);
2013 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i);
2014 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init)(SCREEN*);
2015 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume)(SCREEN*);
2016 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_wrap)(SCREEN*);
2017 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_init)(SCREEN*);
2018 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_resume)(SCREEN*);
2019 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*);
2020 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot);
2021 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*);
2022 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, bool);
2024 extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp);
2025 extern NCURSES_EXPORT(int) _nc_tinfo_doupdate(SCREEN *sp);
2026 extern NCURSES_EXPORT(int) _nc_tinfo_mcprint(SCREEN*,char*,int);
2028 #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
2029 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*);
2032 #if USE_WIDEC_SUPPORT
2033 extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *);
2036 #endif /* NCURSES_SP_FUNCS */
2038 #if NCURSES_SP_FUNCS
2040 #define safe_keyname NCURSES_SP_NAME(keyname)
2041 #define safe_unctrl NCURSES_SP_NAME(unctrl)
2042 #define safe_ungetch NCURSES_SP_NAME(ungetch)
2046 #define safe_keyname _nc_keyname
2047 #define safe_unctrl _nc_unctrl
2048 #define safe_ungetch _nc_ungetch
2050 extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
2051 extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
2052 extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
2060 #endif /* CURSES_PRIV_H */