diff options
Diffstat (limited to 'ncurses/curses.priv.h')
| -rw-r--r-- | ncurses/curses.priv.h | 331 |
1 files changed, 211 insertions, 120 deletions
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 68cda17e71a3..8999ecdf6e75 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -35,7 +35,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.687 2024/04/23 22:28:25 tom Exp $ + * $Id: curses.priv.h,v 1.741 2025/12/27 21:46:04 tom Exp $ * * curses.priv.h * @@ -59,7 +59,7 @@ extern "C" { #if USE_RCS_IDS #define MODULE_ID(id) static const char Ident[] = id; #else -#define MODULE_ID(id) /*nothing*/ +#define MODULE_ID(id) /* nothing */ #endif #include <stddef.h> /* for offsetof */ @@ -88,11 +88,20 @@ extern int errno; #endif /* Some Windows related defines */ + #undef _NC_WINDOWS -#if (defined(_WIN32) || defined(_WIN64)) +#if (defined(_WIN32) || defined(_WIN64__) || defined(__MSYS__)) #define _NC_WINDOWS -#else -#undef EXP_WIN32_DRIVER +#endif + +#undef _NC_CYGWIN +#if (defined(__MSYS__) || defined(__CYGWIN__)) +#define _NC_CYGWIN +#endif + +#undef _NC_WINDOWS_NATIVE +#if (defined(_WIN32) || defined(_WIN64)) +#define _NC_WINDOWS_NATIVE #endif #undef _NC_MINGW @@ -197,7 +206,7 @@ extern int errno; * the path separator in configure doesn't work properly. So, if building * for MinGW, we enforce the correct Windows PATH separator */ -#if defined(_NC_WINDOWS) +#if defined(_NC_WINDOWS_NATIVE) || defined(__DJGPP__) # ifdef NCURSES_PATHSEP # undef NCURSES_PATHSEP # endif @@ -223,6 +232,15 @@ extern int errno; #endif /* + * The stricmp() function is in MSVCRT, and cannot be called or linked from + * Cygwin runtime-dependent binaries currently. Use the POSIX strcaseccmp() + * function instead which is pretty much the same. + */ +#if defined(_NC_CYGWIN) +#define stricmp(s1, s2) strcasecmp(s1, s2) +#endif + +/* * Not all platforms have memmove; some have an equivalent bcopy. (Some may * have neither). */ @@ -293,7 +311,7 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); /* * Options for terminal drivers, etc... */ -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER #define NO_TERMINAL "unknown" #define USE_SP_RIPOFF 1 #define USE_SP_TERMTYPE 1 @@ -348,6 +366,12 @@ typedef TRIES { #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~" /* + * To make them easier to find, user-defined capabilities used within ncurses + * should be tagged with this macro: + */ +#define UserCap(name) #name + +/* * Structure for palette tables */ @@ -379,6 +403,38 @@ typedef TRIES { #undef KEY_EVENT /* reduce compiler-warnings with Visual C++ */ #endif +/* + * Macros to make additional parameter to implement wgetch_events() + */ +#ifdef NCURSES_WGETCH_EVENTS +#define EVENTLIST_0th(param) param +#define EVENTLIST_1st(param) param +#define EVENTLIST_2nd(param) , param +#define TWAIT_MASK (TW_ANY | TW_EVENT) +#else +#define EVENTLIST_0th(param) void +#define EVENTLIST_1st(param) /* nothing */ +#define EVENTLIST_2nd(param) /* nothing */ +#define TWAIT_MASK TW_ANY +#endif + +#include <term.priv.h> /* defines TERMIOS via term.h */ + +#if USE_TERM_DRIVER +#if defined(TERMIOS) +#undef USE_NAMED_PIPES +#define USE_NAMED_PIPES 0 +#undef USE_WIN32CON_DRIVER +#elif defined(_NC_WINDOWS) +#include <nc_win32.h> +#endif /* TERMIOS */ +#endif /* USE_TERM_DRIVER */ + +#ifndef FixupPathname +#define FixupPathname(path) /* nothing */ +#define FixupPathname2(path,buffer) /* nothing */ +#endif + typedef struct { int red, green, blue; /* what color_content() returns */ @@ -422,11 +478,10 @@ typedef union { #include <nc_panel.h> -#include <term.priv.h> #include <nc_termios.h> -#define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen) -#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term))) +#define IsPreScreen(sp) (((sp) != NULL) && sp->_prescreen) +#define HasTerminal(sp) (((sp) != NULL) && (NULL != ((sp)->_term))) #define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp)) #if USE_REENTRANT @@ -790,7 +845,7 @@ typedef enum { #if USE_SYSMOUSE ,M_SYSMOUSE /* FreeBSD sysmouse on console */ #endif -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER ,M_TERM_DRIVER /* Win32 console, etc */ #endif } MouseType; @@ -877,6 +932,12 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); #define MAX_DELAY_MSECS 30000 /* + * Limit screen dimensions read from environment variables. + */ +#define MAX_ENV_LINES 512 +#define MAX_ENV_COLUMNS 512 + +/* * 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. @@ -890,13 +951,16 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); * The filesystem database normally uses a single-letter for the lower level * of directories. Use a hexadecimal code for filesystems which do not * preserve mixed-case names. + * + * The leading "./" is used in _nc_to_dospath() to decide whether to prefix + * the converted path with the MinGW32 base directory. */ #if MIXEDCASE_FILENAMES -#define LEAF_FMT "%c" -#define LEAF_LEN 1 +#define LEAF_FMT "./%c" +#define LEAF_LEN 3 #else -#define LEAF_FMT "%02x" -#define LEAF_LEN 2 +#define LEAF_FMT "./%02x" +#define LEAF_LEN 4 #endif /* @@ -910,7 +974,7 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); #define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15)) #define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */ -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER struct DriverTCB; /* Terminal Control Block forward declaration */ #define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver #else @@ -1101,7 +1165,8 @@ typedef struct screen { MouseFormat _mouse_format; /* type of xterm mouse protocol */ NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */ MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */ - MEVENT *_mouse_eventp; /* next free slot in event queue */ + MEVENT *_mouse_readp; /* read pointer into event queue */ + MEVENT *_mouse_writep; /* write pointer into event queue */ /* * These are data that support the proper handling of the panel stack on an @@ -1187,7 +1252,7 @@ typedef struct screen { int _sysmouse_new_buttons; #endif -#if defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER) +#if USE_TERM_DRIVER || USE_NAMED_PIPES MEVENT _drv_mouse_fifo[FIFO_SIZE]; int _drv_mouse_head; int _drv_mouse_tail; @@ -1265,7 +1330,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m) #ifdef USE_SP_WINDOWLIST -#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = 0 +#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = NULL #else #define SP_INIT_WINDOWLIST(sp) /* nothing */ #endif @@ -1282,7 +1347,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; sp->_cursor = -1; \ SP_INIT_WINDOWLIST(sp); \ sp->_outch = NCURSES_OUTC_FUNC; \ - sp->jump = 0 \ + sp->jump = NULL \ /* usually in <limits.h> */ #ifndef UCHAR_MAX @@ -1376,6 +1441,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define NulColor /* nothing */ #endif +#if NCURSES_RGB_COLORS +#define NulDirect , 0 +#else +#define NulDirect /* nothing */ +#endif + #if CCHARW_MAX > 6 #define NulChar 0,0,0,0,0 #elif CCHARW_MAX > 5 @@ -1397,7 +1468,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES) #define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c) -#define NewChar2(c,a) { a, { c, NulChar } NulColor } +#define NewChar2(c,a) { a, { c, NulChar } NulColor NulDirect } #define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch)) #if CCHARW_MAX > 1 @@ -1427,7 +1498,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define PUTC(ch) do { if(!isWidecExt(ch)) { \ if (Charable(ch)) { \ TR_PUTC(CharOf(ch)); \ - NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \ COUNT_OUTCHARS(1); \ } else { \ for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \ @@ -1440,15 +1511,19 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; if (PUTC_n <= 0) { \ if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \ TR_PUTC(CharOf(ch)); \ - NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \ } \ break; \ - } else { \ + } else if (PUTC_n > 1 || !is8bits(PUTC_ch)) { \ int PUTC_j; \ for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \ TR_PUTC(PUTC_buf[PUTC_j]); \ NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \ } \ + } else { \ + PUTC_buf[0] = (char) PUTC_ch; \ + TR_PUTC(PUTC_buf[0]); \ + NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[0]); \ } \ } \ COUNT_OUTCHARS(PUTC_i); \ @@ -1520,10 +1595,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define CHANGED -1 #define LEGALYX(w, y, x) \ - ((w) != 0 && \ + ((w) != NULL && \ ((x) >= 0 && (x) <= (w)->_maxx && \ (y) >= 0 && (y) <= (w)->_maxy)) +#define OK_DIMENSION(n) ((NCURSES_SIZE_T)(n) == (n) && (n) > 0) + #define CHANGED_CELL(line,col) \ if (line->firstchar == _NOCHANGE) \ line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \ @@ -1551,12 +1628,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #include <nc_alloc.h> #include <nc_access.h> -#define FreeIfNeeded(p) if ((p) != 0) free(p) +#define FreeIfNeeded(p) if ((p) != NULL) free(p) /* FreeAndNull() is not a comma-separated expression because some compilers * do not accept a mixture of void with values. */ -#define FreeAndNull(p) do { free(p); p = 0; } while (0) +#define FreeAndNull(p) do { free(p); p = NULL; } while (0) #ifdef EXP_OOM_TESTING extern NCURSES_EXPORT(void *) _nc_oom_malloc(size_t size); @@ -1578,21 +1655,21 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr); #define TYPE_MALLOC(type, size, name) \ do { \ name = typeMalloc(type, size); \ - if (name == 0) \ + if (name == NULL) \ _nc_err_abort(MSG_NO_MEMORY); \ } while (0) #define TYPE_CALLOC(type, size, name) \ do { \ name = typeCalloc(type, size); \ - if (name == 0) \ + if (name == NULL) \ _nc_err_abort(MSG_NO_MEMORY); \ } while (0) #define TYPE_REALLOC(type, size, name) \ do { \ name = typeRealloc(type, size, name); \ - if (name == 0) \ + if (name == NULL) \ _nc_err_abort(MSG_NO_MEMORY); \ } while (0) @@ -1624,8 +1701,8 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr); /* * Standardize/simplify common loops */ -#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen -#define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next +#define each_screen(p) p = _nc_screen_chain; p != NULL; p = (p)->_next_screen +#define each_window(sp,p) p = WindowList(sp); p != NULL; p = (p)->next #define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p /* @@ -1637,8 +1714,8 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr); #define T_CREATE(fmt) "create :" fmt #define T_RETURN(fmt) "return }" fmt -#define NonNull(s) ((s) != 0 ? s : "<null>") -#define NonEmpty(s) ((s) != 0 && *(s) != '\0') +#define NonNull(s) ((s) != NULL ? s : "<null>") +#define NonEmpty(s) ((s) != NULL && *(s) != '\0') #ifdef TRACE @@ -1705,7 +1782,7 @@ typedef void VoidFunc(void); #define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0) #define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0) -extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int); +extern NCURSES_EXPORT(bool) _nc_retrace_bool (bool); extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *); extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *); extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *); @@ -1830,20 +1907,20 @@ extern NCURSES_EXPORT(void) name (void); \ TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));} #define DelCharCost(sp,count) \ - ((parm_dch != 0) \ + ((parm_dch != NULL) \ ? sp->_dch_cost \ - : ((delete_character != 0) \ + : ((delete_character != NULL) \ ? (sp->_dch1_cost * count) \ - : INFINITY)) + : NC_INFINITY)) #define InsCharCost(sp,count) \ - ((parm_ich != 0) \ + ((parm_ich != NULL) \ ? sp->_ich_cost \ : ((enter_insert_mode && exit_insert_mode) \ ? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \ - : ((insert_character != 0) \ + : ((insert_character != NULL) \ ? ((sp->_ich1_cost + sp->_ip_cost) * count) \ - : INFINITY))) + : NC_INFINITY))) #if USE_XMC_SUPPORT #define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ @@ -1864,21 +1941,6 @@ extern NCURSES_EXPORT(void) name (void); \ } #endif -/* - * Macros to make additional parameter to implement wgetch_events() - */ -#ifdef NCURSES_WGETCH_EVENTS -#define EVENTLIST_0th(param) param -#define EVENTLIST_1st(param) param -#define EVENTLIST_2nd(param) , param -#define TWAIT_MASK (TW_ANY | TW_EVENT) -#else -#define EVENTLIST_0th(param) void -#define EVENTLIST_1st(param) /* nothing */ -#define EVENTLIST_2nd(param) /* nothing */ -#define TWAIT_MASK TW_ANY -#endif - #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS #undef toggle_attr_on @@ -1928,7 +1990,7 @@ extern NCURSES_EXPORT(void) _nc_expanded (void); #endif #define save_ttytype(termp) \ - if (TerminalType(termp).term_names != 0) { \ + if (TerminalType(termp).term_names != NULL) { \ _nc_STRNCPY(ttytype, \ TerminalType(termp).term_names, \ NAMESIZE - 1); \ @@ -1936,7 +1998,7 @@ extern NCURSES_EXPORT(void) _nc_expanded (void); } #if !NCURSES_WCWIDTH_GRAPHICS -extern NCURSES_EXPORT(int) _nc_wacs_width(unsigned); +extern NCURSES_EXPORT(int) _nc_wacs_width(wchar_t); #else #define _nc_wacs_width(ch) wcwidth(ch) #endif @@ -2006,7 +2068,7 @@ extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int); extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int); #define ReservePairs(sp,want) \ - if ((sp->_color_pairs == 0) || (want >= sp->_pair_alloc)) \ + if ((sp->_color_pairs == NULL) || (want >= sp->_pair_alloc)) \ _nc_reserve_pairs(sp, want) /* lib_getch.c */ @@ -2015,8 +2077,12 @@ extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eve /* lib_insch.c */ extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype); +/* lib_mouse.c */ +extern NCURSES_EXPORT(bool) _nc_has_mouse (const SCREEN *); + /* lib_mvcur.c */ -#define INFINITY 1000000 /* cost: too high to use */ +#define NC_INFINITY 1000000 /* cost: too high to use */ +#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */ extern NCURSES_EXPORT(int) _nc_mvcur(int yold, int xold, int ynew, int xnew); @@ -2030,16 +2096,9 @@ extern NCURSES_EXPORT(void) _nc_screen_init (void); extern NCURSES_EXPORT(void) _nc_screen_resume (void); extern NCURSES_EXPORT(void) _nc_screen_wrap (void); -/* lib_mouse.c */ -extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *); - -/* lib_mvcur.c */ -#define INFINITY 1000000 /* cost: too high to use */ -#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */ - /* lib_setup.c */ extern NCURSES_EXPORT(char *) _nc_get_locale(void); -extern NCURSES_EXPORT(int) _nc_unicode_locale(void); +extern NCURSES_EXPORT(bool) _nc_unicode_locale(void); extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); extern NCURSES_EXPORT(int) _nc_setupterm(const char *, int, int *, int); extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); @@ -2049,7 +2108,7 @@ 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 +#define _nc_forget_prescr() _nc_prescreen.allocated = NULL #endif /* lib_set_term.c */ @@ -2133,7 +2192,7 @@ extern NCURSES_EXPORT(int) _nc_access (const char *, int); extern NCURSES_EXPORT(int) _nc_baudrate (int); extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *); extern NCURSES_EXPORT(int) _nc_getenv_num (const char *); -extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int); +extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, bool); extern NCURSES_EXPORT(int) _nc_ospeed (int); extern NCURSES_EXPORT(int) _nc_outch (int); extern NCURSES_EXPORT(int) _nc_putchar (int); @@ -2141,13 +2200,13 @@ 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, 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(int) _nc_setupscreen (int, int, FILE *, bool, int); +extern NCURSES_EXPORT(int) _nc_timed_wait (const SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *)); extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *); 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_entry (ENTRY *, TERMTYPE2 *); +extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, const TERMTYPE2 *); extern NCURSES_EXPORT(void) _nc_freeall (void); extern NCURSES_EXPORT(void) _nc_hash_map (void); extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *); @@ -2232,7 +2291,7 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); */ #if USE_WIDEC_SUPPORT -#if defined(_NC_WINDOWS) && !defined(_NC_MSC) && !defined(EXP_WIN32_DRIVER) +#if defined(_NC_WINDOWS_NATIVE) && !defined(_NC_MSC) && !USE_NAMED_PIPES /* * MinGW has wide-character functions, but they do not work correctly. */ @@ -2246,13 +2305,7 @@ extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); #define mblen(s,n) _nc_mblen(s, n) -#endif /* _NC_WINDOWS && !_NC_MSC */ - -#if defined(_NC_WINDOWS) || defined(_NC_MINGW) -/* see wcwidth.c */ -extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t); -#define wcwidth(ucs) _nc_wcwidth(ucs) -#endif +#endif /* _NC_WINDOWS_NATIVE && !_NC_MSC */ #if HAVE_MBTOWC && HAVE_MBLEN #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) @@ -2283,7 +2336,7 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; #define USE_SETBUF_0 0 -#define NC_OUTPUT(sp) ((sp != 0 && sp->_ofp != 0) ? sp->_ofp : stdout) +#define NC_OUTPUT(sp) ((sp != NULL && sp->_ofp != NULL) ? sp->_ofp : stdout) /* * On systems with a broken linker, define 'SP' as a function to force the @@ -2301,7 +2354,7 @@ extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); /* current screen is private data; avoid possible linking conflicts too */ extern NCURSES_EXPORT_VAR(SCREEN *) SP; #define CURRENT_SCREEN SP -#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0) +#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != NULL) #define _nc_set_screen(sp) SP = sp #endif @@ -2357,14 +2410,14 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *); #define SetSafeOutcWrapper(outc) \ SCREEN* sp = CURRENT_SCREEN; \ struct screen outc_wrapper; \ - if (sp==0) { \ + if (sp == NULL) { \ sp = &outc_wrapper; \ memset(sp,0,sizeof(struct screen)); \ sp->_outch = _nc_outc_wrapper; \ }\ sp->jump = outc -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER typedef struct _termInfo { @@ -2461,7 +2514,7 @@ extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int * Entrypoints which are actually provided in the terminal driver, which would * be an sp-name otherwise. */ -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER #define TINFO_HAS_KEY _nc_tinfo_has_key #define TINFO_DOUPDATE _nc_tinfo_doupdate #define TINFO_MVCUR _nc_tinfo_mvcur @@ -2474,14 +2527,23 @@ extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); #define TINFO_MVCUR NCURSES_SP_NAME(_nc_mvcur) #endif -#if defined(EXP_WIN32_DRIVER) -#include <nc_win32.h> +#ifdef _NC_WINDOWS +#if USE_WIDEC_SUPPORT +#include <wchar.h> +#endif +#include <tchar.h> +#include <io.h> +#elif defined(_NC_WINDOWS_NATIVE) +#include <tchar.h> +#include <io.h> +#elif defined(__EMX__) +#include <io.h> #endif /* * Entrypoints using an extra parameter with the terminal driver. */ -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int); #define TINFO_GET_SIZE(sp, tp, lp, cp) \ @@ -2500,33 +2562,46 @@ extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *); _nc_setupterm(name, fd, err, reuse) #endif /* !USE_TERM_DRIVER */ -#ifdef EXP_WIN32_DRIVER -extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; -#else -#ifdef USE_TERM_DRIVER -#if defined(USE_WIN32CON_DRIVER) -#include <nc_mingw.h> +#if USE_TERM_DRIVER extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER; -extern NCURSES_EXPORT(int) _nc_mingw_isatty(int fd); -extern NCURSES_EXPORT(int) _nc_mingw_isconsole(int fd); -extern NCURSES_EXPORT(int) _nc_mingw_console_read( - SCREEN *sp, - HANDLE fd, - int *buf); -extern NCURSES_EXPORT(int) _nc_mingw_testmouse( - SCREEN * sp, - HANDLE fd, - int delay EVENTLIST_2nd(_nc_eventlist*)); -#else -#endif extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; #endif /* USE_TERM_DRIVER */ -#endif /* EXP_WIN32_DRIVER */ -#if defined(USE_TERM_DRIVER) && defined(EXP_WIN32_DRIVER) +#ifdef TERMIOS +#define USE_WINCONMODE 0 +#elif defined(USE_WIN32CON_DRIVER) +#define USE_WINCONMODE 1 +extern NCURSES_EXPORT(int) _nc_console_setmode(void* handle, const ConsoleMode* arg); +extern NCURSES_EXPORT(int) _nc_console_getmode(void* handle, ConsoleMode* arg); +extern NCURSES_EXPORT(bool) _nc_console_checkinit(bool assumeTermInfo); +extern NCURSES_EXPORT(void*) _nc_console_fd2handle(int fd); +extern NCURSES_EXPORT(WORD) _nc_console_MapColor(bool fore, int color); +extern NCURSES_EXPORT(int) _nc_console_flush(void* handle); +extern NCURSES_EXPORT(bool) _nc_console_get_SBI(void); +extern NCURSES_EXPORT(HANDLE) _nc_console_handle(int fd); +extern NCURSES_EXPORT(int) _nc_console_isatty(int fd); +extern NCURSES_EXPORT(bool) _nc_console_keyExist(int keycode); +extern NCURSES_EXPORT(int) _nc_console_keyok(int keycode, int flag); +extern NCURSES_EXPORT(int) _nc_console_read(SCREEN *sp, HANDLE fd, int *buf); +extern NCURSES_EXPORT(bool) _nc_console_restore(void); +extern NCURSES_EXPORT(void) _nc_console_selectActiveHandle(void); +extern NCURSES_EXPORT(void) _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info); +extern NCURSES_EXPORT(void) _nc_console_size(int *Lines, int *Cols); +extern NCURSES_EXPORT(int) _nc_console_test(int fd); +extern NCURSES_EXPORT(int) _nc_console_testmouse(const SCREEN *sp, HANDLE fd, int delay EVENTLIST_2nd(_nc_eventlist*)); +extern NCURSES_EXPORT(int) _nc_console_twait(const SCREEN *sp, HANDLE hdl,int mode,int msec,int *left EVENTLIST_2nd(_nc_eventlist * evl)); +extern NCURSES_EXPORT(int) _nc_console_vt_supported(void); + +#ifdef _NC_CHECK_MINTTY +extern NCURSES_EXPORT(int) _nc_console_checkmintty(int fd, LPHANDLE pMinTTY); +#endif + +#else +#error unsupported driver configuration +#endif /* USE_WIN32CON_DRIVER */ + +#if USE_TERM_DRIVER && defined(USE_WIN32CON_DRIVER) #define NC_ISATTY(fd) (0 != _nc_console_isatty(fd)) -#elif defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER) -#define NC_ISATTY(fd) _nc_mingw_isatty(fd) #else #define NC_ISATTY(fd) isatty(fd) #endif @@ -2539,20 +2614,20 @@ extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER; && (value = ttyname(fd)) != NULL \ && strncmp(value, "/dev/pts/", 9)) -#ifdef USE_TERM_DRIVER -# define IsTermInfo(sp) ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo))) -# define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp)) -# if defined(EXP_WIN32_DRIVER) +#if USE_TERM_DRIVER +# define IsTermInfo(sp) ((TCBOf(sp) != NULL) && ((TCBOf(sp)->drv != NULL)) && ((TCBOf(sp)->drv->isTerminfo))) +# define HasTInfoTerminal(sp) ((NULL != TerminalOf(sp)) && IsTermInfo(sp)) +# if USE_NAMED_PIPES # define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes)) # elif defined(USE_WIN32CON_DRIVER) -# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_mingw_isconsole(TerminalOf(sp)->Filedes)) +# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes)) # else # define IsTermInfoOnConsole(sp) FALSE # endif #else # define IsTermInfo(sp) TRUE -# define HasTInfoTerminal(sp) (0 != TerminalOf(sp)) -# if defined(EXP_WIN32_DRIVER) +# define HasTInfoTerminal(sp) (NULL != TerminalOf(sp)) +# if USE_NAMED_PIPES # define IsTermInfoOnConsole(sp) _nc_console_test(TerminalOf(sp)->Filedes) # else # define IsTermInfoOnConsole(sp) FALSE @@ -2599,7 +2674,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const c extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int)); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*); -extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, bool, int); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *); extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC); extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t); @@ -2654,6 +2729,22 @@ extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned) extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned); #endif +#ifdef _NC_WINDOWS +#if USE_WIDEC_SUPPORT +#define write_screen WriteConsoleOutputW +#define read_screen ReadConsoleOutputW +#define read_keycode ReadConsoleInputW +#define KeyEventChar KeyEvent.uChar.UnicodeChar +#define CharInfoChar Char.UnicodeChar +#else +#define write_screen WriteConsoleOutput +#define read_screen ReadConsoleOutput +#define read_keycode ReadConsoleInput +#define KeyEventChar KeyEvent.uChar.AsciiChar +#define CharInfoChar Char.AsciiChar +#endif +#endif /* _NC_WINDOWS */ + #ifdef __cplusplus } #endif |
