X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=66ac9db25ccb88ad630f68c58eab2e2043cb9aeb;hp=d01109c5dcd4833917bfbee64093ccd8604cfca1;hb=a20e6eb464be80b9cd8cae7ce925d27fe9c209ed;hpb=3eda6f30a84d53844d2ebceadb457e2e7e9cfbf3 diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index d01109c5..66ac9db2 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.567 2017/04/01 17:10:55 tom Exp $ + * $Id: curses.priv.h,v 1.584 2017/08/04 09:02:33 tom Exp $ * * curses.priv.h * @@ -332,6 +332,15 @@ typedef struct } color_t; +typedef union { + struct { + unsigned char red; + unsigned char green; + unsigned char blue; + } bits; /* bits per color-value in RGB */ + unsigned value; +} rgb_bits_t; + /* * If curses.h did not expose the SCREEN-functions, then we do not need the * parameter in the corresponding unextended functions. @@ -358,6 +367,9 @@ color_t; #include +#include +#include + #define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen) #define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term))) #define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp)) @@ -374,8 +386,27 @@ color_t; #define TerminalOf(sp) CurTerm #endif -#include -#include +/* + * The legacy layout for TERMTYPE uses "short" for all of the numbers. Moving + * past that, numeric capabilities can be "int" by using a TERMTYPE2 structure + * in TERMINAL, and doing most of the internal work using TERMTYPE2. There are + * a few places (mostly to expose the legacy layout) where the distinction + * needs attention. + */ +#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR +#define NCURSES_EXT_NUMBERS 1 +#define NCURSES_INT2 int +#define TerminalType(tp) (tp)->type2 +#else +#define NCURSES_EXT_NUMBERS 0 +#define NCURSES_INT2 short +#define TerminalType(tp) (tp)->type +#endif + +#ifdef CUR +#undef CUR +#define CUR TerminalType(cur_term). +#endif /* * Reduce dependency on cur_term global by using terminfo data from SCREEN's @@ -385,7 +416,7 @@ color_t; #undef CUR #endif -#define SP_TERMTYPE TerminalOf(sp)->type. +#define SP_TERMTYPE TerminalType(TerminalOf(sp)). #include @@ -635,6 +666,9 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); /* * Definitions for color pairs */ + +#define MAX_OF_TYPE(t) (int)(((unsigned t)(~0))>>1) + #include /* @@ -767,6 +801,16 @@ typedef struct { #define TGETENT_MAX 4 +/* + * When converting from terminfo to termcap, check for cases where we can trim + * octal escapes down to 2-character form. It is useful for terminfo format + * also, but not as important. + */ +#define MAX_TC_FIXUPS 10 +#define MIN_TC_FIXUPS 4 + +#define isoctal(c) ((c) >= '0' && (c) <= '7') + /* * State of tparm(). */ @@ -928,9 +972,15 @@ typedef struct { int nested_tracef; #endif #endif /* TRACE */ +#if NO_LEAKS + bool leak_checking; +#endif #ifdef USE_PTHREADS pthread_mutex_t mutex_curses; + pthread_mutex_t mutex_prescreen; + pthread_mutex_t mutex_screen; + pthread_mutex_t mutex_update; pthread_mutex_t mutex_tst_tracef; pthread_mutex_t mutex_tracef; int nested_tracef; @@ -949,11 +999,24 @@ extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; #define N_RIPS 5 +#ifdef USE_PTHREADS +typedef struct _prescreen_list { + struct _prescreen_list *next; + pthread_t id; + struct screen *sp; +} PRESCREEN_LIST; +#endif + /* * Global data which can be swept up into a SCREEN when one is created. * It may be modified before the next SCREEN is created. */ typedef struct { +#ifdef USE_PTHREADS + PRESCREEN_LIST *allocated; +#else + struct screen * allocated; +#endif bool use_env; bool filter_mode; attr_t previous_attr; @@ -995,6 +1058,12 @@ typedef struct { extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen; +typedef enum { + ewInitial = 0, + ewRunning, + ewSuspend +} ENDWIN; + /* * The SCREEN structure. */ @@ -1100,17 +1169,14 @@ struct screen { int _scrolling; /* 1 if terminal's smart enough to */ /* used in lib_color.c */ + rgb_bits_t _direct_color; /* RGB overrides color-table */ color_t *_color_table; /* screen's color palette */ int _color_count; /* count of colors in palette */ colorpair_t *_color_pairs; /* screen's color pair list */ int _pair_count; /* same as COLOR_PAIRS */ int _pair_limit; /* actual limit of color-pairs */ + int _pair_alloc; /* current table-size of color-pairs */ #if NCURSES_EXT_FUNCS -#if USE_NEW_PAIR - void *_ordered_pairs; /* index used by alloc_pair() */ - int _pairs_used; /* actual number of color-pairs used */ - int _recent_pair; /* number for most recent free-pair */ -#endif bool _assumed_color; /* use assumed colors */ bool _default_color; /* use default colors */ bool _has_sgr_39_49; /* has ECMA default color support */ @@ -1271,6 +1337,11 @@ struct screen { bool _screen_acs_fix; bool _screen_unicode; #endif +#if NCURSES_EXT_FUNCS && USE_NEW_PAIR + void *_ordered_pairs; /* index used by alloc_pair() */ + int _pairs_used; /* actual number of color-pairs used */ + int _recent_pair; /* number for most recent free-pair */ +#endif }; extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; @@ -1304,7 +1375,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; sp->_cbreak = 0; \ sp->_echo = TRUE; \ sp->_fifohead = -1; \ - sp->_endwin = TRUE; \ + sp->_endwin = ewSuspend; \ sp->_cursor = -1; \ SP_INIT_WINDOWLIST(sp); \ sp->_outch = NCURSES_OUTC_FUNC; \ @@ -1422,6 +1493,8 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; && (a).chars[3] == (b).chars[3] \ && (a).chars[4] == (b).chars[4] \ if_EXT_COLORS(&& (a).ext_color == (b).ext_color)) +#elif CCHARW_MAX > 0 +#error Inconsistent values for CCHARW_MAX #else #define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a))) #endif @@ -1649,7 +1722,7 @@ extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE typedef void VoidFunc(void); -#define TR_FUNC(value) ((const char*) &(value)) +#define TR_FUNC(value) ((const char*) (value)) #define NonNull(s) ((s) != 0 ? s : "") #define returnAttr(code) TRACE_RETURN(code,attr_t) @@ -1887,6 +1960,14 @@ extern NCURSES_EXPORT(void) _nc_expanded (void); #define getcwd(buf,len) getwd(buf) #endif +#define save_ttytype(termp) \ + if (TerminalType(termp).term_names != 0) { \ + _nc_STRNCPY(ttytype, \ + TerminalType(termp).term_names, \ + NAMESIZE - 1); \ + ttytype[NAMESIZE - 1] = '\0'; \ + } + /* charable.c */ #if USE_WIDEC_SUPPORT extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t); @@ -1938,6 +2019,7 @@ extern NCURSES_EXPORT(int) _nc_init_color(SCREEN *, int, int, int, int); extern NCURSES_EXPORT(int) _nc_init_pair(SCREEN *, int, int, int); extern NCURSES_EXPORT(int) _nc_pair_content(SCREEN *, int, int *, int *); extern NCURSES_EXPORT(bool) _nc_reset_colors(void); +extern NCURSES_EXPORT(colorpair_t *) _nc_reserve_pairs(SCREEN *, int); extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int); /* lib_getch.c */ @@ -1975,17 +2057,32 @@ extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, int); extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); +#ifdef USE_PTHREADS +extern NCURSES_EXPORT(SCREEN *) _nc_find_prescr(void); +extern NCURSES_EXPORT(void) _nc_forget_prescr(void); +#else +#define _nc_find_prescr() _nc_prescreen.allocated +#define _nc_forget_prescr() _nc_prescreen.allocated = 0 +#endif + /* lib_set_term.c */ extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); /* lib_setup.c */ +#if NO_LEAKS +#define ExitTerminfo(code) _nc_free_tinfo(code) +#else +#define ExitTerminfo(code) exit(code) +#endif + #define SETUP_FAIL ERR + #define ret_error(code, fmt, arg) if (errret) {\ *errret = code;\ returnCode(SETUP_FAIL);\ } else {\ fprintf(stderr, fmt, arg);\ - exit(EXIT_FAILURE);\ + ExitTerminfo(EXIT_FAILURE);\ } #define ret_error1(code, fmt, arg) ret_error(code, "'%s': " fmt, arg) @@ -1995,7 +2092,7 @@ extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int)); returnCode(SETUP_FAIL);\ } else {\ fprintf(stderr, msg);\ - exit(EXIT_FAILURE);\ + ExitTerminfo(EXIT_FAILURE);\ } /* lib_tstp.c */ @@ -2039,7 +2136,6 @@ extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned); extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); /* elsewhere ... */ -extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *); extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *); extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void); extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int); @@ -2058,14 +2154,15 @@ extern NCURSES_EXPORT(int) _nc_outch (int); extern NCURSES_EXPORT(int) _nc_putchar (int); extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *); extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *); -extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const); -extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *); +extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 *const); +extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *); extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int); extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); +extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const); extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC); extern NCURSES_EXPORT(void) _nc_flush (void); extern NCURSES_EXPORT(void) _nc_free_and_exit (int) GCC_NORETURN; -extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE *); +extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE2 *); extern NCURSES_EXPORT(void) _nc_freeall (void); extern NCURSES_EXPORT(void) _nc_hash_map (void); extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *); @@ -2079,6 +2176,25 @@ extern NCURSES_EXPORT(void) _nc_signal_handler (int); extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *); extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *); +#if NCURSES_EXT_NUMBERS +extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *); +#else +#define _nc_fallback2(tp) _nc_fallback(tp) +#endif + +#if NCURSES_EXT_NUMBERS +extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *); +extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *); +extern NCURSES_EXPORT(void) _nc_import_termtype2(TERMTYPE2 *, const TERMTYPE *); +#else +#define _nc_copy_termtype2(dst,src) _nc_copy_termtype((dst),(src)) +#define _nc_export_termtype2(dst,src) /* nothing */ +#define _nc_import_termtype2(dst,src) /* nothing */ +#define _nc_free_termtype2(t) _nc_free_termtype(t) +/* also... */ +#define _nc_read_entry2 _nc_read_entry +#endif + #if NO_LEAKS extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void); extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);