1 /****************************************************************************
2 * Copyright 2021 Thomas E. Dickey *
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 ****************************************************************************/
30 * $Id: term.priv.h,v 1.5 2021/09/24 16:42:04 tom Exp $
34 * Header file for terminfo library objects which are private to
40 #define _TERM_PRIV_H 1
47 #include <ncurses_cfg.h>
50 #define NCURSES_INTERNALS 1
51 #define NCURSES_OPAQUE 0
53 #include <limits.h> /* PATH_MAX */
54 #include <signal.h> /* sig_atomic_t */
55 #include <time.h> /* time_t */
56 #include <term.h> /* time_t */
74 const char * tparam_base;
76 STACK_FRAME stack[STACKSIZE];
86 int static_vars[NUM_VARS];
103 * Internals for term.h
105 typedef struct term { /* describe an actual terminal */
106 TERMTYPE type; /* terminal type description */
107 short Filedes; /* file description being written to */
108 TTY Ottyb; /* original state of the terminal */
109 TTY Nttyb; /* current state of the terminal */
110 int _baudrate; /* used to compute padding */
111 char * _termname; /* used for termname() */
112 TPARM_STATE tparm_state;
113 #if NCURSES_EXT_COLORS
114 TERMTYPE2 type2; /* extended terminal type description */
120 * Internals for soft-keys
123 WINDOW * win; /* the window used in the hook */
124 int line; /* lines to take, < 0 => from bottom*/
125 int (*hook)(WINDOW *, int); /* callback for user */
129 * Internals for tgetent
134 char * fix_sgr0; /* this holds the filtered sgr0 string */
135 char * last_bufp; /* help with fix_sgr0 leak */
136 TERMINAL * last_term;
139 #define TGETENT_MAX 4
141 #include <term_entry.h> /* dbdLAST */
143 #ifdef USE_TERM_DRIVER
144 struct DriverTCB; /* Terminal Control Block forward declaration */
148 * Global data which is not specific to a screen.
151 SIG_ATOMIC_T have_sigtstp;
152 SIG_ATOMIC_T have_sigwinch;
153 SIG_ATOMIC_T cleanup_nested;
158 char * comp_sourcename;
159 char * comp_termtype;
161 bool have_tic_directory;
162 bool keep_tic_directory;
163 const char * tic_directory;
169 char ** keyname_table;
174 int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */
176 char * safeprint_buf;
177 size_t safeprint_used;
179 TGETENT_CACHE tgetent_cache[TGETENT_MAX];
181 long tgetent_sequence;
183 char * dbd_blob; /* string-heap for dbd_list[] */
184 char ** dbd_list; /* distinct places to look for data */
185 int dbd_size; /* length of dbd_list[] */
186 time_t dbd_time; /* cache last updated */
187 ITERATOR_VARS dbd_vars[dbdLAST];
192 #endif /* HAVE_TSEARCH */
194 #ifdef USE_TERM_DRIVER
195 int (*term_driver)(struct DriverTCB*, const char*, int*);
198 #define WINDOWLIST struct _win_list
200 #ifndef USE_SP_WINDOWLIST
201 WINDOWLIST * _nc_windowlist;
202 #define WindowList(sp) _nc_globals._nc_windowlist
205 #if USE_HOME_TERMINFO
206 char * home_terminfo;
209 #if !USE_SAFE_SPRINTF
215 pthread_mutex_t mutex_curses;
216 pthread_mutex_t mutex_prescreen;
217 pthread_mutex_t mutex_screen;
218 pthread_mutex_t mutex_update;
219 pthread_mutex_t mutex_tst_tracef;
220 pthread_mutex_t mutex_tracef;
223 #define _nc_use_pthreads _nc_globals.use_pthreads
224 #if USE_PTHREADS_EINTR
225 pthread_t read_thread; /* The reading thread */
228 #if USE_WIDEC_SUPPORT
229 char key_name[MB_LEN_MAX + 1];
234 char trace_fname[PATH_MAX];
240 size_t tracearg_used;
242 TRACEBUF * tracebuf_ptr;
243 size_t tracebuf_used;
245 char tracechr_buf[40];
248 size_t tracedmp_used;
250 unsigned char * tracetry_buf;
251 size_t tracetry_used;
253 char traceatr_color_buf[2][80];
254 int traceatr_color_sel;
255 int traceatr_color_last;
256 #if !defined(USE_PTHREADS) && USE_REENTRANT
266 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
271 typedef struct _prescreen_list {
272 struct _prescreen_list *next;
279 * Global data which can be swept up into a SCREEN when one is created.
280 * It may be modified before the next SCREEN is created.
284 PRESCREEN_LIST *allocated;
286 struct screen * allocated;
290 attr_t previous_attr;
291 TPARM_STATE tparm_state;
292 TTY * saved_tty; /* savetty/resetty information */
294 NCURSES_SP_OUTC _outch; /* output handler if not putc */
295 #ifndef USE_SP_RIPOFF
296 ripoff_t rippedoff[N_RIPS];
299 #if NCURSES_NO_PADDING
300 bool _no_padding; /* flag to set if padding disabled */
302 #if BROKEN_LINKER || USE_REENTRANT
303 chtype * real_acs_map;
308 TERMINAL * _cur_term;
311 #if BROKEN_LINKER || USE_REENTRANT
313 const char * _tputs_trace;
318 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
326 #endif /* _TERM_PRIV_H */