/*
- * $Id: curses.priv.h,v 1.412 2009/05/02 21:28:57 tom Exp $
+ * $Id: curses.priv.h,v 1.430 2009/07/04 20:40:42 tom Exp $
*
* curses.priv.h
*
#define if_USE_SCROLL_HINTS(stmt) /*nothing*/
#endif
+/*
+ * Options for terminal drivers, etc...
+ */
+#if 0
+#define USE_SP_RIPOFF 1
+#define USE_SP_TERMTYPE 1
+#define USE_SP_WINDOWLIST 1
+#define USE_TERM_DRIVER 1
+#endif
+
/*
* Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
* when we're throwing control codes at the screen at high volume. To see
#include <nc_panel.h>
-#define IsPreScreen(sp) (((sp)!=0) && sp->_prescreen)
-#define HasTerminal(sp) (((sp)!=0) && (0!=((sp)->_term)))
-#define IsValidScreen(sp) (HasTerminal(sp) && !sp->_prescreen)
+#define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen)
+#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term)))
+#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp))
+
#if BROKEN_LINKER || USE_REENTRANT
-#define TerminalOf(sp) ((sp)?((sp)->_term?(sp)->_term:_nc_prescreen._cur_term): _nc_prescreen._cur_term)
+#define CurTerm _nc_prescreen._cur_term
+#else
+#define CurTerm cur_term
+#endif
+
+#if NCURSES_SP_FUNCS
+#define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm)
#else
-#define TerminalOf(sp) ((sp)?((sp)->_term?(sp)->_term:cur_term):cur_term)
+#define TerminalOf(sp) CurTerm
#endif
#include <term.h>
+
+/*
+ * Reduce dependency on cur_term global by using terminfo data from SCREEN's
+ * pointer to this data.
+ */
+#ifdef USE_SP_TERMTYPE
+#undef CUR
+#endif
+
+#define SP_TERMTYPE TerminalOf(sp)->type.
+
#include <term_entry.h>
+
#include <nc_tparm.h>
#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
#endif
#else /* !(NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT) */
+
#define if_EXT_COLORS(stmt) /* nothing */
#define SetPair(value,p) RemAttr(value, A_COLOR), \
SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
#if USE_REENTRANT
-NCURSES_EXPORT(int *) _nc_ptr_Lines (void);
-NCURSES_EXPORT(int *) _nc_ptr_Cols (void);
+
+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 *);
+
#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, \
int tgetent_index;
long tgetent_sequence;
+#ifndef USE_SP_WINDOWLIST
WINDOWLIST *_nc_windowlist;
-#define _nc_windows _nc_globals._nc_windowlist
+#define WindowList(sp) _nc_globals._nc_windowlist
+#endif
#if USE_HOME_TERMINFO
char *home_terminfo;
char traceatr_color_buf[2][80];
int traceatr_color_sel;
int traceatr_color_last;
-
+#if !defined(USE_PTHREADS) && USE_REENTRANT
+ int nested_tracef;
+#endif
#endif /* TRACE */
#ifdef USE_PTHREADS
bool use_env;
bool filter_mode;
attr_t previous_attr;
+#ifndef USE_SP_RIPOFF
ripoff_t rippedoff[N_RIPS];
ripoff_t *rsp;
+#endif
TPARM_STATE tparm_state;
TTY *saved_tty; /* savetty/resetty information */
#if NCURSES_NO_PADDING
chtype *real_acs_map;
int _LINES;
int _COLS;
+ int _TABSIZE;
+ int _ESCDELAY;
TERMINAL *_cur_term;
#ifdef TRACE
long _outchars;
#endif
} NCURSES_PRESCREEN;
-#define ripoff_sp _nc_prescreen.rsp
-#define ripoff_stack _nc_prescreen.rippedoff
+/*
+ * Use screen-specific ripoff data (for softkeys) rather than global.
+ */
+#ifdef USE_SP_RIPOFF
+#define safe_ripoff_sp (sp)->rsp
+#define safe_ripoff_stack (sp)->rippedoff
+#else
+#define safe_ripoff_sp _nc_prescreen.rsp
+#define safe_ripoff_stack _nc_prescreen.rippedoff
+#endif
extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
WINDOW *_newscr; /* virtual screen to be updated to */
WINDOW *_stdscr; /* screen's full-window context */
+#define CurScreen(sp) (sp)->_curscr
+#define NewScreen(sp) (sp)->_newscr
+#define StdScreen(sp) (sp)->_stdscr
+
TRIES *_keytry; /* "Try" for use with keypad mode */
TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */
bool _tried; /* keypad mode was initialized */
*/
bool _nc_sp_idlok;
bool _nc_sp_idcok;
-#define _nc_idlok SP->_nc_sp_idlok
-#define _nc_idcok SP->_nc_sp_idcok
+
+#define _nc_idlok SP_PARM->_nc_sp_idlok
+#define _nc_idcok SP_PARM->_nc_sp_idcok
/*
* These are the data that support the mouse interface.
* This supports automatic resizing
*/
#if USE_SIZECHANGE
- int (*_resize)(int,int);
+ int (*_resize)(NCURSES_SP_DCLx int y, int x);
#endif
/*
int _oldnum_size;
bool _cleanup; /* cleanup after int/quit signal */
- int (*_outch)(int); /* output handler if not putc */
+ NCURSES_SP_OUTC _outch; /* output handler if not putc */
int _legacy_coding; /* see use_legacy_coding() */
char tracechr_buf[40];
char tracemse_buf[TRACEMSE_MAX];
#endif
+#ifdef USE_SP_WINDOWLIST
+ WINDOWLIST* _windowlist;
+#define WindowList(sp) (sp)->_windowlist
+#endif
+ NCURSES_OUTC jump;
+
+ ripoff_t rippedoff[N_RIPS];
+ ripoff_t *rsp;
+
/*
* ncurses/ncursesw are the same up to this point.
*/
sp->_fifohead = -1; \
sp->_endwin = TRUE; \
sp->_cursor = -1; \
- sp->_windowlist = 0; \
+ WindowList(sp) = 0; \
sp->_outch = NCURSES_SP_NAME(_nc_outch); \
sp->jump = 0 \
* Standardize/simplify common loops
*/
#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen
-#define each_window(p) p = _nc_windows; p != 0; p = (p)->next
-#define each_ripoff(p) p = ripoff_stack; (p - ripoff_stack) < N_RIPS; ++p
+#define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next
+#define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p
/*
* Prefixes for call/return points of library function traces. We use these to
__FILE__, __LINE__, \
sp->_cursrow, \
sp->_curscol)); \
- _nc_do_xmc_glitch(chg); \
+ NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \
} \
}
#else
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 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_acs.c */
-extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
-extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
+extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
+extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
/* lib_addch.c */
#if USE_WIDEC_SUPPORT
extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, 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(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
+/* lib_set_term.c */
+extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int));
+
/* lib_tstp.c */
#if USE_SIGWINCH
extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *);
/* elsewhere ... */
extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
-extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
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_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
-extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
+extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, 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 *);
#define USE_SETBUF_0 0
-#define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
+#define NC_BUFFERED(sp,flag) NCURSES_SP_NAME(_nc_set_buffer)(NCURSES_SP_ARGx sp->_ofp, flag)
#define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout)
* 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);
extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
+#define CURRENT_SCREEN _nc_screen()
#else
/* current screen is private data; avoid possible linking conflicts too */
extern NCURSES_EXPORT_VAR(SCREEN *) SP;
-#define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
+#define CURRENT_SCREEN SP
+#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0)
#define _nc_set_screen(sp) SP = sp
#endif
-#define CURRENT_SCREEN SP
-
+#if NCURSES_SP_FUNCS && 0
#define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr())
+#else
+#define CURRENT_SCREEN_PRE CURRENT_SCREEN
+#endif
/*
* We don't want to use the lines or columns capabilities internally, because
#define screen_columns(sp) (sp)->_columns
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, 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
*/
#define MSG_NO_MEMORY "Out of memory"
#define MSG_NO_INPUTS "Premature EOF"
+extern NCURSES_EXPORT(int) _nc_set_tty_mode(TTY *);
+extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *);
+
/* timed_wait flag definitions */
#define TW_NONE 0
#define TW_INPUT 1
typedef struct _termInfo
{
- bool caninit;
+ bool caninit;
- bool hascolor;
- bool initcolor;
- bool canchange;
+ bool hascolor;
+ bool initcolor;
+ bool canchange;
- int tabsize;
+ int tabsize;
- int maxcolors;
- int maxpairs;
- int nocolorvideo;
+ int maxcolors;
+ int maxpairs;
+ int nocolorvideo;
- int numlabels;
- int labelwidth;
- int labelheight;
+ int numlabels;
+ int labelwidth;
+ int labelheight;
- const color_t* defaultPalette;
+ const color_t* defaultPalette;
} TerminalInfo;
typedef struct term_driver {
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*);
+#endif
+
#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;
-#define IsTermInfo(sp) TRUE
-#define HasTInfoTerminal(sp) ((0!=TerminalOf(sp)) && IsTermInfo(sp))
+#ifdef USE_TERM_DRIVER
+#define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo)))
+#else
+#define IsTermInfo(sp) TRUE
+#endif
+
+#define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
#define IsValidTIScreen(sp) (HasTInfoTerminal(sp))
/*
* 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(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(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int);
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char *);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resetty)(SCREEN*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*);
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_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_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_tputs)(SCREEN*,const char*,int,int(*)(SCREEN*, int));
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, 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_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_set_buffer)(SCREEN*, FILE *, bool);
extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp);
-extern NCURSES_EXPORT(int) _nc_tinfo_doupdate(SCREEN *sp);
-extern NCURSES_EXPORT(int) _nc_tinfo_mcprint(SCREEN*,char*,int);
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*);
#define safe_unctrl _nc_unctrl
#define safe_ungetch _nc_ungetch
+extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);