]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/curses.priv.h
ncurses 5.7 - patch 20100515
[ncurses.git] / ncurses / curses.priv.h
index 1f5507b2a02a25d926ff237de409ffd5fa016e78..0856ad9a8dde64fcc9feab1947b346e9d79a42b1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,7 +35,7 @@
 
 
 /*
- * $Id: curses.priv.h,v 1.442 2009/10/31 20:33:43 tom Exp $
+ * $Id: curses.priv.h,v 1.462 2010/05/15 22:08:12 tom Exp $
  *
  *     curses.priv.h
  *
@@ -61,6 +61,7 @@ extern "C" {
 #define MODULE_ID(id) /*nothing*/
 #endif
 
+#include <stddef.h>            /* for offsetof */
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
@@ -176,6 +177,20 @@ extern NCURSES_EXPORT(int) _nc_env_access (void);
 extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
 #endif
 
+/*
+ * If we have va_copy(), use it for assigning va_list's.
+ */
+#if defined(HAVE___VA_COPY)
+#define begin_va_copy(dst,src) __va_copy(dst, src)
+#define end_va_copy(dst)       va_end(dst)
+#elif defined(va_copy) || defined(HAVE_VA_COPY)
+#define begin_va_copy(dst,src) va_copy(dst, src)
+#define end_va_copy(dst)       va_end(dst)
+#else
+#define begin_va_copy(dst,src) (dst) = (src)
+#define end_va_copy(dst)       /* nothing */
+#endif
+
 /*
  * Scroll hints are useless when hashmap is used
  */
@@ -255,6 +270,7 @@ color_t;
 #define _nc_bkgd    _bkgrnd
 #else
 #undef _XOPEN_SOURCE_EXTENDED
+#undef _XPG5
 #define _nc_bkgd    _bkgd
 #define wgetbkgrnd(win, wch)   *wch = win->_bkgd
 #define wbkgrnd            wbkgd
@@ -270,6 +286,10 @@ color_t;
  * If curses.h did not expose the SCREEN-functions, then we do not need the
  * parameter in the corresponding unextended functions.
  */
+
+#define USE_SP_FUNC_SUPPORT     NCURSES_SP_FUNCS
+#define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS)
+
 #if NCURSES_SP_FUNCS
 #define SP_PARM         sp     /* use parameter */
 #define NCURSES_SP_ARG          SP_PARM
@@ -320,15 +340,36 @@ color_t;
 
 #include <nc_tparm.h>
 
-#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
+/*
+ * Use these macros internally, to make tracing less verbose.  But leave the
+ * option for compiling the tracing into the library.
+ */
+#if 1
+#define ColorPair(n)           NCURSES_BITS(n, 0)
+#define PairNumber(a)          (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
+#else
+#define ColorPair(pair)                COLOR_PAIR(pair)
+#define PairNumber(attr)       PAIR_NUMBER(attr)
+#endif
+
+#define unColor(n)             unColor2(AttrOf(n))
+#define unColor2(a)            ((a) & ALL_BUT_COLOR)
+
+/*
+ * Extended-colors stores the color pair in a separate struct-member than the
+ * attributes.  But for compatibility, we handle most cases where a program
+ * written for non-extended colors stores the color in the attributes by
+ * checking for a color pair in both places.
+ */
+#if NCURSES_EXT_COLORS
 #define if_EXT_COLORS(stmt)    stmt
-#define NetPair(value,p)       (value).ext_color = (p), \
-                               AttrOf(value) &= ALL_BUT_COLOR, \
-                               AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
-#define SetPair(value,p)       (value).ext_color = (p)
-#define GetPair(value)         (value).ext_color
-#define unColor(n)             (AttrOf(n) & ALL_BUT_COLOR)
-#define GET_WINDOW_PAIR(w)     (w)->_color
+#define SetPair(value,p)       SetPair2((value).ext_color, AttrOf(value), p)
+#define SetPair2(c,a,p)                c = (p), \
+                               a = (unColor2(a) | (A_COLOR & ColorPair(oldColor(c))))
+#define GetPair(value)         GetPair2((value).ext_color, AttrOf(value))
+#define GetPair2(c,a)          ((c) ? (c) : PairNumber(a))
+#define oldColor(p)            (((p) > 255) ? 255 : (p))
+#define GET_WINDOW_PAIR(w)     GetPair2((w)->_color, (w)->_attrs)
 #define SET_WINDOW_PAIR(w,p)   (w)->_color = (p)
 #define SameAttrOf(a,b)                (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
 
