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.7 2021/11/20 23:33:33 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 */
80 const char * tparam_base;
82 STACK_FRAME stack[STACKSIZE];
92 int static_vars[NUM_VARS];
109 * Internals for term.h
111 typedef struct term { /* describe an actual terminal */
112 TERMTYPE type; /* terminal type description */
113 short Filedes; /* file description being written to */
114 TTY Ottyb; /* original state of the terminal */
115 TTY Nttyb; /* current state of the terminal */
116 int _baudrate; /* used to compute padding */
117 char * _termname; /* used for termname() */
118 TPARM_STATE tparm_state;
119 #if NCURSES_EXT_COLORS
120 TERMTYPE2 type2; /* extended terminal type description */
126 * Internals for soft-keys
129 WINDOW * win; /* the window used in the hook */
130 int line; /* lines to take, < 0 => from bottom*/
131 int (*hook)(WINDOW *, int); /* callback for user */
135 * Internals for tgetent
140 char * fix_sgr0; /* this holds the filtered sgr0 string */
141 char * last_bufp; /* help with fix_sgr0 leak */
142 TERMINAL * last_term;
145 #define TGETENT_MAX 4
147 #include <term_entry.h> /* dbdLAST */
149 #ifdef USE_TERM_DRIVER
150 struct DriverTCB; /* Terminal Control Block forward declaration */
154 * Global data which is not specific to a screen.
157 SIG_ATOMIC_T have_sigtstp;
158 SIG_ATOMIC_T have_sigwinch;
159 SIG_ATOMIC_T cleanup_nested;
164 char * comp_sourcename;
165 char * comp_termtype;
167 bool have_tic_directory;
168 bool keep_tic_directory;
169 const char * tic_directory;
175 char ** keyname_table;
180 int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */
182 char * safeprint_buf;
183 size_t safeprint_used;
185 TGETENT_CACHE tgetent_cache[TGETENT_MAX];
187 long tgetent_sequence;
190 char * dbd_blob; /* string-heap for dbd_list[] */
191 char ** dbd_list; /* distinct places to look for data */
192 int dbd_size; /* length of dbd_list[] */
193 time_t dbd_time; /* cache last updated */
194 ITERATOR_VARS dbd_vars[dbdLAST];
199 #endif /* HAVE_TSEARCH */
201 #ifdef USE_TERM_DRIVER
202 int (*term_driver)(struct DriverTCB*, const char*, int*);
205 #define WINDOWLIST struct _win_list
207 #ifndef USE_SP_WINDOWLIST
208 WINDOWLIST * _nc_windowlist;
209 #define WindowList(sp) _nc_globals._nc_windowlist
212 #if USE_HOME_TERMINFO
213 char * home_terminfo;
216 #if !USE_SAFE_SPRINTF
222 pthread_mutex_t mutex_curses;
223 pthread_mutex_t mutex_prescreen;
224 pthread_mutex_t mutex_screen;
225 pthread_mutex_t mutex_update;
226 pthread_mutex_t mutex_tst_tracef;
227 pthread_mutex_t mutex_tracef;
230 #define _nc_use_pthreads _nc_globals.use_pthreads
231 #if USE_PTHREADS_EINTR
232 pthread_t read_thread; /* The reading thread */
235 #if USE_WIDEC_SUPPORT
236 char key_name[MB_LEN_MAX + 1];
241 char trace_fname[PATH_MAX];
247 size_t tracearg_used;
249 TRACEBUF * tracebuf_ptr;
250 size_t tracebuf_used;
252 char tracechr_buf[40];
255 size_t tracedmp_used;
257 unsigned char * tracetry_buf;
258 size_t tracetry_used;
260 char traceatr_color_buf[2][80];
261 int traceatr_color_sel;
262 int traceatr_color_last;
263 #if !defined(USE_PTHREADS) && USE_REENTRANT
273 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
278 typedef struct _prescreen_list {
279 struct _prescreen_list *next;
286 * Global data which can be swept up into a SCREEN when one is created.
287 * It may be modified before the next SCREEN is created.
291 PRESCREEN_LIST *allocated;
293 struct screen * allocated;
297 attr_t previous_attr;
298 TPARM_STATE tparm_state;
299 TTY * saved_tty; /* savetty/resetty information */
301 NCURSES_SP_OUTC _outch; /* output handler if not putc */
302 #ifndef USE_SP_RIPOFF
303 ripoff_t rippedoff[N_RIPS];
306 #if NCURSES_NO_PADDING
307 bool _no_padding; /* flag to set if padding disabled */
309 #if BROKEN_LINKER || USE_REENTRANT
310 chtype * real_acs_map;
315 TERMINAL * _cur_term;
318 #if BROKEN_LINKER || USE_REENTRANT
320 const char * _tputs_trace;
325 extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
327 extern NCURSES_EXPORT(void) _nc_free_tparm(TERMINAL*);
335 #endif /* _TERM_PRIV_H */