1 /****************************************************************************
2 * Copyright 2021-2023,2024 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.13 2024/03/02 20:43:06 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
57 # include <limits.h> /* PATH_MAX, MB_LEN_MAX, etc */
58 #elif HAVE_SYS_PARAM_H
59 # include <sys/param.h>
62 #include <signal.h> /* sig_atomic_t */
63 #include <time.h> /* time_t */
64 #include <term.h> /* time_t */
73 * If not properly configured to use the system's limits.h, we get gcc's
74 * fallback for limits.h which sets MB_LEN_MAX to 1, which is never correct.
76 #if !HAVE_CONSISTENT_MB_LEN_MAX
81 #define MB_LEN_MAX 16 /* should be >= MB_CUR_MAX, but that may be a function */
85 # if defined(_POSIX_PATH_MAX)
86 # define PATH_MAX _POSIX_PATH_MAX
87 # elif defined(MAXPATHLEN)
88 # define PATH_MAX MAXPATHLEN
90 # define PATH_MAX 255 /* the Posix minimum path-size */
110 const char * tparam_base;
112 STACK_FRAME stack[STACKSIZE];
122 int static_vars[NUM_VARS];
139 * Internals for term.h
141 typedef struct term { /* describe an actual terminal */
142 TERMTYPE type; /* terminal type description */
143 short Filedes; /* file description being written to */
144 TTY Ottyb; /* original state of the terminal */
145 TTY Nttyb; /* current state of the terminal */
146 int _baudrate; /* used to compute padding */
147 char * _termname; /* used for termname() */
148 TPARM_STATE tparm_state;
149 #if NCURSES_EXT_COLORS
150 TERMTYPE2 type2; /* extended terminal type description */
156 * Internals for soft-keys
159 WINDOW * win; /* the window used in the hook */
160 int line; /* lines to take, < 0 => from bottom*/
161 int (*hook)(WINDOW *, int); /* callback for user */
165 * Internals for tgetent
170 char * fix_sgr0; /* this holds the filtered sgr0 string */
171 char * last_bufp; /* help with fix_sgr0 leak */
172 TERMINAL * last_term;
175 #define TGETENT_MAX 4
177 #include <term_entry.h> /* dbdLAST */
179 #ifdef USE_TERM_DRIVER
180 struct DriverTCB; /* Terminal Control Block forward declaration */
184 * Global data which is not specific to a screen.
187 SIG_ATOMIC_T have_sigtstp;
188 SIG_ATOMIC_T have_sigwinch;
189 SIG_ATOMIC_T cleanup_nested;
194 char * comp_sourcename;
195 char * comp_termtype;
197 bool have_tic_directory;
198 bool keep_tic_directory;
199 const char * tic_directory;
205 char ** keyname_table;
210 int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */
212 char * safeprint_buf;
213 size_t safeprint_used;
215 TGETENT_CACHE tgetent_cache[TGETENT_MAX];
217 long tgetent_sequence;
220 char * dbd_blob; /* string-heap for dbd_list[] */
221 char ** dbd_list; /* distinct places to look for data */
222 int dbd_size; /* length of dbd_list[] */
223 time_t dbd_time; /* cache last updated */
224 ITERATOR_VARS dbd_vars[dbdLAST];
229 #endif /* HAVE_TSEARCH */
231 #ifdef USE_TERM_DRIVER
232 int (*term_driver)(struct DriverTCB*, const char*, int*);
235 #define WINDOWLIST struct _win_list
237 #ifndef USE_SP_WINDOWLIST
238 WINDOWLIST * _nc_windowlist;
239 #define WindowList(sp) _nc_globals._nc_windowlist
242 #if USE_HOME_TERMINFO
243 char * home_terminfo;
246 #if !USE_SAFE_SPRINTF
252 pthread_mutex_t mutex_curses;
253 pthread_mutex_t mutex_prescreen;
254 pthread_mutex_t mutex_screen;
255 pthread_mutex_t mutex_update;
256 pthread_mutex_t mutex_tst_tracef;
257 pthread_mutex_t mutex_tracef;
260 #define _nc_use_pthreads _nc_globals.use_pthreads
261 #if USE_PTHREADS_EINTR
262 pthread_t read_thread; /* The reading thread */
265 #if USE_WIDEC_SUPPORT
266 char key_name[MB_LEN_MAX + 1];
276 size_t tracearg_used;
278 TRACEBUF * tracebuf_ptr;
279 size_t tracebuf_used;
281 char tracechr_buf[40];
284 size_t tracedmp_used;
286 unsigned char * tracetry_buf;
287 size_t tracetry_used;
289 char traceatr_color_buf[2][80];
290 int traceatr_color_sel;
291 int traceatr_color_last;
292 #if !defined(USE_PTHREADS) && USE_REENTRANT
302 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
307 typedef struct _prescreen_list {
308 struct _prescreen_list *next;
315 * Global data which can be swept up into a SCREEN when one is created.
316 * It may be modified before the next SCREEN is created.
320 PRESCREEN_LIST *allocated;
322 struct screen * allocated;
326 attr_t previous_attr;
327 TPARM_STATE tparm_state;
328 TTY * saved_tty; /* savetty/resetty information */
330 NCURSES_SP_OUTC _outch; /* output handler if not putc */
331 #ifndef USE_SP_RIPOFF
332 ripoff_t rippedoff[N_RIPS];
335 #if NCURSES_NO_PADDING
336 bool _no_padding; /* flag to set if padding disabled */
338 #if BROKEN_LINKER || USE_REENTRANT
339 chtype * real_acs_map;
344 TERMINAL * _cur_term;
347 #if BROKEN_LINKER || USE_REENTRANT
349 const char * _tputs_trace;
354 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
356 extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*);
364 #endif /* _TERM_PRIV_H */