@@ -338,16 +379,15 @@ color_t;
 #define VIDATTR(sp,attr,pair)  vid_attr(attr, pair, 0)
 #endif
 
-#else /* !(NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT) */
+#else /* !NCURSES_EXT_COLORS */
 
 #define if_EXT_COLORS(stmt)    /* nothing */
 #define SetPair(value,p)       RemAttr(value, A_COLOR), \
-                               SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
-#define GetPair(value)         PAIR_NUMBER(AttrOf(value))
-#define unColor(n)             (AttrOf(n) & ALL_BUT_COLOR)
-#define GET_WINDOW_PAIR(w)     PAIR_NUMBER(WINDOW_ATTRS(w))
+                               SetAttr(value, AttrOf(value) | (A_COLOR & ColorPair(p)))
+#define GetPair(value)         PairNumber(AttrOf(value))
+#define GET_WINDOW_PAIR(w)     PairNumber(WINDOW_ATTRS(w))
 #define SET_WINDOW_PAIR(w,p)   WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
-                               WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p))
+                               WINDOW_ATTRS(w) |= (A_COLOR & ColorPair(p))
 #define SameAttrOf(a,b)                (AttrOf(a) == AttrOf(b))
 
 #if NCURSES_SP_FUNCS
@@ -356,7 +396,7 @@ color_t;
 #define VIDATTR(sp,attr,pair)  vidattr(attr)
 #endif
 
-#endif /* NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT */
+#endif /* NCURSES_EXT_COLORS */
 
 #if NCURSES_NO_PADDING
 #define GetNoPadding(sp)       ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding)
@@ -417,6 +457,19 @@ NCURSES_EXPORT(int *)        _nc_ptr_Escdelay (SCREEN *);
            data.__data.__nusers)
 #define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name)
 
+#if USE_WEAK_SYMBOLS
+#if defined(__GNUC__)
+#  if defined __USE_ISOC99
+#    define _cat_pragma(exp)   _Pragma(#exp)
+#    define _weak_pragma(exp)  _cat_pragma(weak name)
+#  else
+#    define _weak_pragma(exp)
+#  endif
+#  define _declare(name)       __extension__ extern __typeof__(name) name
+#  define weak_symbol(name)    _weak_pragma(name) _declare(name) __attribute__((weak))
+#endif
+#endif
+
 #ifdef USE_PTHREADS
 
 #if USE_REENTRANT
@@ -434,19 +487,6 @@ extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
 #error POSIX threads requires --enable-reentrant option
 #endif
 
-#if USE_WEAK_SYMBOLS
-#if defined(__GNUC__)
-#  if defined __USE_ISOC99
-#    define _cat_pragma(exp)   _Pragma(#exp)
-#    define _weak_pragma(exp)  _cat_pragma(weak name)
-#  else
-#    define _weak_pragma(exp)
-#  endif
-#  define _declare(name)       __extension__ extern __typeof__(name) name
-#  define weak_symbol(name)    _weak_pragma(name) _declare(name) __attribute__((weak))
-#endif
-#endif
-
 #ifdef USE_PTHREADS
 #  if USE_WEAK_SYMBOLS
 weak_symbol(pthread_sigmask);
@@ -471,6 +511,19 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 
 #else /* !USE_PTHREADS */
 
+#if USE_PTHREADS_EINTR
+#  if USE_WEAK_SYMBOLS
+#include <pthread.h>
+weak_symbol(pthread_sigmask);
+weak_symbol(pthread_kill);
+weak_symbol(pthread_self);
+weak_symbol(pthread_equal);
+extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
+#    undef  sigprocmask
+#    define sigprocmask _nc_sigprocmask
+#  endif
+#endif /* USE_PTHREADS_EINTR */
+
 #define _nc_init_pthreads()    /* nothing */
 #define _nc_mutex_init(obj)    /* nothing */
 
