1 /****************************************************************************
2 * Copyright 2021,2023 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.8 2023/09/16 15:16:38 tom Exp $
34 * Header file for terminfo library objects which are private to
39 #define _TERM_PRIV_H 1
46 #include <ncurses_cfg.h>
53 #define NCURSES_INTERNALS 1
54 #define NCURSES_OPAQUE 0
56 #include <limits.h> /* PATH_MAX */
57 #include <signal.h> /* sig_atomic_t */
58 #include <time.h> /* time_t */
59 #include <term.h> /* time_t */
83 const char * tparam_base;
85 STACK_FRAME stack[STACKSIZE];
95 int static_vars[NUM_VARS];
112 * Internals for term.h
114 typedef struct term { /* describe an actual terminal */
115 TERMTYPE type; /* terminal type description */
116 short Filedes; /* file description being written to */
117 TTY Ottyb; /* original state of the terminal */
118 TTY Nttyb; /* current state of the terminal */
119 int _baudrate; /* used to compute padding */
120 char * _termname; /* used for termname() */
121 TPARM_STATE tparm_state;
122 #if NCURSES_EXT_COLORS
123 TERMTYPE2 type2; /* extended terminal type description */
129 * Internals for soft-keys
132 WINDOW * win; /* the window used in the hook */
133 int line; /* lines to take, < 0 => from bottom*/
134 int (*hook)(WINDOW *, int); /* callback for user */
138 * Internals for tgetent
143 char * fix_sgr0; /* this holds the filtered sgr0 string */
144 char * last_bufp; /* help with fix_sgr0 leak */
145 TERMINAL * last_term;
148 #define TGETENT_MAX 4
150 #include <term_entry.h> /* dbdLAST */
152 #ifdef USE_TERM_DRIVER
153 struct DriverTCB; /* Terminal Control Block forward declaration */
157 * Global data which is not specific to a screen.
160 SIG_ATOMIC_T have_sigtstp;
161 SIG_ATOMIC_T have_sigwinch;
162 SIG_ATOMIC_T cleanup_nested;
167 char * comp_sourcename;
168 char * comp_termtype;
170 bool have_tic_directory;
171 bool keep_tic_directory;
172 const char * tic_directory;
178 char ** keyname_table;
183 int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */
185 char * safeprint_buf;
186 size_t safeprint_used;
188 TGETENT_CACHE tgetent_cache[TGETENT_MAX];
190 long tgetent_sequence;
193 char * dbd_blob; /* string-heap for dbd_list[] */
194 char ** dbd_list; /* distinct places to look for data */
195 int dbd_size; /* length of dbd_list[] */
196 time_t dbd_time; /* cache last updated */
197 ITERATOR_VARS dbd_vars[dbdLAST];
202 #endif /* HAVE_TSEARCH */
204 #ifdef USE_TERM_DRIVER
205 int (*term_driver)(struct DriverTCB*, const char*, int*);
208 #define WINDOWLIST struct _win_list
210 #ifndef USE_SP_WINDOWLIST
211 WINDOWLIST * _nc_windowlist;
212 #define WindowList(sp) _nc_globals._nc_windowlist
215 #if USE_HOME_TERMINFO
216 char * home_terminfo;
219 #if !USE_SAFE_SPRINTF
225 pthread_mutex_t mutex_curses;
226 pthread_mutex_t mutex_prescreen;
227 pthread_mutex_t mutex_screen;
228 pthread_mutex_t mutex_update;
229 pthread_mutex_t mutex_tst_tracef;
230 pthread_mutex_t mutex_tracef;
233 #define _nc_use_pthreads _nc_globals.use_pthreads
234 #if USE_PTHREADS_EINTR
235 pthread_t read_thread; /* The reading thread */
238 #if USE_WIDEC_SUPPORT
239 char key_name[MB_LEN_MAX + 1];
244 char trace_fname[PATH_MAX];
250 size_t tracearg_used;
252 TRACEBUF * tracebuf_ptr;
253 size_t tracebuf_used;
255 char tracechr_buf[40];
258 size_t tracedmp_used;
260 unsigned char * tracetry_buf;
261 size_t tracetry_used;
263 char traceatr_color_buf[2][80];
264 int traceatr_color_sel;
265 int traceatr_color_last;
266 #if !defined(USE_PTHREADS) && USE_REENTRANT
276 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
281 typedef struct _prescreen_list {
282 struct _prescreen_list *next;
289 * Global data which can be swept up into a SCREEN when one is created.
290 * It may be modified before the next SCREEN is created.
294 PRESCREEN_LIST *allocated;
296 struct screen * allocated;
300 attr_t previous_attr;
301 TPARM_STATE tparm_state;
302 TTY * saved_tty; /* savetty/resetty information */
304 NCURSES_SP_OUTC _outch; /* output handler if not putc */
305 #ifndef USE_SP_RIPOFF
306 ripoff_t rippedoff[N_RIPS];
309 #if NCURSES_NO_PADDING
310 bool _no_padding; /* flag to set if padding disabled */
312 #if BROKEN_LINKER || USE_REENTRANT
313 chtype * real_acs_map;
318 TERMINAL * _cur_term;
321 #if BROKEN_LINKER || USE_REENTRANT
323 const char * _tputs_trace;
328 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
330 extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*);
338 #endif /* _TERM_PRIV_H */