/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2011,2012 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 *
* and: Juergen Pfeifer *
****************************************************************************/
-
/*
- * $Id: curses.priv.h,v 1.417 2009/05/23 23:01:44 tom Exp $
+ * $Id: curses.priv.h,v 1.506 2012/09/01 19:21:05 tom Exp $
*
* curses.priv.h
*
#ifndef CURSES_PRIV_H
#define CURSES_PRIV_H 1
+/* *INDENT-OFF* */
#include <ncurses_dll.h>
#define MODULE_ID(id) /*nothing*/
#endif
+#include <stddef.h> /* for offsetof */
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/stat.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#define USE_FUNC_POLL 0
#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+
/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
#include <signal.h>
#define USE_EMX_MOUSE 0
#endif
+/* kLIBC keyboard/mouse support */
+#if defined(__OS2__) && defined(__KLIBC__)
+#define USE_KLIBC_KBD 1
+#define USE_KLIBC_MOUSE 1
+#else
+#define USE_KLIBC_KBD 0
+#define USE_KLIBC_MOUSE 0
+#endif
+
#define DEFAULT_MAXCLICK 166
#define EV_MAX 8 /* size of mouse circular event queue */
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
+
+/*
+ * Either/both S_ISxxx and/or S_IFxxx are defined in sys/types.h; some systems
+ * lack one or the other.
+ */
+#ifndef S_ISDIR
+#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG)
+#endif
+
/*
* Scroll hints are useless when hashmap is used
*/
#define if_USE_SCROLL_HINTS(stmt) /*nothing*/
#endif
+#include <nc_string.h>
+
/*
* Options for terminal drivers, etc...
*/
-#if 0
+#ifdef USE_TERM_DRIVER
#define USE_SP_RIPOFF 1
#define USE_SP_TERMTYPE 1
#define USE_SP_WINDOWLIST 1
-#define USE_TERM_DRIVER 1
#endif
/*
#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
* 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
#endif
#include <term.h>
+#include <nc_termios.h>
/*
* Reduce dependency on cur_term global by using terminfo data from SCREEN's
#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,(((unsigned long)(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 & (unsigned) 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))
#if NCURSES_SP_FUNCS
-#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, pair, 0)
+#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, (short) pair, 0)
#else
-#define VIDATTR(sp,attr,pair) vid_attr(attr, pair, 0)
+#define VIDATTR(sp,attr,pair) vid_attr(attr, (short) 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 & (attr_t) 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 & (attr_t) ColorPair(p))
#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
#if NCURSES_SP_FUNCS
#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)
#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))
#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
+#if USE_REENTRANT || NCURSES_SP_FUNCS
+NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *);
+NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *);
+NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *);
+NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *);
+#endif
+
#if USE_REENTRANT
-NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
-NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
+
#define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES))
#define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS))
-#define SET_LINES(value) *_nc_ptr_Lines() = value
-#define SET_COLS(value) *_nc_ptr_Cols() = value
+#define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE))
+#define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY))
+
+#define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value
+#define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value
+#define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value
+#define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value
+
#else
+
#define ptrLines(sp) &LINES
#define ptrCols(sp) &COLS
+#define ptrTabsize(sp) &TABSIZE
+#define ptrEscdelay(sp) &ESCDELAY
+
#define SET_LINES(value) LINES = value
#define SET_COLS(value) COLS = value
+#define SET_TABSIZE(value) TABSIZE = value
+#define SET_ESCDELAY(value) ESCDELAY = value
+
#endif
#define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
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))
+#else
+# undef USE_WEAK_SYMBOLS
+# define USE_WEAK_SYMBOLS 0
+#endif
+#endif
+
#ifdef USE_PTHREADS
#if USE_REENTRANT
#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);
+weak_symbol(pthread_kill);
weak_symbol(pthread_self);
weak_symbol(pthread_equal);
weak_symbol(pthread_mutex_init);
#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 */
#endif /* USE_PTHREADS */
+/*
+ * When using sp-funcs, locks are targeted to SCREEN-level granularity.
+ * So the locking is done in the non-sp-func (which calls the sp-func) rather
+ * than in the sp-func itself.
+ *
+ * Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()".
+ * Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS".
+ */
+#if NCURSES_SP_FUNCS
+
+#define _nc_nonsp_lock_global(name) /* nothing */
+#define _nc_nonsp_try_global(name) 0
+#define _nc_nonsp_unlock_global(name) /* nothing */
+
+#define _nc_sp_lock_global(name) _nc_lock_global(name)
+#define _nc_sp_try_global(name) _nc_try_global(name)
+#define _nc_sp_unlock_global(name) _nc_unlock_global(name)
+
+#else
+
+#define _nc_nonsp_lock_global(name) _nc_lock_global(name)
+#define _nc_nonsp_try_global(name) _nc_try_global(name)
+#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name)
+
+#define _nc_sp_lock_global(name) /* nothing */
+#define _nc_sp_try_global(name) 0
+#define _nc_sp_unlock_global(name) /* nothing */
+
+#endif
+
#if HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
# define TimeType struct timeval
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 */
#if USE_SYSMOUSE
,M_SYSMOUSE /* FreeBSD sysmouse on console */
#endif
+#ifdef USE_TERM_DRIVER
+ ,M_TERM_DRIVER /* Win32 console, etc */
+#endif
} MouseType;
/*
struct _SLK;
-#ifndef USE_TERMLIB
+#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
typedef struct
{
#if USE_GPM_SUPPORT
#undef buttons /* term.h defines this, and gpm uses it! */
#include <gpm.h>
+#if USE_WEAK_SYMBOLS
+weak_symbol(Gpm_Wgetch);
+#endif
#ifdef HAVE_LIBDL
/* link dynamically to GPM */
*/
#if MIXEDCASE_FILENAMES
#define LEAF_FMT "%c"
+#define LEAF_LEN 1
#else
#define LEAF_FMT "%02x"
+#define LEAF_LEN 2
#endif
/*
#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
+
+typedef struct {
+ const char *name;
+ char *value;
+} ITERATOR_VARS;
+
/*
* Global data which is not specific to a screen.
*/
typedef struct {
+ SIG_ATOMIC_T have_sigtstp;
SIG_ATOMIC_T have_sigwinch;
SIG_ATOMIC_T cleanup_nested;
bool init_signals;
bool init_screen;
- const char *comp_sourcename;
+ char *comp_sourcename;
char *comp_termtype;
bool have_tic_directory;
int tgetent_index;
long tgetent_sequence;
+ char *dbd_blob; /* string-heap for dbd_list[] */
+ char **dbd_list; /* distinct places to look for data */
+ int dbd_size; /* length of dbd_list[] */
+ time_t dbd_time; /* cache last updated */
+ ITERATOR_VARS dbd_vars[dbdLAST];
+
#ifndef USE_SP_WINDOWLIST
WINDOWLIST *_nc_windowlist;
#define WindowList(sp) _nc_globals._nc_windowlist
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];
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;
#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;
int _COLS;
+ int _TABSIZE;
+ int _ESCDELAY;
TERMINAL *_cur_term;
#ifdef TRACE
long _outchars;
const char *_tputs_trace;
#endif
#endif
+ bool use_tioctl;
} NCURSES_PRESCREEN;
/*
*/
struct screen {
- int _ifd; /* input file ptr for screen */
+ int _ifd; /* input file descriptor for screen */
+ int _ofd; /* output file descriptor for screen */
FILE *_ofp; /* output file ptr for screen */
- char *_setbuf; /* buffered I/O for output */
+ char *out_buffer; /* output buffer */
+ size_t out_limit; /* output buffer size */
+ size_t out_inuse; /* output buffer current use */
bool _filtered; /* filter() was called */
- bool _buffered; /* setvbuf uses _setbuf data */
bool _prescreen; /* is in prescreen phase */
bool _use_env; /* LINES & COLS from environment? */
int _checkfd; /* filedesc for typeahead check */
int _pair_count; /* count of color pairs */
int _pair_limit; /* actual limit of color-pairs */
#if NCURSES_EXT_FUNCS
+ bool _assumed_color; /* use assumed colors */
bool _default_color; /* use default colors */
bool _has_sgr_39_49; /* has ECMA default color support */
int _default_fg; /* assumed default foreground */
bool _use_rmso; /* true if we may use 'rmso' */
bool _use_rmul; /* true if we may use 'rmul' */
+#if USE_KLIBC_KBD
+ bool _extended_key; /* true if an extended key */
+#endif
+
/*
* These data correspond to the state of the idcok() and idlok()
* functions. A caveat is in order here: the XSI and SVr4
*/
bool _nc_sp_idlok;
bool _nc_sp_idcok;
-#define _nc_idlok SP->_nc_sp_idlok
-#define _nc_idcok SP->_nc_sp_idcok
/*
* These are the data that support the mouse interface.
void (*_mouse_wrap) (SCREEN *);
int _mouse_fd; /* file-descriptor, if any */
bool _mouse_active; /* true if initialized */
- mmask_t _mouse_mask;
+ mmask_t _mouse_mask; /* set via mousemask() */
+ mmask_t _mouse_mask2; /* OR's in press/release bits */
+ mmask_t _mouse_bstate;
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 */
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
*/
#if USE_SIZECHANGE
- int (*_resize)(int,int);
+ int (*_resize)(NCURSES_SP_DCLx int y, int x);
+ int (*_ungetch)(SCREEN *, int);
#endif
/*
int *_oldnum_list;
int _oldnum_size;
- bool _cleanup; /* cleanup after int/quit signal */
NCURSES_SP_OUTC _outch; /* output handler if not putc */
int _legacy_coding; /* see use_legacy_coding() */
*/
bool _screen_acs_fix;
#endif
+
+ bool _use_tioctl;
};
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 */
+#if 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[] */
#endif
};
-#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+#define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m)
#define SP_PRE_INIT(sp) \
sp->_cursrow = -1; \
#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)
#define SetChar(ch,c,a) do { \
NCURSES_CH_T *_cp = &ch; \
memset(_cp, 0, sizeof(ch)); \
- _cp->chars[0] = (c); \
+ _cp->chars[0] = (wchar_t) (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)
#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
mbstate_t PUT_st; wchar_t PUTC_ch
#define PUTC_INIT init_mb (PUT_st)
-#define PUTC(ch,b) do { if(!isWidecExt(ch)) { \
+#define PUTC(ch) do { if(!isWidecExt(ch)) { \
if (Charable(ch)) { \
- fputc(CharOf(ch), b); \
+ NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx CharOf(ch)); \
COUNT_OUTCHARS(1); \
} else { \
PUTC_INIT; \
PUTC_ch = (ch).chars[PUTC_i]; \
if (PUTC_ch == L'\0') \
break; \
- PUTC_n = wcrtomb(PUTC_buf, \
- (ch).chars[PUTC_i], &PUT_st); \
+ PUTC_n = (int) wcrtomb(PUTC_buf, \
+ (ch).chars[PUTC_i], &PUT_st); \
if (PUTC_n <= 0) { \
if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
- putc(PUTC_ch,b); \
+ NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx CharOf(ch)); \
break; \
+ } else { \
+ int PUTC_j; \
+ for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \
+ NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \
+ } \
} \
- fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
} \
COUNT_OUTCHARS(PUTC_i); \
} } } while (0)
* zero. Otherwise we can use those bits to tell if a cell is the
* first or extension part of a wide character.
*/
-#define WidecExt(ch) (AttrOf(ch) & A_CHARTEXT)
+#define WidecExt(ch) (int) (AttrOf(ch) & A_CHARTEXT)
#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) \
#define CHDEREF(wch) wch
#define ARG_CH_T NCURSES_CH_T
#define CARG_CH_T NCURSES_CH_T
-#define PUTC_DATA int data = 0
-#define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0)
+#define PUTC_DATA /* nothing */
+#define PUTC(ch) NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_ARGx (int) ch)
#define BLANK (' '|A_NORMAL)
#define ZEROS ('\0'|A_NORMAL)
#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 \
|| line->firstchar > (start)) \
- line->firstchar = start; \
+ line->firstchar = (NCURSES_SIZE_T) (start); \
if (line->lastchar == _NOCHANGE \
|| line->lastchar < (end)) \
- line->lastchar = end
+ line->lastchar = (NCURSES_SIZE_T) (end)
#define CHANGED_TO_EOL(line,start,end) \
if (line->firstchar == _NOCHANGE \
|| line->firstchar > (start)) \
- line->firstchar = start; \
- line->lastchar = end
+ line->firstchar = (NCURSES_SIZE_T) (start); \
+ line->lastchar = (NCURSES_SIZE_T) (end)
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
#define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a
#define T(a) TR(TRACE_CALLS, a)
-#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
+#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
+#define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value)
+#define TRACE_RETURN_SP(value,type) return _nc_retrace_##type(SP_PARM, 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 returnIntAttr(code) TRACE_RETURN2(code,int,attr_t)
+#define returnMMask(code) TRACE_RETURN_SP(code,mmask_t)
#define returnPtr(code) TRACE_RETURN(code,ptr)
#define returnSP(code) TRACE_RETURN(code,sp)
#define returnVoid T((T_RETURN(""))); return
#define returnVoidPtr(code) TRACE_RETURN(code,void_ptr)
#define returnWin(code) TRACE_RETURN(code,win)
-extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
+extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int);
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 *);
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 (int);
extern NCURSES_EXPORT(int) _nc_retrace_int (int);
+extern NCURSES_EXPORT(int) _nc_retrace_int_attr_t (attr_t);
+extern NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t (SCREEN *, mmask_t);
extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *);
extern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *);
#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 returnIntAttr(code) return code
+#define returnMMask(code) return code
#define returnPtr(code) return code
#define returnSP(code) return code
#define returnVoid return
#endif /* TRACE/!TRACE */
+/*
+ * Workaround for defective implementation of gcc attribute warn_unused_result
+ */
+#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
+#define IGNORE_RC(func) errno = (int) func
+#else
+#define IGNORE_RC(func) (void) func
+#endif /* gcc workarounds */
+
/*
* Return-codes for tgetent() and friends.
*/
#define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress)
#define toggle_attr_on(S,at) {\
- if (PAIR_NUMBER(at) > 0) {\
- (S) = ((S) & ALL_BUT_COLOR) | (at);\
+ if (PairNumber(at) > 0) {\
+ (S) = ((S) & ALL_BUT_COLOR) | (attr_t) (at);\
} else {\
- (S) |= (at);\
+ (S) |= (attr_t) (at);\
}\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define toggle_attr_off(S,at) {\
- if (PAIR_NUMBER(at) > 0) {\
+ if (PairNumber(at) > 0) {\
(S) &= ~(at|A_COLOR);\
} else {\
(S) &= ~(at);\
: 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 \
} \
}
#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
/*
#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
extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t);
#undef DelCharCost
-#define DelCharCost(count) _nc_DelCharCost(count)
-extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
+#define DelCharCost(sp, count) NCURSES_SP_NAME(_nc_DelCharCost)(NCURSES_SP_ARGx count)
#undef InsCharCost
-#define InsCharCost(count) _nc_InsCharCost(count)
-extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
+#define InsCharCost(sp, count) NCURSES_SP_NAME(_nc_InsCharCost)(NCURSES_SP_ARGx count)
+
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int _c);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int _c);
#undef UpdateAttrs
-#define UpdateAttrs(c) _nc_UpdateAttrs(c)
-extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
+#define UpdateAttrs(sp,c) NCURSES_SP_NAME(_nc_UpdateAttrs)(NCURSES_SP_ARGx CHREF(c))
+
+#if USE_WIDEC_SUPPORT || defined(NEED_NCURSES_CH_T)
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T _c);
+#else
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx chtype c);
+#endif
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
+extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
+extern NCURSES_EXPORT(void) _nc_UpdateAttrs (CARG_CH_T);
+#endif /* NCURSES_SP_FUNCS */
#else
#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
extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
/* lib_getch.c */
-extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *));
/* lib_insch.c */
-extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
+extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype);
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
extern NCURSES_EXPORT(char *) _nc_get_locale(void);
extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
-extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
-extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
+extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, int);
+extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int);
+
+/* lib_set_term.c */
+extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int));
+
+/* lib_setup.c */
+#define ret_error(code, fmt, arg) if (errret) {\
+ *errret = code;\
+ returnCode(ERR);\
+ } else {\
+ fprintf(stderr, fmt, arg);\
+ exit(EXIT_FAILURE);\
+ }
+
+#define ret_error1(code, fmt, arg) ret_error(code, "'%s': " fmt, arg)
+
+#define ret_error0(code, msg) if (errret) {\
+ *errret = code;\
+ returnCode(ERR);\
+ } else {\
+ fprintf(stderr, msg);\
+ exit(EXIT_FAILURE);\
+ }
/* lib_tstp.c */
#if USE_SIGWINCH
/* 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);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
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 *, bool);
+extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int);
extern NCURSES_EXPORT(int) _nc_ospeed (int);
extern NCURSES_EXPORT(int) _nc_outch (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_setupscreen (int, int, FILE *, bool, int);
+extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *);
+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_do_color (short, short, bool, NCURSES_OUTC);
+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_make_oldhash (int i);
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
-extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
-extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
+extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int);
+extern NCURSES_EXPORT(void) _nc_setenv_num (const char *, int);
+extern NCURSES_EXPORT(void) _nc_signal_handler (int);
extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *);
extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
extern NCURSES_EXPORT(void) _nc_codes_leaks(void);
extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void);
+extern NCURSES_EXPORT(void) _nc_comp_error_leaks(void);
extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
+extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void);
extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
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);
+extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, int const, int const, NCURSES_CH_T);
#endif
-#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *);
+#endif
+
+#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
#endif
#define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
#endif
+/*
+ * Wide-character macros to hide some platform-differences.
+ */
+#if USE_WIDEC_SUPPORT
+#if HAVE_MBTOWC && HAVE_MBLEN
+#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
+#define count_mbytes(buffer,length,state) mblen(buffer,length)
+#define check_mbytes(wch,buffer,length,state) \
+ (int) mbtowc(&wch, buffer, length)
+#define state_unused
+#elif HAVE_MBRTOWC && HAVE_MBRLEN
+#define reset_mbytes(state) init_mb(state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define check_mbytes(wch,buffer,length,state) \
+ (int) mbrtowc(&wch, buffer, length, &state)
+#else
+make an error
+#endif
+#endif
+
/*
* Not everyone has vsscanf(), but we'd like to use it for scanw().
*/
* On systems with a broken linker, define 'SP' as a function to force the
* linker to pull in the data-only module with 'SP'.
*/
+#define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1)
+
#if BROKEN_LINKER
#define SP _nc_screen()
extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
/* 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 = typeCalloc(SCREEN, 1)) != 0)
+#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0)
#define _nc_set_screen(sp) SP = sp
#endif
-#if NCURSES_SP_FUNCS && 0
+#if NCURSES_SP_FUNCS
#define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr())
#else
#define CURRENT_SCREEN_PRE CURRENT_SCREEN
#define screen_columns(sp) (sp)->_columns
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
-extern NCURSES_EXPORT(int) _nc_format_slks (SCREEN *, int);
+extern NCURSES_EXPORT(int) _nc_format_slks (NCURSES_SP_DCLx int _c);
/*
* Some constants related to SLK's
#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
-extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
-
/*
* Common error messages
*/
}\
sp->jump = outc
-struct DriverTCB; /* Terminal Control Block forward declaration */
+#ifdef USE_TERM_DRIVER
typedef void* TERM_HANDLE;
typedef struct _termInfo
int maxpairs;
int nocolorvideo;
+ int numbuttons;
int numlabels;
int labelwidth;
int labelheight;
typedef struct term_driver {
bool isTerminfo;
- bool (*CanHandle)(struct DriverTCB*,const char*,int*);
+ bool (*CanHandle)(struct DriverTCB*, const char*, int*);
void (*init)(struct DriverTCB*);
void (*release)(struct DriverTCB*);
int (*size)(struct DriverTCB*, int* Line, int *Cols);
- int (*sgmode)(struct DriverTCB*, bool setFlag, TTY*);
+ int (*sgmode)(struct DriverTCB*, int setFlag, TTY*);
chtype (*conattr)(struct DriverTCB*);
int (*hwcur)(struct DriverTCB*, int yold, int xold, int y, int x);
- int (*mode)(struct DriverTCB*, bool progFlag, bool defFlag);
+ int (*mode)(struct DriverTCB*, int progFlag, int defFlag);
bool (*rescol)(struct DriverTCB*);
bool (*rescolors)(struct DriverTCB*);
- void (*color)(struct DriverTCB*,bool fore, int color, int(*)(SCREEN*,int));
- int (*doBeepOrFlash)(struct DriverTCB*, bool);
- void (*initpair)(struct DriverTCB*,short,short,short);
- void (*initcolor)(struct DriverTCB*,short,short,short,short);
- void (*docolor)(struct DriverTCB*,short,short,bool,int(*)(SCREEN*,int));
+ void (*color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int));
+ int (*doBeepOrFlash)(struct DriverTCB*, int);
+ void (*initpair)(struct DriverTCB*, int, int, int);
+ void (*initcolor)(struct DriverTCB*, int, int, int, int);
+ void (*docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int));
void (*initmouse)(struct DriverTCB*);
+ int (*testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*));
void (*setfilter)(struct DriverTCB*);
- void (*hwlabel)(struct DriverTCB*,int,char*);
- void (*hwlabelOnOff)(struct DriverTCB*,bool);
+ void (*hwlabel)(struct DriverTCB*, int, char*);
+ void (*hwlabelOnOff)(struct DriverTCB*, int);
int (*update)(struct DriverTCB*);
- int (*defaultcolors)(struct DriverTCB*,int,int);
- int (*print)(struct DriverTCB*,char*,int);
- int (*getsize)(struct DriverTCB*,int*,int*);
- int (*setsize)(struct DriverTCB*,int,int);
- void (*initacs)(struct DriverTCB*,chtype*,chtype*);
+ int (*defaultcolors)(struct DriverTCB*, int, int);
+ int (*print)(struct DriverTCB*, char*, int);
+ int (*getsize)(struct DriverTCB*, int*, int*);
+ int (*setsize)(struct DriverTCB*, int, int);
+ void (*initacs)(struct DriverTCB*, chtype*, chtype*);
void (*scinit)(SCREEN *);
void (*scexit)(SCREEN *);
- int (*twait)(struct DriverTCB*,int,int,int* EVENTLIST_2nd(_nc_eventlist*));
- int (*read)(struct DriverTCB*,int*);
- int (*nap)(struct DriverTCB*,int);
- int (*kpad)(struct DriverTCB*, bool);
- int (*kyOk)(struct DriverTCB*, int, bool);
+ int (*twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*));
+ int (*read)(struct DriverTCB*, int*);
+ int (*nap)(struct DriverTCB*, int);
+ int (*kpad)(struct DriverTCB*, int);
+ int (*kyOk)(struct DriverTCB*, int, int);
bool (*kyExist)(struct DriverTCB*, int);
} TERM_DRIVER;
-
typedef struct DriverTCB
{
TERMINAL term; /* needs to be the first Element !!! */
extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette;
extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette;
-#ifdef USE_TERM_DRIVER
-extern NCURSES_EXPORT(int) _nc_tinfo_has_key(SCREEN*, int);
-extern NCURSES_EXPORT(int) _nc_tinfo_doupdate(SCREEN *sp);
-extern NCURSES_EXPORT(int) _nc_tinfo_mvcur(SCREEN*,int,int,int,int);
extern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*);
+extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *);
+#endif /* USE_TERM_DRIVER */
+
+/*
+ * Entrypoints which are actually provided in the terminal driver, which would
+ * be an sp-name otherwise.
+ */
+#ifdef USE_TERM_DRIVER
+#define TINFO_HAS_KEY _nc_tinfo_has_key
+#define TINFO_DOUPDATE _nc_tinfo_doupdate
+#define TINFO_MVCUR _nc_tinfo_mvcur
+extern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int);
+extern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *);
+extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int);
+#else
+#define TINFO_HAS_KEY NCURSES_SP_NAME(has_key)
+#define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate)
+#define TINFO_MVCUR NCURSES_SP_NAME(mvcur)
#endif
+/*
+ * Entrypoints using an extra parameter with the terminal driver.
+ */
+#ifdef USE_TERM_DRIVER
+extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *);
+extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, int);
+#define TINFO_GET_SIZE(sp, tp, lp, cp) \
+ _nc_get_screensize(sp, tp, lp, cp)
+#define TINFO_SET_CURTERM(sp, tp) \
+ NCURSES_SP_NAME(set_curterm)(sp, tp)
+#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
+ _nc_setupterm_ex(tpp, name, fd, err, reuse)
+#else /* !USE_TERM_DRIVER */
+extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
+#define TINFO_GET_SIZE(sp, tp, lp, cp) \
+ _nc_get_screensize(sp, lp, cp)
+#define TINFO_SET_CURTERM(sp, tp) \
+ set_curterm(tp)
+#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
+ _nc_setupterm(name, fd, err, reuse)
+#endif /* !USE_TERM_DRIVER */
+
+#ifdef USE_TERM_DRIVER
#ifdef __MINGW32__
#include <nc_mingw.h>
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
#endif
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
+#endif
#ifdef USE_TERM_DRIVER
#define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo)))
extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int);
#if USE_REENTRANT
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_ttytype)(SCREEN*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*);
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*);
#endif
* We put the safe versions of various calls here as they are not published
* part of the API up to now
*/
-extern NCURSES_EXPORT(SCREEN*) _nc_SP(void);
-
-extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_set_curterm)(SCREEN*,TERMINAL*);
-extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(cur_term)(SCREEN *sp);
+extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp);
extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int);
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*);
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const char*);
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 *, bool, int);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, short, void *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int));
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, short, short, bool, NCURSES_SP_OUTC);
+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);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*);
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, bool);
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, int);
extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp);
}
#endif
+/* *INDENT-ON* */
+
#endif /* CURSES_PRIV_H */