@@ -524,14 +577,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
 typedef unsigned colorpair_t;  /* type big enough to store PAIR_OF() */
 #define C_SHIFT 9              /* we need more bits than there are colors */
 #define C_MASK                 ((1 << C_SHIFT) - 1)
-#define PAIR_OF(fg, bg)                ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+#define PAIR_OF(fg, bg)                (colorpair_t) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
 #define FORE_OF(c)             (((c) >> C_SHIFT) & C_MASK)
 #define BACK_OF(c)             ((c) & C_MASK)
 #define isDefaultColor(c)      ((c) >= COLOR_DEFAULT || (c) < 0)
 
 #define COLOR_DEFAULT          C_MASK
 
-#if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)
+#if defined(USE_BUILD_CC) || (defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T))
 
 #undef NCURSES_CH_T            /* this is not a termlib feature */
 #define NCURSES_CH_T void      /* ...but we need a pointer in SCREEN */
@@ -557,6 +610,9 @@ typedef enum {
 #if USE_SYSMOUSE
        ,M_SYSMOUSE             /* FreeBSD sysmouse on console */
 #endif
+#ifdef USE_TERM_DRIVER
+       ,M_TERM_DRIVER          /* Win32 console, etc */
+#endif
 } MouseType;
 
 /*
@@ -575,7 +631,7 @@ typedef struct {
 
 struct _SLK;
 
-#ifndef USE_TERMLIB
+#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
 
 typedef struct
 {
@@ -686,8 +742,10 @@ typedef struct {
  */
 #if MIXEDCASE_FILENAMES
 #define LEAF_FMT "%c"
+#define LEAF_LEN 1
 #else
 #define LEAF_FMT "%02x"
+#define LEAF_LEN 2
 #endif
 
 /*
@@ -700,6 +758,13 @@ typedef struct {
 #define TRACEMSE_MAX   (80 + (5 * 10) + (32 * 15))
 #define TRACEMSE_FMT   "id %2d  at (%2d, %2d, %2d) state %4lx = {" /* } */
 
+#ifdef USE_TERM_DRIVER
+struct DriverTCB; /* Terminal Control Block forward declaration */
+#define INIT_TERM_DRIVER()     _nc_globals.term_driver = _nc_get_driver
+#else
+#define INIT_TERM_DRIVER()     /* nothing */
+#endif
+
 /*
  * Global data which is not specific to a screen.
  */
@@ -746,6 +811,10 @@ typedef struct {
        int             safeprint_rows;
 #endif
 
+#ifdef USE_TERM_DRIVER
+       int             (*term_driver)(struct DriverTCB*, const char*, int*);
+#endif
+
 #ifdef TRACE
        bool            init_trace;
        char            trace_fname[PATH_MAX];
@@ -782,6 +851,9 @@ typedef struct {
        int             use_pthreads;
 #define _nc_use_pthreads       _nc_globals.use_pthreads
 #endif
+#if USE_PTHREADS_EINTR
+       pthread_t       read_thread;            /* The reading thread */
+#endif
 } NCURSES_GLOBALS;
 
 extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
@@ -805,6 +877,7 @@ typedef struct {
 #if NCURSES_NO_PADDING
        bool            _no_padding;    /* flag to set if padding disabled  */
 #endif
+       NCURSES_SP_OUTC _outch;         /* output handler if not putc */
 #if BROKEN_LINKER || USE_REENTRANT
        chtype          *real_acs_map;
        int             _LINES;
@@ -1016,6 +1089,13 @@ struct screen {
        int             _sysmouse_new_buttons;
 #endif
 
+#ifdef USE_TERM_DRIVER
+       MEVENT          _drv_mouse_fifo[FIFO_SIZE];
+       int             _drv_mouse_head;
+       int             _drv_mouse_tail;
+       int             _drv_mouse_old_buttons;
+       int             _drv_mouse_new_buttons;
+#endif
        /*
         * This supports automatic resizing
         */
@@ -1084,10 +1164,10 @@ extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
 extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
        WINDOWLIST {
-       WINDOW  win;            /* first, so WINDOW_EXT() works */
        WINDOWLIST *next;
        SCREEN *screen;         /* screen containing the window */
-#ifdef _XOPEN_SOURCE_EXTENDED
+       WINDOW  win;            /* WINDOW_EXT() needs to account for offset */
+#ifdef NCURSES_WIDECHAR
        char addch_work[(MB_LEN_MAX * 9) + 1];
        unsigned addch_used;    /* number of bytes in addch_work[] */
        int addch_x;            /* x-position for addch_work[] */
@@ -1095,7 +1175,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #endif
 };
 
-#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+#define WINDOW_EXT(w,m) (((WINDOWLIST *)((char *)(w) - offsetof(WINDOWLIST, win)))->m)
 
 #define SP_PRE_INIT(sp)                         \
     sp->_cursrow = -1;                          \
@@ -1185,6 +1265,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars)
 
 #define UChar(c)       ((unsigned char)(c))
+#define UShort(c)      ((unsigned short)(c))
 #define ChCharOf(c)    ((c) & (chtype)A_CHARTEXT)
 #define ChAttrOf(c)    ((c) & (chtype)A_ATTRIBUTES)
 
@@ -1231,7 +1312,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
                            memset(_cp, 0, sizeof(ch));                             \
                            _cp->chars[0] = (c);                                            \
                            _cp->attr = (a);                                        \
-                           if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a)));             \
+                           if_EXT_COLORS(SetPair(ch, PairNumber(a)));              \
                        } while (0)
 #define CHREF(wch)     (&wch)
 #define CHDEREF(wch)   (*wch)
@@ -1277,7 +1358,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 #define isWidecBase(ch)        (WidecExt(ch) == 1)
 #define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
 #define SetWidecExt(dst, ext)  AttrOf(dst) &= ~A_CHARTEXT,             \
-                               AttrOf(dst) |= (ext + 1)
+                               AttrOf(dst) |= (attr_t) (ext + 1)
 
 #define if_WIDEC(code)  code
 #define Charable(ch)   ((SP_PARM != 0 && SP_PARM->_legacy_coding)      \
@@ -1330,11 +1411,11 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
 
 #define CHANGED_CELL(line,col) \
        if (line->firstchar == _NOCHANGE) \
-               line->firstchar = line->lastchar = col; \
+               line->firstchar = line->lastchar = (NCURSES_SIZE_T) col; \
        else if ((col) < line->firstchar) \
-               line->firstchar = col; \
+               line->firstchar = (NCURSES_SIZE_T) col; \
        else if ((col) > line->lastchar) \
-               line->lastchar = col
+               line->lastchar = (NCURSES_SIZE_T) col
 
 #define CHANGED_RANGE(line,start,end) \
        if (line->firstchar == _NOCHANGE \
@@ -1426,11 +1507,14 @@ extern NCURSES_EXPORT(void)     _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE
 #define T(a)           TR(TRACE_CALLS, a)
 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
 
+#define NonNull(s)     ((s) != 0 ? s : "<null>")
+
 #define returnAttr(code)       TRACE_RETURN(code,attr_t)
 #define returnBits(code)       TRACE_RETURN(code,unsigned)
 #define returnBool(code)       TRACE_RETURN(code,bool)
 #define returnCPtr(code)       TRACE_RETURN(code,cptr)
 #define returnCVoidPtr(code)   TRACE_RETURN(code,cvoid_ptr)
+#define returnChar(code)       TRACE_RETURN(code,char)
 #define returnChtype(code)     TRACE_RETURN(code,chtype)
 #define returnCode(code)       TRACE_RETURN(code,int)
 #define returnPtr(code)                TRACE_RETURN(code,ptr)
@@ -1450,6 +1534,7 @@ extern NCURSES_EXPORT(char *)           _nc_varargs (const char *, va_list);
 extern NCURSES_EXPORT(chtype)           _nc_retrace_chtype (chtype);
 extern NCURSES_EXPORT(const char *)     _nc_altcharset_name(attr_t, chtype);
 extern NCURSES_EXPORT(const char *)     _nc_retrace_cptr (const char *);
+extern NCURSES_EXPORT(char)             _nc_retrace_char (char);
 extern NCURSES_EXPORT(int)              _nc_retrace_int (int);
 extern NCURSES_EXPORT(unsigned)         _nc_retrace_unsigned (unsigned);
 extern NCURSES_EXPORT(void *)           _nc_retrace_void_ptr (void *);
@@ -1490,6 +1575,7 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
 #define returnBool(code)       return code
 #define returnCPtr(code)       return code
 #define returnCVoidPtr(code)   return code
+#define returnChar(code)       return ((char) code)
 #define returnChtype(code)     return code
 #define returnCode(code)       return code
 #define returnPtr(code)                return code
@@ -1528,7 +1614,7 @@ extern    NCURSES_EXPORT(void) name (void); \
 #define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress)
 
 #define toggle_attr_on(S,at) {\
-   if (PAIR_NUMBER(at) > 0) {\
+   if (PairNumber(at) > 0) {\
       (S) = ((S) & ALL_BUT_COLOR) | (at);\
    } else {\
       (S) |= (at);\
@@ -1537,7 +1623,7 @@ extern    NCURSES_EXPORT(void) name (void); \
 
 
 #define toggle_attr_off(S,at) {\
-   if (PAIR_NUMBER(at) > 0) {\
+   if (PairNumber(at) > 0) {\
       (S) &= ~(at|A_COLOR);\
    } else {\
       (S) &= ~(at);\
@@ -1561,7 +1647,7 @@ extern    NCURSES_EXPORT(void) name (void); \
                    : INFINITY)))
 
 #if USE_XMC_SUPPORT
-#define UpdateAttrs(sp,c)      if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
+#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
                                attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \
                                VIDATTR(sp, AttrOf(c), GetPair(c)); \
                                if (magic_cookie_glitch > 0 \
@@ -1574,8 +1660,9 @@ extern    NCURSES_EXPORT(void) name (void); \
                                } \
                        }
 #else
-#define UpdateAttrs(sp,c)      if (!SameAttrOf(SCREEN_ATTRS(sp), c)) \
-                                   VIDATTR(sp, AttrOf(c), GetPair(c));
+#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
+                                   VIDATTR(sp, AttrOf(c), GetPair(c)); \
+                       }
 #endif
 
 /*
@@ -1585,10 +1672,12 @@ extern  NCURSES_EXPORT(void) name (void); \
 #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
@@ -1681,7 +1770,7 @@ NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
 #endif
 
 /* lib_addstr.c */
-#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
 #endif
 
@@ -1812,7 +1901,7 @@ extern NCURSES_EXPORT(void) _nc_names_leaks(void);
 extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
 #endif
 
-#ifndef USE_TERMLIB
+#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
 extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
 extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
 extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T);
@@ -1822,7 +1911,7 @@ extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE
 extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *);
 #endif
 
-#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
 extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
 #endif
 
@@ -1958,7 +2047,6 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *);
     sp->jump = outc
 
 #ifdef USE_TERM_DRIVER
-struct DriverTCB; /* Terminal Control Block forward declaration */
 typedef void* TERM_HANDLE;
 
 typedef struct _termInfo
@@ -1975,6 +2063,7 @@ typedef struct _termInfo
     int  maxpairs;
     int  nocolorvideo;
 
+    int  numbuttons;
     int  numlabels;
     int  labelwidth;
     int  labelheight;
@@ -2000,6 +2089,7 @@ typedef struct term_driver {
     void   (*initcolor)(struct DriverTCB*,short,short,short,short);
     void   (*docolor)(struct DriverTCB*,short,short,bool,int(*)(SCREEN*,int));
     void   (*initmouse)(struct DriverTCB*);
+    int    (*testmouse)(struct DriverTCB*,int);
     void   (*setfilter)(struct DriverTCB*);
     void   (*hwlabel)(struct DriverTCB*,int,char*);
     void   (*hwlabelOnOff)(struct DriverTCB*,bool);