From 404cc3f5b0751dd219565139f825c5a4d445f651 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 10 May 2009 23:36:12 +0000 Subject: [PATCH] ncurses 5.7 - patch 20090510 + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). --- NEWS | 5 +- dist.mk | 4 +- include/MKterm.h.awk.in | 4 +- include/curses.h.in | 17 +- include/curses.wide | 6 +- ncurses/base/MKkeyname.awk | 21 +-- ncurses/base/define_key.c | 12 +- ncurses/base/lib_beep.c | 6 +- ncurses/base/lib_color.c | 82 ++++++--- ncurses/base/lib_delwin.c | 4 +- ncurses/base/lib_dft_fgbg.c | 8 +- ncurses/base/lib_flash.c | 6 +- ncurses/base/lib_freeall.c | 8 +- ncurses/base/lib_getstr.c | 23 ++- ncurses/base/lib_mouse.c | 6 +- ncurses/base/lib_newterm.c | 6 +- ncurses/base/lib_newwin.c | 46 ++++- ncurses/base/lib_screen.c | 6 +- ncurses/base/lib_set_term.c | 43 +++-- ncurses/base/lib_slk.c | 9 +- ncurses/base/lib_slkinit.c | 17 +- ncurses/base/lib_slkrefr.c | 9 +- ncurses/base/resizeterm.c | 170 +++++++++++------- ncurses/base/wresize.c | 4 +- ncurses/curses.priv.h | 133 +++++++++----- ncurses/tinfo/comp_scan.c | 28 ++- ncurses/tinfo/init_keytry.c | 4 +- ncurses/tinfo/lib_acs.c | 17 +- ncurses/tinfo/lib_baudrate.c | 18 +- ncurses/tinfo/lib_has_cap.c | 6 +- ncurses/tinfo/lib_longname.c | 38 +++- ncurses/tinfo/lib_options.c | 23 ++- ncurses/tinfo/lib_print.c | 11 +- ncurses/tinfo/lib_termcap.c | 14 +- ncurses/tinfo/lib_ti.c | 52 ++++-- ncurses/tinfo/lib_tputs.c | 76 ++++++-- ncurses/tinfo/lib_ttyflags.c | 34 +++- ncurses/tinfo/setbuf.c | 24 ++- ncurses/trace/lib_traceatr.c | 6 +- ncurses/tty/hashmap.c | 6 +- ncurses/tty/lib_mvcur.c | 14 +- ncurses/tty/lib_tstp.c | 4 +- ncurses/tty/lib_vidattr.c | 46 +++-- ncurses/tty/tty_update.c | 298 +++++++++++++++++++------------- ncurses/widechar/lib_vid_attr.c | 86 ++++++--- 45 files changed, 984 insertions(+), 476 deletions(-) diff --git a/NEWS b/NEWS index bedbaae8..2903d41b 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1384 2009/05/02 22:27:02 tom Exp $ +-- $Id: NEWS,v 1.1386 2009/05/10 21:27:04 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,9 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20090510 + + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + 20090502 + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + add vwmterm terminfo entry (patch by Bryan Christ). diff --git a/dist.mk b/dist.mk index c7d22744..8f754ab7 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.697 2009/05/02 17:26:04 tom Exp $ +# $Id: dist.mk,v 1.699 2009/05/10 21:27:04 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 7 -NCURSES_PATCH = 20090502 +NCURSES_PATCH = 20090510 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/include/MKterm.h.awk.in b/include/MKterm.h.awk.in index 4e33af26..215d6d24 100644 --- a/include/MKterm.h.awk.in +++ b/include/MKterm.h.awk.in @@ -34,7 +34,7 @@ BEGIN { print "/* and: Thomas E. Dickey 1995-on */" print "/****************************************************************************/" print "" - print "/* $Id: MKterm.h.awk.in,v 1.56 2009/05/02 19:25:57 tom Exp $ */" + print "/* $Id: MKterm.h.awk.in,v 1.57 2009/05/09 15:54:50 tom Exp $ */" print "" print "/*" print "** term.h -- Definition of struct term" @@ -344,7 +344,7 @@ END { print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);" print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);" print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);" - print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, int (*)(int));" + print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);" print "" print "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);" print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);" diff --git a/include/curses.h.in b/include/curses.h.in index 4c886142..b76a5c4d 100644 --- a/include/curses.h.in +++ b/include/curses.h.in @@ -32,7 +32,7 @@ * and: Thomas E. Dickey 1996-on * ****************************************************************************/ -/* $Id: curses.h.in,v 1.198 2009/05/02 21:59:55 tom Exp $ */ +/* $Id: curses.h.in,v 1.199 2009/05/09 15:48:04 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -517,6 +517,12 @@ extern NCURSES_EXPORT(int) wgetnstr_events(WINDOW *,char *,int,_nc_eventlist *); #define GCC_UNUSED /* nothing */ #endif +/* + * Curses uses a helper function. Define our type for this to simplify + * extending it for the sp-funcs feature. + */ +typedef int (*NCURSES_OUTC)(int); + /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the @@ -734,7 +740,7 @@ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ -extern NCURSES_EXPORT(int) vidputs (chtype, int (*)(int)); /* implemented */ +extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* generated */ @@ -889,6 +895,10 @@ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* @GENERA #define NCURSES_SP_FUNCS @NCURSES_PATCH@ #define NCURSES_SP_NAME(name) name##_sp +/* Define the sp-funcs helper function */ +#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) +typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); + extern NCURSES_EXPORT(SCREEN*) new_prescr(void); /* implemented */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented */ @@ -961,7 +971,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* impleme extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented */ -extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, int (*)(int)); /* implemented */ +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented */ #if @NCURSES_EXT_FUNCS@ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); @@ -982,6 +992,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name +#define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ diff --git a/include/curses.wide b/include/curses.wide index 6ba9280f..e21e4b40 100644 --- a/include/curses.wide +++ b/include/curses.wide @@ -1,4 +1,4 @@ -/* $Id: curses.wide,v 1.38 2009/05/02 23:12:00 tom Exp $ */ +/* $Id: curses.wide,v 1.39 2009/05/09 15:43:00 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in @@ -140,7 +140,7 @@ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, short, void *); /* implemented */ -extern NCURSES_EXPORT(int) vid_puts (attr_t, short, void *, int (*)(int)); /* implemented */ +extern NCURSES_EXPORT(int) vid_puts (attr_t, short, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ @@ -172,7 +172,7 @@ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* impleme extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, short, void *); -extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, short, void *, int (*)(int)); +extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, short, void *, NCURSES_SP_OUTC); #endif #ifndef NCURSES_NOMACROS diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk index 19ca2dd9..e487038d 100644 --- a/ncurses/base/MKkeyname.awk +++ b/ncurses/base/MKkeyname.awk @@ -1,4 +1,4 @@ -# $Id: MKkeyname.awk,v 1.41 2009/02/15 00:24:58 tom Exp $ +# $Id: MKkeyname.awk,v 1.43 2009/05/09 19:01:49 tom Exp $ ############################################################################## # Copyright (c) 1999-2008,2009 Free Software Foundation, Inc. # # # @@ -67,7 +67,8 @@ END { print "#define SIZEOF_TABLE 256" print "#define MyTable _nc_globals.keyname_table" print "" - print "NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)" + print "NCURSES_EXPORT(NCURSES_CONST char *)" + print "safe_keyname (SCREEN *sp, int c)" print "{" print " int i;" print " char name[20];" @@ -116,14 +117,14 @@ END { print " result = MyTable[c];" print " }" print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES" - print " } else if (result == 0 && cur_term != 0) {" + print " } else if (result == 0 && HasTerminal(sp)) {" print " int j, k;" print " char * bound;" - print " TERMTYPE *tp = &(cur_term->type);" + print " TERMTYPE *tp = &(TerminalOf(sp)->type);" print " int save_trace = _nc_tracing;" print "" print " _nc_tracing = 0; /* prevent recursion via keybound() */" - print " for (j = 0; (bound = keybound(c, j)) != 0; ++j) {" + print " for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != 0; ++j) {" print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {" print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {" print " result = ExtStrname(tp, k, strnames);" @@ -142,18 +143,10 @@ END { print "}" print "" print "NCURSES_EXPORT(NCURSES_CONST char *)" - print "NCURSES_SP_NAME(keyname) (NCURSES_SP_DCLx int c)" - print "{" - print "\treturn _nc_keyname(SP_PARM, c);" - print "}" - print "" - print "#if NCURSES_SP_FUNCS" - print "NCURSES_EXPORT(NCURSES_CONST char *)" print "keyname (int c)" print "{" - print " return NCURSES_SP_NAME(keyname) (CURRENT_SCREEN, c);" + print " return safe_keyname (CURRENT_SCREEN, c);" print "}" - print "#endif" print "" print "#if NO_LEAKS" print "void _nc_keyname_leaks(void)" diff --git a/ncurses/base/define_key.c b/ncurses/base/define_key.c index ea07416b..d2ebd6ef 100644 --- a/ncurses/base/define_key.c +++ b/ncurses/base/define_key.c @@ -33,27 +33,27 @@ #include -MODULE_ID("$Id: define_key.c,v 1.15 2009/02/15 00:30:40 tom Exp $") +MODULE_ID("$Id: define_key.c,v 1.17 2009/05/09 18:30:16 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode) { int code = ERR; - T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode)); - if (SP_PARM == 0) { + T((T_CALLED("define_key(%p, %s,%d)"), SP_PARM, _nc_visbuf(str), keycode)); + if (SP_PARM == 0 || !HasTInfoTerminal(SP_PARM)) { code = ERR; } else if (keycode > 0) { unsigned ukey = (unsigned) keycode; if (str != 0) { - define_key(str, 0); - } else if (has_key(keycode)) { + NCURSES_SP_NAME(define_key) (NCURSES_SP_ARGx str, 0); + } else if (NCURSES_SP_NAME(has_key) (NCURSES_SP_ARGx keycode)) { while (_nc_remove_key(&(SP_PARM->_keytry), ukey)) code = OK; } if (str != 0) { - if (key_defined(str) == 0) { + if (NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx str) == 0) { if (_nc_add_to_try(&(SP_PARM->_keytry), str, ukey) == OK) { code = OK; } else { diff --git a/ncurses/base/lib_beep.c b/ncurses/base/lib_beep.c index 1d2f5040..0093a382 100644 --- a/ncurses/base/lib_beep.c +++ b/ncurses/base/lib_beep.c @@ -43,7 +43,11 @@ #include #include /* beep, flash */ -MODULE_ID("$Id: lib_beep.c,v 1.11 2009/02/15 00:32:06 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_beep.c,v 1.13 2009/05/10 00:48:29 tom Exp $") /* * beep() diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c index e5985798..3ad82150 100644 --- a/ncurses/base/lib_color.c +++ b/ncurses/base/lib_color.c @@ -43,7 +43,11 @@ #include #include -MODULE_ID("$Id: lib_color.c,v 1.88 2009/02/15 00:33:02 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_color.c,v 1.91 2009/05/10 00:48:29 tom Exp $") /* * These should be screen structure members. They need to be globals for @@ -155,31 +159,39 @@ toggled_colors(int c) } static void -set_background_color(int bg, int (*outc) (int)) +set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc) { if (set_a_background) { TPUTS_TRACE("set_a_background"); - tputs(TPARM_1(set_a_background, bg), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(set_a_background, bg), + 1, outc); } else { TPUTS_TRACE("set_background"); - tputs(TPARM_1(set_background, toggled_colors(bg)), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(set_background, toggled_colors(bg)), + 1, outc); } } static void -set_foreground_color(int fg, int (*outc) (int)) +set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc) { if (set_a_foreground) { TPUTS_TRACE("set_a_foreground"); - tputs(TPARM_1(set_a_foreground, fg), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(set_a_foreground, fg), + 1, outc); } else { TPUTS_TRACE("set_foreground"); - tputs(TPARM_1(set_foreground, toggled_colors(fg)), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(set_foreground, toggled_colors(fg)), + 1, outc); } } static void -init_color_table(void) +init_color_table(NCURSES_SP_DCL0) { const color_t *tp; int n; @@ -208,7 +220,7 @@ init_color_table(void) * Reset the color pair, e.g., to whatever color pair 0 is. */ static bool -reset_color_pair(void) +reset_color_pair(NCURSES_SP_DCL0) { bool result = FALSE; @@ -228,13 +240,16 @@ reset_color_pair(void) bool _nc_reset_colors(void) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif int result = FALSE; T((T_CALLED("_nc_reset_colors()"))); if (SP->_color_defs > 0) SP->_color_defs = -(SP->_color_defs); - if (reset_color_pair()) + if (reset_color_pair(NCURSES_SP_ARG)) result = TRUE; if (orig_colors != 0) { TPUTS_TRACE("orig_colors"); @@ -257,9 +272,13 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0) result = OK; } else { - if (reset_color_pair() != TRUE) { - set_foreground_color(default_fg(), _nc_outch); - set_background_color(default_bg(), _nc_outch); + if (reset_color_pair(NCURSES_SP_ARG) != TRUE) { + set_foreground_color(NCURSES_SP_ARGx + default_fg(), + NCURSES_SP_NAME(_nc_outch)); + set_background_color(NCURSES_SP_ARGx + default_bg(), + NCURSES_SP_NAME(_nc_outch)); } if (max_pairs > 0 && max_colors > 0) { @@ -286,7 +305,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0) if (SP_PARM->_color_table != 0) { SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(), default_bg()); - init_color_table(); + init_color_table(NCURSES_SP_ARG); T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS)); @@ -647,7 +666,11 @@ pair_content(short pair, short *f, short *b) #endif NCURSES_EXPORT(void) -_nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int)) +NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx + short old_pair, + short pair, + bool reverse, + NCURSES_SP_OUTC outc) { NCURSES_COLOR_T fg = COLOR_DEFAULT; NCURSES_COLOR_T bg = COLOR_DEFAULT; @@ -658,7 +681,9 @@ _nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int)) } else if (pair != 0) { if (set_color_pair) { TPUTS_TRACE("set_color_pair"); - tputs(TPARM_1(set_color_pair, pair), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(set_color_pair, pair), + 1, outc); return; } else if (SP != 0) { pair_content((short) pair, &fg, &bg); @@ -679,17 +704,17 @@ _nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int)) if (SP->_has_sgr_39_49 && isDefaultColor(old_bg) && !isDefaultColor(old_fg)) { - tputs("\033[39m", 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc); } else if (SP->_has_sgr_39_49 && isDefaultColor(old_fg) && !isDefaultColor(old_bg)) { - tputs("\033[49m", 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc); } else #endif - reset_color_pair(); + reset_color_pair(NCURSES_SP_ARG); } } else { - reset_color_pair(); + reset_color_pair(NCURSES_SP_ARG); if (old_pair < 0) return; } @@ -711,9 +736,22 @@ _nc_do_color(short old_pair, short pair, bool reverse, int (*outc) (int)) fg, bg)); if (!isDefaultColor(fg)) { - set_foreground_color(fg, outc); + set_foreground_color(NCURSES_SP_ARGx fg, outc); } if (!isDefaultColor(bg)) { - set_background_color(bg, outc); + set_background_color(NCURSES_SP_ARGx bg, outc); } } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_do_color(short old_pair, short pair, bool reverse, NCURSES_OUTC outc) +{ + SetSafeOutcWrapper(outc); + NCURSES_SP_NAME(_nc_do_color) (CURRENT_SCREEN, + old_pair, + pair, + reverse, + _nc_outc_wrapper); +} +#endif diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c index b92c4033..e7a4b89d 100644 --- a/ncurses/base/lib_delwin.c +++ b/ncurses/base/lib_delwin.c @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_delwin.c,v 1.17 2008/06/07 14:10:56 tom Exp $") +MODULE_ID("$Id: lib_delwin.c,v 1.18 2009/05/09 18:30:57 tom Exp $") static bool cannot_delete(WINDOW *win) @@ -48,7 +48,7 @@ cannot_delete(WINDOW *win) WINDOWLIST *p; bool result = TRUE; - for (each_window(p)) { + for (each_window(SP, p)) { if (&(p->win) == win) { result = FALSE; } else if ((p->win._flags & _SUBWIN) != 0 diff --git a/ncurses/base/lib_dft_fgbg.c b/ncurses/base/lib_dft_fgbg.c index 0082347b..1d8f5d24 100644 --- a/ncurses/base/lib_dft_fgbg.c +++ b/ncurses/base/lib_dft_fgbg.c @@ -34,7 +34,11 @@ #include #include -MODULE_ID("$Id: lib_dft_fgbg.c,v 1.19 2009/02/14 21:53:21 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_dft_fgbg.c,v 1.21 2009/05/10 00:48:29 tom Exp $") /* * Modify the behavior of color-pair 0 so that the library doesn't assume that @@ -44,7 +48,7 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (NCURSES_SP_DCL0) { T((T_CALLED("use_default_colors()"))); - returnCode(NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_ARGx - 1, -1)); + returnCode(NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_ARGx -1, -1)); } #if NCURSES_SP_FUNCS diff --git a/ncurses/base/lib_flash.c b/ncurses/base/lib_flash.c index eb6fa654..68fea134 100644 --- a/ncurses/base/lib_flash.c +++ b/ncurses/base/lib_flash.c @@ -43,7 +43,11 @@ #include #include /* beep, flash */ -MODULE_ID("$Id: lib_flash.c,v 1.7 2009/02/15 00:35:15 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_flash.c,v 1.9 2009/05/10 00:48:29 tom Exp $") /* * flash() diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c index dbdf443f..86308217 100644 --- a/ncurses/base/lib_freeall.c +++ b/ncurses/base/lib_freeall.c @@ -40,7 +40,7 @@ extern int malloc_errfd; /* FIXME */ #endif -MODULE_ID("$Id: lib_freeall.c,v 1.57 2009/04/19 14:31:26 tom Exp $") +MODULE_ID("$Id: lib_freeall.c,v 1.58 2009/05/09 18:34:30 tom Exp $") /* * Free all ncurses data. This is used for testing only (there's no practical @@ -66,14 +66,14 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0) if (SP_PARM != 0) { _nc_lock_global(curses); - while (_nc_windows != 0) { + while (WindowList(SP_PARM) != 0) { bool deleted = FALSE; /* Delete only windows that're not a parent */ - for (each_window(p)) { + for (each_window(SP_PARM, p)) { bool found = FALSE; - for (each_window(q)) { + for (each_window(SP_PARM, q)) { if ((p != q) && (q->win._flags & _SUBWIN) && (&(p->win) == q->win._parent)) { diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c index b17df03d..0a71db51 100644 --- a/ncurses/base/lib_getstr.c +++ b/ncurses/base/lib_getstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 * @@ -39,9 +39,8 @@ */ #include -#include -MODULE_ID("$Id: lib_getstr.c,v 1.27 2008/08/16 19:20:04 tom Exp $") +MODULE_ID("$Id: lib_getstr.c,v 1.28 2009/05/09 17:02:41 tom Exp $") /* * This wipes out the last character, no matter whether it was a tab, control @@ -89,19 +88,19 @@ wgetnstr_events(WINDOW *win, if (!win) returnCode(ERR); - _nc_get_tty_mode(&buf); + NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx &buf); oldnl = sp->_nl; oldecho = sp->_echo; oldraw = sp->_raw; oldcbreak = sp->_cbreak; - nl(); - noecho(); - noraw(); - cbreak(); + NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noraw) (NCURSES_SP_ARG); + NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG); - erasec = erasechar(); - killc = killchar(); + erasec = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG); + killc = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG); oldstr = str; getyx(win, y, x); @@ -144,7 +143,7 @@ wgetnstr_events(WINDOW *win, } } else if (ch >= KEY_MIN || (maxlen >= 0 && str - oldstr >= maxlen)) { - beep(); + NCURSES_SP_NAME(beep) (NCURSES_SP_ARG); } else { *str++ = (char) ch; if (oldecho == TRUE) { @@ -193,7 +192,7 @@ wgetnstr_events(WINDOW *win, sp->_raw = oldraw; sp->_cbreak = oldcbreak; - _nc_set_tty_mode(&buf); + NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx &buf); *str = '\0'; if (ch == ERR) diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index c7af9ce2..f0ad82fc 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -79,7 +79,11 @@ #include -MODULE_ID("$Id: lib_mouse.c,v 1.105 2009/02/28 21:09:20 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_mouse.c,v 1.107 2009/05/10 00:48:29 tom Exp $") #include diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c index 8dd70e0f..11397fba 100644 --- a/ncurses/base/lib_newterm.c +++ b/ncurses/base/lib_newterm.c @@ -46,10 +46,14 @@ #define _POSIX_SOURCE #endif +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + #include /* clear_screen, cup & friends, cur_term */ #include -MODULE_ID("$Id: lib_newterm.c,v 1.75 2009/04/18 19:22:08 tom Exp $") +MODULE_ID("$Id: lib_newterm.c,v 1.77 2009/05/10 00:48:29 tom Exp $") #ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */ #define ONLCR 0 diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c index e7a30bf9..7d3b02be 100644 --- a/ncurses/base/lib_newwin.c +++ b/ncurses/base/lib_newwin.c @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$Id: lib_newwin.c,v 1.54 2009/04/18 21:02:34 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.57 2009/05/09 23:40:03 tom Exp $") #define window_is(name) ((sp)->_##name == win) @@ -88,11 +88,11 @@ _nc_freewin(WINDOW *win) if (win != 0) { if (_nc_try_global(curses) == 0) { q = 0; - for (each_window(p)) { + for (each_window(SP, p)) { if (&(p->win) == win) { remove_window_from_screen(win); if (q == 0) - _nc_windows = p->next; + WindowList(SP) = p->next; else q->next = p->next; @@ -133,7 +133,9 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx if (num_columns == 0) num_columns = screen_columns(SP_PARM) - begx; - if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0) + win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx + num_lines, num_columns, begy, begx, 0); + if (win == 0) returnWin(0); for (i = 0; i < num_lines; i++) { @@ -164,6 +166,9 @@ newwin(int num_lines, int num_columns, int begy, int begx) NCURSES_EXPORT(WINDOW *) derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif WINDOW *win; int i; int flags = _SUBWIN; @@ -189,8 +194,10 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) if (orig->_flags & _ISPAD) flags |= _ISPAD; - if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, - orig->_begx + begx, flags)) == 0) + win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx num_lines, num_columns, + orig->_begy + begy, + orig->_begx + begx, flags); + if (win == 0) returnWin(0); win->_pary = begy; @@ -235,7 +242,8 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx WINDOW *win; bool is_pad = (flags & _ISPAD); - T((T_CALLED("_nc_makenew(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx)); + T((T_CALLED("_nc_makenew(%p,%d,%d,%d,%d)"), + SP_PARM, num_lines, num_columns, begy, begx)); if (SP_PARM == 0) returnWin(0); @@ -329,9 +337,9 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx win->_flags |= _SCROLLWIN; } - wp->next = _nc_windows; + wp->next = WindowList(SP_PARM); wp->screen = SP_PARM; - _nc_windows = wp; + WindowList(SP_PARM) = wp; T((T_CREATE("window %p"), win)); @@ -365,3 +373,23 @@ _nc_screen_of(WINDOW *win) } return (sp); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +_nc_curscr_of(SCREEN *sp) +{ + return sp == 0 ? 0 : sp->_curscr; +} + +NCURSES_EXPORT(WINDOW *) +_nc_newscr_of(SCREEN *sp) +{ + return sp == 0 ? 0 : sp->_newscr; +} + +NCURSES_EXPORT(WINDOW *) +_nc_stdscr_of(SCREEN *sp) +{ + return sp == 0 ? 0 : sp->_stdscr; +} +#endif diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c index 745a3667..aa1592e0 100644 --- a/ncurses/base/lib_screen.c +++ b/ncurses/base/lib_screen.c @@ -35,7 +35,11 @@ #include -MODULE_ID("$Id: lib_screen.c,v 1.32 2009/02/15 00:39:13 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_screen.c,v 1.34 2009/05/10 00:48:29 tom Exp $") #define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index 70148cd4..632bfba0 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -45,7 +45,11 @@ #include /* cur_term */ #include -MODULE_ID("$Id: lib_set_term.c,v 1.118 2009/02/15 00:39:46 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_set_term.c,v 1.122 2009/05/10 00:48:29 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN *screenp) @@ -257,6 +261,9 @@ _nc_setupscreen(int slines GCC_UNUSED, bool filtered, int slk_format) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif char *env; int bottom_stolen = 0; bool support_cookies = USE_XMC_SUPPORT; @@ -556,8 +563,8 @@ _nc_setupscreen(int slines GCC_UNUSED, def_shell_mode(); def_prog_mode(); - for (rop = ripoff_stack; - rop != ripoff_sp && (rop - ripoff_stack) < N_RIPS; + for (rop = safe_ripoff_stack; + rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS; rop++) { /* If we must simulate soft labels, grab off the line to be used. @@ -596,7 +603,7 @@ _nc_setupscreen(int slines GCC_UNUSED, } } /* reset the stack */ - ripoff_sp = ripoff_stack; + safe_ripoff_sp = safe_ripoff_stack; T(("creating stdscr")); assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines); @@ -616,25 +623,35 @@ _nc_setupscreen(int slines GCC_UNUSED, * off from the top or bottom. */ NCURSES_EXPORT(int) -_nc_ripoffline(int line, int (*init) (WINDOW *, int)) +NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_DCLx + int line, + int (*init) (WINDOW *, int)) { T((T_CALLED("_nc_ripoffline(%d, %p)"), line, init)); if (line != 0) { - if (ripoff_sp == 0) - ripoff_sp = ripoff_stack; - if (ripoff_sp >= ripoff_stack + N_RIPS) + if (safe_ripoff_sp == 0) + safe_ripoff_sp = safe_ripoff_stack; + if (safe_ripoff_sp >= safe_ripoff_stack + N_RIPS) returnCode(ERR); - ripoff_sp->line = line; - ripoff_sp->hook = init; - ripoff_sp++; + safe_ripoff_sp->line = line; + safe_ripoff_sp->hook = init; + safe_ripoff_sp++; } returnCode(OK); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_ripoffline(int line, int (*init) (WINDOW *, int)) +{ + return NCURSES_SP_NAME(_nc_ripoffline) (CURRENT_SCREEN, line, init); +} +#endif + NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (NCURSES_SP_DCLx int line, @@ -646,7 +663,9 @@ NCURSES_SP_NAME(ripoffline) (NCURSES_SP_DCLx if (line == 0) returnCode(OK); - returnCode(_nc_ripoffline((line < 0) ? -1 : 1, init)); + returnCode(NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_ARGx + (line < 0) ? -1 : 1, + init)); } #if NCURSES_SP_FUNCS diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c index 58e887b1..2f1a9211 100644 --- a/ncurses/base/lib_slk.c +++ b/ncurses/base/lib_slk.c @@ -45,7 +45,11 @@ #include #include /* num_labels, label_*, plab_norm */ -MODULE_ID("$Id: lib_slk.c,v 1.36 2009/02/15 00:33:48 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_slk.c,v 1.38 2009/05/10 00:48:29 tom Exp $") /* * Free any memory related to soft labels, return an error. @@ -68,6 +72,9 @@ slk_failed(void) NCURSES_EXPORT(int) _nc_slk_initialize(WINDOW *stwin, int cols) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif int i, x; int res = OK; unsigned max_length; diff --git a/ncurses/base/lib_slkinit.c b/ncurses/base/lib_slkinit.c index 7e80e82c..29cfeedb 100644 --- a/ncurses/base/lib_slkinit.c +++ b/ncurses/base/lib_slkinit.c @@ -30,7 +30,6 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * - * and: Juergen Pfeifer 2009 * ****************************************************************************/ /* @@ -40,17 +39,21 @@ */ #include -MODULE_ID("$Id: lib_slkinit.c,v 1.8 2009/02/15 00:42:36 tom Exp $") +MODULE_ID("$Id: lib_slkinit.c,v 1.10 2009/05/09 18:32:07 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (NCURSES_SP_DCLx int format) { int code = ERR; - T((T_CALLED("slk_init(%d)"), format)); - if (format >= 0 && format <= 3 && !_nc_globals.slk_format) { - _nc_globals.slk_format = 1 + format; - code = _nc_ripoffline(-SLK_LINES(_nc_globals.slk_format), _nc_slk_initialize); + T((T_CALLED("slk_init(%p,%d)"), SP_PARM, format)); + + if (SP_PARM && format >= 0 && format <= 3 && !SP_PARM->slk_format && + SP_PARM->_prescreen) { + SP_PARM->slk_format = 1 + format; + code = NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_ARGx + -SLK_LINES(SP_PARM->slk_format), + _nc_slk_initialize); } returnCode(code); } @@ -59,6 +62,6 @@ NCURSES_SP_NAME(slk_init) (NCURSES_SP_DCLx int format) NCURSES_EXPORT(int) slk_init(int format) { - return NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN, format); + return NCURSES_SP_NAME(slk_init) (CURRENT_SCREEN_PRE, format); } #endif diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c index d0b4c547..96ca6a6e 100644 --- a/ncurses/base/lib_slkrefr.c +++ b/ncurses/base/lib_slkrefr.c @@ -40,7 +40,11 @@ #include #include /* num_labels, label_*, plab_norm */ -MODULE_ID("$Id: lib_slkrefr.c,v 1.18 2009/02/15 00:33:48 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_slkrefr.c,v 1.20 2009/05/10 00:48:29 tom Exp $") /* * Paint the info line for the PC style SLK emulation. @@ -68,6 +72,9 @@ slk_paint_info(WINDOW *win) static void slk_intern_refresh(SLK * slk) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif int i; int fmt = SP->slk_format; diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c index 0f3ea72b..cf99ad0d 100644 --- a/ncurses/base/resizeterm.c +++ b/ncurses/base/resizeterm.c @@ -41,7 +41,11 @@ #include #include -MODULE_ID("$Id: resizeterm.c,v 1.35 2009/04/18 20:32:33 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: resizeterm.c,v 1.39 2009/05/10 00:48:29 tom Exp $") #define stolen_lines (screen_lines - SP->_lines_avail) @@ -64,18 +68,23 @@ static int current_cols; static void show_window_sizes(const char *name) { + SCREEN *sp; WINDOWLIST *wp; _nc_lock_global(curses); - _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS, - screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN)); - for (each_window(wp)) { - _tracef(" window %p is %2ld x %2ld at %2ld,%2ld", - &(wp->win), - (long) wp->win._maxy + 1, - (long) wp->win._maxx + 1, - (long) wp->win._begy, - (long) wp->win._begx); + for (each_screen(sp)) { + _tracef("%s resizing: %p: %2d x %2d (%2d x %2d)", name, sp, + *(ptrLines(sp)), + *(ptrCols(sp)), + screen_lines(sp), screen_columns(sp)); + for (each_window(sp, wp)) { + _tracef(" window %p is %2ld x %2ld at %2ld,%2ld", + &(wp->win), + (long) wp->win._maxy + 1, + (long) wp->win._maxx + 1, + (long) wp->win._begy, + (long) wp->win._begx); + } } _nc_unlock_global(curses); } @@ -86,15 +95,23 @@ show_window_sizes(const char *name) * structure's size. */ NCURSES_EXPORT(bool) -is_term_resized(int ToLines, int ToCols) +NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_DCLx int ToLines, int ToCols) { - T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols)); + T((T_CALLED("is_term_resized(%p, %d, %d)"), SP_PARM, ToLines, ToCols)); returnCode(ToLines > 0 && ToCols > 0 - && (ToLines != screen_lines(CURRENT_SCREEN) - || ToCols != screen_columns(CURRENT_SCREEN))); + && (ToLines != screen_lines(SP_PARM) + || ToCols != screen_columns(SP_PARM))); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(bool) +is_term_resized(int ToLines, int ToCols) +{ + return NCURSES_SP_NAME(is_term_resized) (CURRENT_SCREEN, ToLines, ToCols); +} +#endif + /* */ static ripoff_t * @@ -104,6 +121,9 @@ ripped_window(WINDOW *win) ripoff_t *rop; if (win != 0) { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif for (each_ripoff(rop)) { if (rop->win == win && rop->line != 0) { result = rop; @@ -125,6 +145,9 @@ ripped_bottom(WINDOW *win) ripoff_t *rop; if (win != 0) { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif for (each_ripoff(rop)) { if (rop->line < 0) { result -= rop->line; @@ -146,9 +169,12 @@ child_depth(WINDOW *cmp) int depth = 0; if (cmp != 0) { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(cmp); +#endif WINDOWLIST *wp; - for (each_window(wp)) { + for (each_window(sp, wp)) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { depth = 1 + child_depth(tst); @@ -184,7 +210,7 @@ static int adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS) { int result; - int bottom = CurLines + SP->_topstolen - stolen; + int bottom = CurLines + _nc_screen_of(win)->_topstolen - stolen; int myLines = win->_maxy + 1; int myCols = win->_maxx + 1; ripoff_t *rop = ripped_window(win); @@ -239,19 +265,19 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS) * children, decrease those to fit, then decrease the containing window, etc. */ static int -decrease_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) +decrease_size(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS) { bool found; int depth = 0; WINDOWLIST *wp; - T((T_CALLED("decrease_size(%d, %d)"), ToLines, ToCols)); + T((T_CALLED("decrease_size(%p, %d, %d)"), SP_PARM, ToLines, ToCols)); do { found = FALSE; TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d", ToLines, ToCols, depth)); - for (each_window(wp)) { + for (each_window(SP_PARM, wp)) { WINDOW *win = &(wp->win); if (!(win->_flags & _ISPAD)) { @@ -273,19 +299,19 @@ decrease_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) * parent, increase those to fit, then increase the contained window, etc. */ static int -increase_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) +increase_size(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS) { bool found; int depth = 0; WINDOWLIST *wp; - T((T_CALLED("increase_size(%d, %d)"), ToLines, ToCols)); + T((T_CALLED("increase_size(%p, %d, %d)"), SP_PARM, ToLines, ToCols)); do { found = FALSE; TR(TRACE_UPDATE, ("increasing size of windows to %dx%d, depth=%d", ToLines, ToCols, depth)); - for (each_window(wp)) { + for (each_window(SP_PARM, wp)) { WINDOW *win = &(wp->win); if (!(win->_flags & _ISPAD)) { @@ -307,25 +333,26 @@ increase_size(int ToLines, int ToCols, int stolen EXTRA_DCLS) * such as ungetch(). */ NCURSES_EXPORT(int) -resize_term(int ToLines, int ToCols) +NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols) { int result = OK EXTRA_ARGS; int was_stolen; - T((T_CALLED("resize_term(%d,%d) old(%d,%d)"), - ToLines, ToCols, - screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN))); + T((T_CALLED("resize_term(%p,%d,%d) old(%d,%d)"), + SP_PARM, ToLines, ToCols, + SP_PARM == 0 ? -1 : screen_lines(SP_PARM), + SP_PARM == 0 ? -1 : screen_columns(SP_PARM))); - if (SP == 0) { + if (SP_PARM == 0) { returnCode(ERR); } _nc_lock_global(curses); - was_stolen = (screen_lines(CURRENT_SCREEN) - SP->_lines_avail); - if (is_term_resized(ToLines, ToCols)) { - int myLines = CurLines = screen_lines(CURRENT_SCREEN); - int myCols = CurCols = screen_columns(CURRENT_SCREEN); + was_stolen = (screen_lines(SP_PARM) - SP_PARM->_lines_avail); + if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) { + int myLines = CurLines = screen_lines(SP_PARM); + int myCols = CurCols = screen_columns(SP_PARM); #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { @@ -333,33 +360,35 @@ resize_term(int ToLines, int ToCols) _nc_unlock_global(tracef); } #endif - if (ToLines > screen_lines(CURRENT_SCREEN)) { - increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS); + if (ToLines > screen_lines(SP_PARM)) { + increase_size(NCURSES_SP_ARGx + myLines = ToLines, myCols, was_stolen EXTRA_ARGS); CurLines = myLines; CurCols = myCols; } - if (ToCols > screen_columns(CURRENT_SCREEN)) { - increase_size(myLines, myCols = ToCols, was_stolen EXTRA_ARGS); + if (ToCols > screen_columns(SP_PARM)) { + increase_size(NCURSES_SP_ARGx + myLines, myCols = ToCols, was_stolen EXTRA_ARGS); CurLines = myLines; CurCols = myCols; } if (ToLines < myLines || ToCols < myCols) { - decrease_size(ToLines, ToCols, was_stolen EXTRA_ARGS); + decrease_size(NCURSES_SP_ARGx ToLines, ToCols, was_stolen EXTRA_ARGS); } - screen_lines(CURRENT_SCREEN) = lines = ToLines; - screen_columns(CURRENT_SCREEN) = columns = ToCols; + screen_lines(SP_PARM) = lines = ToLines; + screen_columns(SP_PARM) = columns = ToCols; - SP->_lines_avail = lines - was_stolen; + SP_PARM->_lines_avail = lines - was_stolen; - if (SP->oldhash) { - FreeAndNull(SP->oldhash); + if (SP_PARM->oldhash) { + FreeAndNull(SP_PARM->oldhash); } - if (SP->newhash) { - FreeAndNull(SP->newhash); + if (SP_PARM->newhash) { + FreeAndNull(SP_PARM->newhash); } #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { @@ -383,6 +412,18 @@ resize_term(int ToLines, int ToCols) returnCode(result); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +resize_term(int ToLines, int ToCols) +{ + int res = ERR; + _nc_lock_global(curses); + res = NCURSES_SP_NAME(resize_term) (CURRENT_SCREEN, ToLines, ToCols); + _nc_unlock_global(curses); + return (res); +} +#endif + /* * This function reallocates NCURSES window structures. It is invoked in * response to a SIGWINCH interrupt. Other user-defined windows may also need @@ -392,34 +433,34 @@ resize_term(int ToLines, int ToCols) * invoked directly from the signal handler. */ NCURSES_EXPORT(int) -resizeterm(int ToLines, int ToCols) +NCURSES_SP_NAME(resizeterm) (NCURSES_SP_DCLx int ToLines, int ToCols) { int result = ERR; - T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"), - ToLines, ToCols, - screen_lines(CURRENT_SCREEN), screen_columns(CURRENT_SCREEN))); + T((T_CALLED("resizeterm(%p, %d,%d) old(%d,%d)"), + SP_PARM, ToLines, ToCols, + SP_PARM == 0 ? -1 : screen_lines(SP_PARM), screen_columns(SP_PARM))); - if (SP != 0) { + if (SP_PARM != 0) { result = OK; - SP->_sig_winch = FALSE; + SP_PARM->_sig_winch = FALSE; - if (is_term_resized(ToLines, ToCols)) { + if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) { #if USE_SIGWINCH ripoff_t *rop; - bool slk_visible = (SP != 0 - && SP->_slk != 0 - && !(SP->_slk->hidden)); + bool slk_visible = (SP_PARM != 0 + && SP_PARM->_slk != 0 + && !(SP_PARM->_slk->hidden)); if (slk_visible) { slk_clear(); } #endif - result = resize_term(ToLines, ToCols); + result = NCURSES_SP_NAME(resize_term) (NCURSES_SP_ARGx ToLines, ToCols); #if USE_SIGWINCH - safe_ungetch(SP, KEY_RESIZE); /* so application can know this */ - clearok(curscr, TRUE); /* screen contents are unknown */ + safe_ungetch(SP_PARM, KEY_RESIZE); /* so application can know this */ + clearok(CurScreen(SP_PARM), TRUE); /* screen contents are unknown */ /* ripped-off lines are a special case: if we did not lengthen * them, we haven't moved them either. repaint them, too. @@ -429,7 +470,7 @@ resizeterm(int ToLines, int ToCols) * not know which are really on top. */ for (each_ripoff(rop)) { - if (rop->win != stdscr + if (rop->win != StdScreen(SP_PARM) && rop->win != 0 && rop->line < 0) { @@ -442,10 +483,9 @@ resizeterm(int ToLines, int ToCols) /* soft-keys are a special case: we _know_ how to repaint them */ if (slk_visible) { - slk_restore(); - slk_touch(); - - slk_refresh(); + NCURSES_SP_NAME(slk_restore) (NCURSES_SP_ARG); + NCURSES_SP_NAME(slk_touch) (NCURSES_SP_ARG); + NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_ARG); } #endif } @@ -453,3 +493,11 @@ resizeterm(int ToLines, int ToCols) returnCode(result); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +resizeterm(int ToLines, int ToCols) +{ + return NCURSES_SP_NAME(resizeterm) (CURRENT_SCREEN, ToLines, ToCols); +} +#endif diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c index f46085af..49e0d58a 100644 --- a/ncurses/base/wresize.c +++ b/ncurses/base/wresize.c @@ -32,7 +32,7 @@ #include -MODULE_ID("$Id: wresize.c,v 1.29 2008/06/07 13:59:01 tom Exp $") +MODULE_ID("$Id: wresize.c,v 1.30 2009/05/09 18:37:43 tom Exp $") static int cleanup_lines(struct ldat *data, int length) @@ -56,7 +56,7 @@ repair_subwindows(WINDOW *cmp) _nc_lock_global(curses); - for (each_window(wp)) { + for (each_window(SP, wp)) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 04f7c914..007ed445 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.412 2009/05/02 21:28:57 tom Exp $ + * $Id: curses.priv.h,v 1.416 2009/05/10 01:01:51 tom Exp $ * * curses.priv.h * @@ -193,6 +193,11 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t); #define if_USE_SCROLL_HINTS(stmt) /*nothing*/ #endif +/* + * Terminal drivers... + */ +#define USE_TERM_DRIVER 0 + /* * 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 @@ -279,17 +284,36 @@ color_t; #include -#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 + +/* + * 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 + #include #if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT @@ -655,7 +679,7 @@ typedef struct { long tgetent_sequence; WINDOWLIST *_nc_windowlist; -#define _nc_windows _nc_globals._nc_windowlist +#define WindowList(sp) _nc_globals._nc_windowlist #if USE_HOME_TERMINFO char *home_terminfo; @@ -689,7 +713,9 @@ typedef struct { 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 @@ -733,8 +759,16 @@ typedef struct { #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; @@ -763,6 +797,10 @@ struct screen { 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 */ @@ -944,7 +982,7 @@ struct screen { 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() */ @@ -964,6 +1002,15 @@ struct screen { char tracechr_buf[40]; char tracemse_buf[TRACEMSE_MAX]; #endif +#if 0 + 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. */ @@ -1002,7 +1049,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; 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 \ @@ -1277,8 +1324,8 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; * 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 @@ -1456,7 +1503,7 @@ extern NCURSES_EXPORT(void) name (void); \ __FILE__, __LINE__, \ sp->_cursrow, \ sp->_curscol)); \ - _nc_do_xmc_glitch(chg); \ + NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \ } \ } #else @@ -1546,8 +1593,8 @@ extern NCURSES_EXPORT(void) _nc_linedump (void); #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 @@ -1637,7 +1684,6 @@ extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *); /* 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); @@ -1656,7 +1702,7 @@ 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_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 *); @@ -1722,7 +1768,7 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; #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) @@ -1735,16 +1781,20 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; 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 CURRENT_SCREEN SP #define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 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 @@ -1802,23 +1852,23 @@ typedef void* TERM_HANDLE; 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 { @@ -1893,8 +1943,13 @@ 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)) +#if 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)) /* @@ -1942,14 +1997,13 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_savetty)(SCREEN*); 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; @@ -1993,6 +2047,7 @@ extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t * #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); diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c index 5ad750f9..e747effc 100644 --- a/ncurses/tinfo/comp_scan.c +++ b/ncurses/tinfo/comp_scan.c @@ -51,7 +51,7 @@ #include #include -MODULE_ID("$Id: comp_scan.c,v 1.83 2008/08/16 19:22:55 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.84 2009/05/09 16:37:42 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -61,19 +61,13 @@ MODULE_ID("$Id: comp_scan.c,v 1.83 2008/08/16 19:22:55 tom Exp $") #define iswhite(ch) (ch == ' ' || ch == '\t') -NCURSES_EXPORT_VAR(int) -_nc_syntax = 0; /* termcap or terminfo? */ -NCURSES_EXPORT_VAR(long) -_nc_curr_file_pos = 0; /* file offset of current line */ -NCURSES_EXPORT_VAR(long) -_nc_comment_start = 0; /* start of comment range before name */ -NCURSES_EXPORT_VAR(long) -_nc_comment_end = 0; /* end of comment range before name */ -NCURSES_EXPORT_VAR(long) -_nc_start_line = 0; /* start line of current entry */ - -NCURSES_EXPORT_VAR(struct token) -_nc_curr_token = +NCURSES_EXPORT_VAR (int) _nc_syntax = 0; /* termcap or terminfo? */ +NCURSES_EXPORT_VAR (long) _nc_curr_file_pos = 0; /* file offset of current line */ +NCURSES_EXPORT_VAR (long) _nc_comment_start = 0; /* start of comment range before name */ +NCURSES_EXPORT_VAR (long) _nc_comment_end = 0; /* end of comment range before name */ +NCURSES_EXPORT_VAR (long) _nc_start_line = 0; /* start line of current entry */ + +NCURSES_EXPORT_VAR (struct token) _nc_curr_token = { 0, 0, 0 }; @@ -91,8 +85,7 @@ static int pushtype; /* type of pushback token */ static char *pushname; #if NCURSES_EXT_FUNCS -NCURSES_EXPORT_VAR(bool) -_nc_disable_period = FALSE; /* used by tic -a option */ +NCURSES_EXPORT_VAR (bool) _nc_disable_period = FALSE; /* used by tic -a option */ #endif /***************************************************************************** @@ -637,7 +630,8 @@ _nc_get_token(bool silent) /* just to get rid of the compiler warning */ type = UNDEF; if (!silent) - _nc_warning("Illegal character - '%s'", unctrl((chtype) ch)); + _nc_warning("Illegal character - '%s'", + unctrl((chtype) ch)); } } /* end else (first_column == FALSE) */ } /* end else (ch != EOF) */ diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c index 9fbb5d1e..1ef8090b 100644 --- a/ncurses/tinfo/init_keytry.c +++ b/ncurses/tinfo/init_keytry.c @@ -31,7 +31,7 @@ #include -MODULE_ID("$Id: init_keytry.c,v 1.13 2009/04/18 18:53:37 tom Exp $") +MODULE_ID("$Id: init_keytry.c,v 1.14 2009/05/10 00:48:29 tom Exp $") /* ** _nc_init_keytry() @@ -45,7 +45,7 @@ MODULE_ID("$Id: init_keytry.c,v 1.13 2009/04/18 18:53:37 tom Exp $") * than cur_term. */ #undef CUR -#define CUR (sp->_term)->type. +#define CUR SP_TERMTYPE #if BROKEN_LINKER #undef _nc_tinfo_fkeys diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c index 4eb2602b..d0bec27c 100644 --- a/ncurses/tinfo/lib_acs.c +++ b/ncurses/tinfo/lib_acs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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,12 +35,16 @@ #include #include /* ena_acs, acs_chars */ -MODULE_ID("$Id: lib_acs.c,v 1.37 2009/03/21 19:39:23 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_acs.c,v 1.39 2009/05/10 00:48:29 tom Exp $") #if BROKEN_LINKER || USE_REENTRANT #define MyBuffer _nc_prescreen.real_acs_map -NCURSES_EXPORT_VAR(chtype *) -NCURSES_PUBLIC_VAR(acs_map)(void) +NCURSES_EXPORT(chtype *) +NCURSES_PUBLIC_VAR(acs_map) (void) { if (MyBuffer == 0) MyBuffer = typeCalloc(chtype, ACS_LEN); @@ -48,7 +52,7 @@ NCURSES_PUBLIC_VAR(acs_map)(void) } #undef MyBuffer #else -NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] = +NCURSES_EXPORT_VAR (chtype) acs_map[ACS_LEN] = { 0 }; @@ -57,6 +61,9 @@ NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] = NCURSES_EXPORT(void) _nc_init_acs(void) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif chtype *fake_map = acs_map; chtype *real_map = SP != 0 ? SP->_acs_map : fake_map; int j; diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c index 72818e2c..f80303e0 100644 --- a/ncurses/tinfo/lib_baudrate.c +++ b/ncurses/tinfo/lib_baudrate.c @@ -38,7 +38,6 @@ */ #include -#include /* cur_term, pad_char */ #include /* ospeed */ #if defined(__FreeBSD__) #include @@ -80,7 +79,7 @@ #undef USE_OLD_TTY #endif /* USE_OLD_TTY */ -MODULE_ID("$Id: lib_baudrate.c,v 1.28 2009/02/14 21:41:22 tom Exp $") +MODULE_ID("$Id: lib_baudrate.c,v 1.29 2009/02/21 17:22:13 tom Exp $") /* * int @@ -199,7 +198,7 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0) { int result; - T((T_CALLED("baudrate()"))); + T((T_CALLED("baudrate(%p)"), SP_PARM)); /* * In debugging, allow the environment symbol to override when we're @@ -207,7 +206,8 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0) * that take into account costs that depend on baudrate. */ #ifdef TRACE - if (!isatty(fileno(SP_PARM ? SP_PARM->_ofp : stdout)) + if (IsValidTIScreen(SP_PARM) + && !isatty(fileno(SP_PARM ? SP_PARM->_ofp : stdout)) && getenv("BAUDRATE") != 0) { int ret; if ((ret = _nc_getenv_num("BAUDRATE")) <= 0) @@ -217,19 +217,19 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0) } #endif - if (cur_term != 0) { + if (IsValidTIScreen(SP_PARM)) { #ifdef USE_OLD_TTY - result = cfgetospeed(&cur_term->Nttyb); + result = cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb)); ospeed = _nc_ospeed(result); #else /* !USE_OLD_TTY */ #ifdef TERMIOS - ospeed = cfgetospeed(&cur_term->Nttyb); + ospeed = cfgetospeed(&(TerminalOf(SP_PARM)->Nttyb)); #else - ospeed = cur_term->Nttyb.sg_ospeed; + ospeed = TerminalOf(SP_PARM)->Nttyb.sg_ospeed; #endif result = _nc_baudrate(ospeed); #endif - cur_term->_baudrate = result; + TerminalOf(SP_PARM)->_baudrate = result; } else { result = ERR; } diff --git a/ncurses/tinfo/lib_has_cap.c b/ncurses/tinfo/lib_has_cap.c index 546ba605..f5af76cf 100644 --- a/ncurses/tinfo/lib_has_cap.c +++ b/ncurses/tinfo/lib_has_cap.c @@ -42,7 +42,11 @@ #include -MODULE_ID("$Id: lib_has_cap.c,v 1.6 2009/04/18 17:28:45 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_has_cap.c,v 1.8 2009/05/10 00:53:52 tom Exp $") NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0) diff --git a/ncurses/tinfo/lib_longname.c b/ncurses/tinfo/lib_longname.c index 746f83f4..2164a126 100644 --- a/ncurses/tinfo/lib_longname.c +++ b/ncurses/tinfo/lib_longname.c @@ -42,20 +42,27 @@ #include -MODULE_ID("$Id: lib_longname.c,v 1.10 2009/02/15 00:48:15 tom Exp $") +MODULE_ID("$Id: lib_longname.c,v 1.11 2009/02/21 17:18:02 tom Exp $") +#if USE_REENTRANT NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0) { + static char empty[] = + {'\0'}; char *ptr; - T((T_CALLED("longname()"))); + T((T_CALLED("longname(%p)"), SP_PARM)); - for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--) - if (*ptr == '|') - returnPtr(ptr + 1); - - returnPtr(ttytype); + if (SP_PARM) { + for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype); + ptr > SP_PARM->_ttytype; + ptr--) + if (*ptr == '|') + returnPtr(ptr + 1); + returnPtr(SP_PARM->_ttytype); + } + return empty; } #if NCURSES_SP_FUNCS @@ -65,3 +72,20 @@ longname(void) return NCURSES_SP_NAME(longname) (CURRENT_SCREEN); } #endif + +#else +NCURSES_EXPORT(char *) +longname(void) +{ + char *ptr; + + T((T_CALLED("longname()"))); + + for (ptr = ttytype + strlen(ttytype); + ptr > ttytype; + ptr--) + if (*ptr == '|') + returnPtr(ptr + 1); + returnPtr(ttytype); +} +#endif diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index b037ddcb..e8125319 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -44,13 +44,20 @@ #include -MODULE_ID("$Id: lib_options.c,v 1.61 2009/05/02 21:19:53 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_options.c,v 1.63 2009/05/10 00:48:29 tom Exp $") static int _nc_meta(SCREEN *, bool); NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif T((T_CALLED("idlok(%p,%d)"), win, flag)); if (win) { @@ -234,12 +241,20 @@ has_key_internal(int keycode, TRIES * tp) || has_key_internal(keycode, tp->sibling)); } +NCURSES_EXPORT(int) +NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode) +{ + T((T_CALLED("has_key(%p,%d)"), SP_PARM, keycode)); + returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE); +} + +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) has_key(int keycode) { - T((T_CALLED("has_key(%d)"), keycode)); - returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE); + return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode); } +#endif #endif /* NCURSES_EXT_FUNCS */ /* @@ -247,7 +262,7 @@ has_key(int keycode) * than cur_term. */ #undef CUR -#define CUR (sp->_term)->type. +#define CUR SP_TERMTYPE NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_DCLx diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c index 975b46d8..6f466673 100644 --- a/ncurses/tinfo/lib_print.c +++ b/ncurses/tinfo/lib_print.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2009 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,12 +35,19 @@ #include -MODULE_ID("$Id: lib_print.c,v 1.16 2006/11/26 00:26:34 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_print.c,v 1.18 2009/05/10 00:48:29 tom Exp $") NCURSES_EXPORT(int) mcprint(char *data, int len) /* ship binary character data to the printer via mc4/mc5/mc5p */ { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif char *mybuf, *switchon; size_t onsize, offsize, res; diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c index 2d245ffb..4c0097db 100644 --- a/ncurses/tinfo/lib_termcap.c +++ b/ncurses/tinfo/lib_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 * @@ -45,7 +45,11 @@ #include -MODULE_ID("$Id: lib_termcap.c,v 1.63 2008/08/16 19:22:55 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_termcap.c,v 1.65 2009/05/10 00:48:29 tom Exp $") NCURSES_EXPORT_VAR(char *) UP = 0; NCURSES_EXPORT_VAR(char *) BC = 0; @@ -78,6 +82,9 @@ NCURSES_EXPORT_VAR(char *) BC = 0; NCURSES_EXPORT(int) tgetent(char *bufp, const char *name) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif int errcode; int n; bool found_cache = FALSE; @@ -246,6 +253,9 @@ tgetnum(NCURSES_CONST char *id) NCURSES_EXPORT(char *) tgetstr(NCURSES_CONST char *id, char **area) { +#if NCURSES_SP_FUNCS + SCREEN *sp = CURRENT_SCREEN; +#endif unsigned i; char *result = NULL; diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c index df460f95..355310ec 100644 --- a/ncurses/tinfo/lib_ti.c +++ b/ncurses/tinfo/lib_ti.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. * + * Copyright (c) 1998-2003,2009 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 * @@ -36,17 +36,17 @@ #include #include -MODULE_ID("$Id: lib_ti.c,v 1.23 2003/05/24 21:10:28 tom Exp $") +MODULE_ID("$Id: lib_ti.c,v 1.24 2009/04/18 17:37:50 tom Exp $") NCURSES_EXPORT(int) -tigetflag(NCURSES_CONST char *str) +NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str) { unsigned i; - T((T_CALLED("tigetflag(%s)"), str)); + T((T_CALLED("tigetflag(%p, %s)"), SP_PARM, str)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_boolean(i, tp) { const char *capname = ExtBoolname(tp, i, boolnames); if (!strcmp(str, capname)) { @@ -59,15 +59,23 @@ tigetflag(NCURSES_CONST char *str) returnCode(ABSENT_BOOLEAN); } +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -tigetnum(NCURSES_CONST char *str) +tigetflag(NCURSES_CONST char *str) +{ + return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) { unsigned i; - T((T_CALLED("tigetnum(%s)"), str)); + T((T_CALLED("tigetnum(%p, %s)"), SP_PARM, str)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_number(i, tp) { const char *capname = ExtNumname(tp, i, numnames); if (!strcmp(str, capname)) { @@ -81,15 +89,23 @@ tigetnum(NCURSES_CONST char *str) returnCode(CANCELLED_NUMERIC); /* Solaris returns a -1 instead */ } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +tigetnum(NCURSES_CONST char *str) +{ + return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str); +} +#endif + NCURSES_EXPORT(char *) -tigetstr(NCURSES_CONST char *str) +NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str) { unsigned i; - T((T_CALLED("tigetstr(%s)"), str)); + T((T_CALLED("tigetstr(%p, %s)"), SP_PARM, str)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_string(i, tp) { const char *capname = ExtStrname(tp, i, strnames); if (!strcmp(str, capname)) { @@ -101,3 +117,11 @@ tigetstr(NCURSES_CONST char *str) returnPtr(CANCELLED_STRING); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(char *) +tigetstr(NCURSES_CONST char *str) +{ + return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str); +} +#endif diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c index c7061796..e3dc8d32 100644 --- a/ncurses/tinfo/lib_tputs.c +++ b/ncurses/tinfo/lib_tputs.c @@ -42,12 +42,17 @@ */ #include + +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + #include #include /* padding_baud_rate, xon_xoff */ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.70 2009/05/02 20:54:22 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.73 2009/05/10 00:54:17 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -70,24 +75,28 @@ _nc_set_no_padding(SCREEN *sp) } #endif -static int (*my_outch) (int c) = _nc_outch; +#if NCURSES_SP_FUNCS +#define my_outch SP_PARM->_outch +#else +static NCURSES_SP_OUTC my_outch = NCURSES_SP_NAME(_nc_outch); +#endif NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms) { - T((T_CALLED("delay_output(%d)"), ms)); + T((T_CALLED("delay_output(%p,%d)"), SP_PARM, ms)); if (no_pad_char) { - _nc_flush(); + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); napms(ms); } else { register int nullcount; nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000); for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--) - my_outch(PC); - if (my_outch == _nc_outch) - _nc_flush(); + my_outch(NCURSES_SP_ARGx PC); + if (my_outch == NCURSES_SP_NAME(_nc_outch)) + NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); } returnCode(OK); @@ -142,14 +151,26 @@ _nc_outch(int ch) } #endif +NCURSES_EXPORT(int) +NCURSES_SP_NAME(putp) (NCURSES_SP_DCLx const char *string) +{ + return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + string, 1, NCURSES_SP_NAME(_nc_outch)); +} + +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) putp(const char *string) { - return tputs(string, 1, _nc_outch); + return NCURSES_SP_NAME(putp) (CURRENT_SCREEN, string); } +#endif NCURSES_EXPORT(int) -tputs(const char *string, int affcnt, int (*outc) (int)) +NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx + const char *string, + int affcnt, + NCURSES_SP_OUTC outc) { bool always_delay; bool normal_delay; @@ -162,7 +183,7 @@ tputs(const char *string, int affcnt, int (*outc) (int)) char addrbuf[32]; if (USE_TRACEF(TRACE_TPUTS)) { - if (outc == _nc_outch) + if (outc == NCURSES_SP_NAME(_nc_outch)) (void) strcpy(addrbuf, "_nc_outch"); else (void) sprintf(addrbuf, "%p", outc); @@ -189,7 +210,7 @@ tputs(const char *string, int affcnt, int (*outc) (int)) !xon_xoff && padding_baud_rate #if NCURSES_NO_PADDING - && !GetNoPadding(SP) + && !GetNoPadding(SP_PARM) #endif && (_nc_baudrate(ospeed) >= padding_baud_rate); } @@ -226,21 +247,21 @@ tputs(const char *string, int affcnt, int (*outc) (int)) my_outch = outc; /* redirect delay_output() */ while (*string) { if (*string != '$') - (*outc) (*string); + (*outc) (NCURSES_SP_ARGx *string); else { string++; if (*string != '<') { - (*outc) ('$'); + (*outc) (NCURSES_SP_ARGx '$'); if (*string) - (*outc) (*string); + (*outc) (NCURSES_SP_ARGx *string); } else { bool mandatory; string++; if ((!isdigit(UChar(*string)) && *string != '.') || !strchr(string, '>')) { - (*outc) ('$'); - (*outc) ('<'); + (*outc) (NCURSES_SP_ARGx '$'); + (*outc) (NCURSES_SP_ARGx '<'); continue; } @@ -275,7 +296,7 @@ tputs(const char *string, int affcnt, int (*outc) (int)) && (always_delay || normal_delay || mandatory)) - delay_output(number / 10); + NCURSES_SP_NAME(delay_output) (NCURSES_SP_ARGx number / 10); } /* endelse (*string == '<') */ } /* endelse (*string == '$') */ @@ -295,6 +316,25 @@ tputs(const char *string, int affcnt, int (*outc) (int)) delay_output(trailpad / 10); #endif /* BSD_TPUTS */ - my_outch = _nc_outch; + my_outch = NCURSES_SP_NAME(_nc_outch); return OK; } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_outc_wrapper(SCREEN *sp, int c) +{ + if (0 == sp) { + return (ERR); + } else { + return sp->jump(c); + } +} + +NCURSES_EXPORT(int) +tputs(const char *string, int affcnt, int (*outc) (int)) +{ + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx string, affcnt, _nc_outc_wrapper); +} +#endif diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c index 15961368..8115662e 100644 --- a/ncurses/tinfo/lib_ttyflags.c +++ b/ncurses/tinfo/lib_ttyflags.c @@ -38,10 +38,14 @@ #include #include /* cur_term */ -MODULE_ID("$Id: lib_ttyflags.c,v 1.19 2009/02/15 00:33:49 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_ttyflags.c,v 1.24 2009/05/10 00:48:29 tom Exp $") NCURSES_EXPORT(int) -_nc_get_tty_mode(TTY * buf) +NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; @@ -71,8 +75,16 @@ _nc_get_tty_mode(TTY * buf) return (result); } +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -_nc_set_tty_mode(TTY * buf) +_nc_get_tty_mode(TTY * buf) +{ + return NCURSES_SP_NAME(_nc_get_tty_mode) (CURRENT_SCREEN, buf); +} +#endif + +NCURSES_EXPORT(int) +NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; @@ -86,8 +98,8 @@ _nc_set_tty_mode(TTY * buf) if (SET_TTY(cur_term->Filedes, buf) != 0) { if (errno == EINTR) continue; - if ((errno == ENOTTY) && (SP != 0)) - SP->_notty = TRUE; + if ((errno == ENOTTY) && (SP_PARM != 0)) + SP_PARM->_notty = TRUE; result = ERR; } break; @@ -100,6 +112,14 @@ _nc_set_tty_mode(TTY * buf) return (result); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +_nc_set_tty_mode(TTY * buf) +{ + return NCURSES_SP_NAME(_nc_set_tty_mode) (CURRENT_SCREEN, buf); +} +#endif + NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0) { @@ -174,7 +194,7 @@ NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0) if (SP_PARM) { if (SP_PARM->_keypad_on) _nc_keypad(SP_PARM, TRUE); - NC_BUFFERED(TRUE); + NC_BUFFERED(SP_PARM, TRUE); } returnCode(OK); } @@ -199,7 +219,7 @@ NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0) if (SP_PARM) { _nc_keypad(SP_PARM, FALSE); _nc_flush(); - NC_BUFFERED(FALSE); + NC_BUFFERED(SP_PARM, FALSE); } returnCode(_nc_set_tty_mode(&cur_term->Ottyb)); } diff --git a/ncurses/tinfo/setbuf.c b/ncurses/tinfo/setbuf.c index ba910e89..5610913d 100644 --- a/ncurses/tinfo/setbuf.c +++ b/ncurses/tinfo/setbuf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2009 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 * @@ -29,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * ****************************************************************************/ /* @@ -40,7 +42,7 @@ #include -MODULE_ID("$Id: setbuf.c,v 1.13 2007/05/12 19:04:02 tom Exp $") +MODULE_ID("$Id: setbuf.c,v 1.14 2009/05/09 23:09:00 tom Exp $") /* * If the output file descriptor is connected to a tty (the typical case) it @@ -98,11 +100,11 @@ MODULE_ID("$Id: setbuf.c,v 1.13 2007/05/12 19:04:02 tom Exp $") * buffer. So we disable this by default (there may yet be a workaround). */ NCURSES_EXPORT(void) -_nc_set_buffer(FILE *ofp, bool buffered) +NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_DCLx FILE *ofp, bool buffered) { /* optional optimization hack -- do before any output to ofp */ #if HAVE_SETVBUF || HAVE_SETBUFFER - if (SP->_buffered != buffered) { + if (SP_PARM->_buffered != buffered) { unsigned buf_len; char *buf_ptr; @@ -115,10 +117,10 @@ _nc_set_buffer(FILE *ofp, bool buffered) #endif if (buffered != 0) { buf_len = min(LINES * (COLS + 6), 2800); - if ((buf_ptr = SP->_setbuf) == 0) { + if ((buf_ptr = SP_PARM->_setbuf) == 0) { if ((buf_ptr = typeMalloc(char, buf_len)) == NULL) return; - SP->_setbuf = buf_ptr; + SP_PARM->_setbuf = buf_ptr; /* Don't try to free this! */ } #if !USE_SETBUF_0 @@ -144,7 +146,15 @@ _nc_set_buffer(FILE *ofp, bool buffered) (void) setbuffer(ofp, buf_ptr, (int) buf_len); #endif - SP->_buffered = buffered; + SP_PARM->_buffered = buffered; } #endif /* HAVE_SETVBUF || HAVE_SETBUFFER */ } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_set_buffer(FILE *ofp, bool buffered) +{ + return NCURSES_SP_NAME(_nc_set_buffer) (CURRENT_SCREEN, ofp, buffered); +} +#endif diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c index 368ecd79..66d35f40 100644 --- a/ncurses/trace/lib_traceatr.c +++ b/ncurses/trace/lib_traceatr.c @@ -39,7 +39,11 @@ #include -MODULE_ID("$Id: lib_traceatr.c,v 1.65 2009/04/18 18:06:31 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_traceatr.c,v 1.66 2009/05/10 00:48:29 tom Exp $") #define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name)) diff --git a/ncurses/tty/hashmap.c b/ncurses/tty/hashmap.c index 05c37919..926c538f 100644 --- a/ncurses/tty/hashmap.c +++ b/ncurses/tty/hashmap.c @@ -69,7 +69,11 @@ AUTHOR #include -MODULE_ID("$Id: hashmap.c,v 1.57 2009/04/18 19:03:50 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: hashmap.c,v 1.59 2009/05/10 00:51:57 tom Exp $") #ifdef HASHDEBUG diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c index 2d724070..c4f48238 100644 --- a/ncurses/tty/lib_mvcur.c +++ b/ncurses/tty/lib_mvcur.c @@ -153,10 +153,13 @@ */ #include -#include #include -MODULE_ID("$Id: lib_mvcur.c,v 1.118 2009/05/02 20:38:58 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_mvcur.c,v 1.120 2009/05/10 00:52:29 tom Exp $") #define WANT_CHAR(sp, y, x) (sp)->_newscr->_line[y].text[x] /* desired state */ #define BAUDRATE(sp) cur_term->_baudrate /* bits per second */ @@ -254,7 +257,7 @@ static int normalized_cost(NCURSES_SP_DCLx const char *const cap, int affcnt) /* compute the effective character-count for an operation (round up) */ { - int cost = _nc_msec_cost(cap, affcnt); + int cost = NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_ARGx cap, affcnt); if (cost != INFINITY) cost = (cost + SP_PARM->_char_padding - 1) / SP_PARM->_char_padding; return cost; @@ -440,7 +443,7 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0) * SCREEN's _endwin to TRUE at window initialization time and let this be * called by doupdate's return-from-shellout code. */ - _nc_mvcur_resume(); + NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG); } #if NCURSES_SP_FUNCS @@ -920,7 +923,8 @@ onscreen_mvcur(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew, bool ovw) if (usecost != INFINITY) { TPUTS_TRACE("mvcur"); - tputs(buffer, 1, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + buffer, 1, NCURSES_SP_NAME(_nc_outch)); SP_PARM->_cursrow = ynew; SP_PARM->_curscol = xnew; return (OK); diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c index 4e7c53c1..4a0ef503 100644 --- a/ncurses/tty/lib_tstp.c +++ b/ncurses/tty/lib_tstp.c @@ -46,7 +46,7 @@ #define _POSIX_SOURCE #endif -MODULE_ID("$Id: lib_tstp.c,v 1.38 2009/04/18 19:36:11 tom Exp $") +MODULE_ID("$Id: lib_tstp.c,v 1.39 2009/05/09 15:46:20 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -269,7 +269,7 @@ cleanup(int sig) if (scan->_ofp != 0 && isatty(fileno(scan->_ofp))) { scan->_cleanup = TRUE; - scan->_outch = _nc_outch; + scan->_outch = NCURSES_SP_NAME(_nc_outch); } set_term(scan); NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG); diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c index 83b6dbdf..cf0ca437 100644 --- a/ncurses/tty/lib_vidattr.c +++ b/ncurses/tty/lib_vidattr.c @@ -66,9 +66,15 @@ #include #include -MODULE_ID("$Id: lib_vidattr.c,v 1.53 2009/05/02 22:35:03 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_vidattr.c,v 1.56 2009/05/10 00:48:29 tom Exp $") -#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc) +#define doPut(mode) \ + TPUTS_TRACE(#mode); \ + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx mode, 1, outc) #define TurnOn(mask,mode) \ if ((turn_on & mask) && mode) { doPut(mode); } @@ -84,7 +90,8 @@ MODULE_ID("$Id: lib_vidattr.c,v 1.53 2009/05/02 22:35:03 tom Exp $") if ((pair != old_pair) \ || (fix_pair0 && (pair == 0)) \ || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ - _nc_do_color(old_pair, pair, reverse, outc); \ + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \ + old_pair, pair, reverse, outc); \ } \ } @@ -93,7 +100,7 @@ MODULE_ID("$Id: lib_vidattr.c,v 1.53 2009/05/02 22:35:03 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx chtype newmode, - int (*outc) (int)) + NCURSES_SP_OUTC outc) { attr_t turn_on, turn_off; int pair; @@ -225,16 +232,18 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx } else if (set_attributes) { if (turn_on || turn_off) { TPUTS_TRACE("set_attributes"); - tputs(tparm(set_attributes, - (newmode & A_STANDOUT) != 0, - (newmode & A_UNDERLINE) != 0, - (newmode & A_REVERSE) != 0, - (newmode & A_BLINK) != 0, - (newmode & A_DIM) != 0, - (newmode & A_BOLD) != 0, - (newmode & A_INVIS) != 0, - (newmode & A_PROTECT) != 0, - (newmode & A_ALTCHARSET) != 0), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + tparm(set_attributes, + (newmode & A_STANDOUT) != 0, + (newmode & A_UNDERLINE) != 0, + (newmode & A_REVERSE) != 0, + (newmode & A_BLINK) != 0, + (newmode & A_DIM) != 0, + (newmode & A_BOLD) != 0, + (newmode & A_INVIS) != 0, + (newmode & A_PROTECT) != 0, + (newmode & A_ALTCHARSET) != 0), + 1, outc); PreviousAttr &= ALL_BUT_COLOR; } SetColorsIf((pair != 0) || fix_pair0, PreviousAttr); @@ -297,14 +306,17 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (NCURSES_SP_DCLx chtype newmode) { - return NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, _nc_outch); + return NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx + newmode, + NCURSES_SP_NAME(_nc_outch)); } #if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -vidputs(chtype newmode, int (*outc) (int)) +vidputs(chtype newmode, NCURSES_OUTC outc) { - return NCURSES_SP_NAME(vidputs) (CURRENT_SCREEN, newmode, outc); + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(vidputs) (CURRENT_SCREEN, newmode, _nc_outc_wrapper); } NCURSES_EXPORT(int) diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index cabca530..7e99b358 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -45,6 +45,10 @@ #include +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + #if defined __HAIKU__ && defined __BEOS__ #undef __BEOS__ #endif @@ -78,7 +82,7 @@ #include -MODULE_ID("$Id: tty_update.c,v 1.252 2009/05/02 20:52:11 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.255 2009/05/10 00:53:14 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -103,7 +107,7 @@ static NCURSES_CH_T normal = NewChar(BLANK_TEXT); */ /* #define POSITION_DEBUG */ -static NCURSES_INLINE NCURSES_CH_T ClrBlank(WINDOW *win); +static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win); #if NCURSES_SP_FUNCS static int ClrBottom(SCREEN *, int total); @@ -129,7 +133,7 @@ static void TransformLine(int const lineno); ****************************************************************************/ static void -position_check(SCREEN *sp, int expected_y, int expected_x, char *legend) +position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend) /* check to see if the real cursor position matches the virtual */ { char buf[20]; @@ -141,7 +145,7 @@ position_check(SCREEN *sp, int expected_y, int expected_x, char *legend) NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); memset(buf, '\0', sizeof(buf)); - putp("\033[6n"); /* only works on ANSI-compatibles */ + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx "\033[6n"); /* only works on ANSI-compatibles */ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); *(s = buf) = 0; do { @@ -162,8 +166,12 @@ position_check(SCREEN *sp, int expected_y, int expected_x, char *legend) if (expected_y < 0) expected_y = y - 1; if (y - 1 != expected_y || x - 1 != expected_x) { - beep(); - tputs(tparm("\033[%d;%dH", expected_y + 1, expected_x + 1), 1, _nc_outch); + NCURSES_SP_NAME(beep) (NCURSES_SP_ARG); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + tparm("\033[%d;%dH", + expected_y + 1, + expected_x + 1), + 1, NCURSES_SP_NAME(_nc_outch)); _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s", y - 1, x - 1, expected_y, expected_x, legend); } else { @@ -298,7 +306,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) * make it work for wide characters. */ if (SP_PARM->_outch != 0) { - SP_PARM->_outch(UChar(ch)); + SP_PARM->_outch(NCURSES_SP_ARGx UChar(ch)); } else #endif { @@ -308,7 +316,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) SP_PARM->_curscol += chlen; if (char_padding) { TPUTS_TRACE("char_padding"); - putp(char_padding); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx char_padding); } } @@ -380,7 +388,7 @@ PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch) } else if (enter_am_mode && exit_am_mode) { /* we can suppress automargin */ TPUTS_TRACE("exit_am_mode"); - putp(exit_am_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_am_mode); PutAttrChar(NCURSES_SP_ARGx ch); SP_PARM->_curscol--; @@ -390,7 +398,7 @@ PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch) "exit_am_mode"); TPUTS_TRACE("enter_am_mode"); - putp(enter_am_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx enter_am_mode); } else if ((enter_insert_mode && exit_insert_mode) || insert_character || parm_ich) { GoTo(NCURSES_SP_ARGx @@ -401,7 +409,7 @@ PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch) screen_lines(SP_PARM) - 1, screen_columns(SP_PARM) - 2); InsStr(NCURSES_SP_ARGx - newscr->_line[screen_lines(SP_PARM) - 1].text + + NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text + screen_columns(SP_PARM) - 2, 1); } } @@ -550,7 +558,7 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num) && runcount > SP_PARM->_ech_cost + SP_PARM->_cup_ch_cost && can_clear_with(NCURSES_SP_ARGx CHREF(ntext0))) { UpdateAttrs(SP_PARM, ntext0); - putp(TPARM_1(erase_chars, runcount)); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx TPARM_1(erase_chars, runcount)); /* * If this is the last part of the given interval, @@ -573,8 +581,12 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T * ntext, int num) rep_count--; UpdateAttrs(SP_PARM, ntext0); - tputs(TPARM_2(repeat_char, CharOf(ntext0), rep_count), - rep_count, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(repeat_char, + CharOf(ntext0), + rep_count), + rep_count, + NCURSES_SP_NAME(_nc_outch)); SP_PARM->_curscol += rep_count; if (wrap_possible) @@ -656,17 +668,17 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) T((T_CALLED("doupdate()"))); - if (curscr == 0 - || newscr == 0) + if (CurScreen(SP_PARM) == 0 + || NewScreen(SP_PARM) == 0) returnCode(ERR); #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { - if (curscr->_clear) + if (CurScreen(SP_PARM)->_clear) _tracef("curscr is clear"); else - _tracedump("curscr", curscr); - _tracedump("newscr", newscr); + _tracedump("curscr", CurScreen(SP_PARM)); + _tracedump("newscr", NewScreen(SP_PARM)); _nc_unlock_global(tracef); } #endif /* TRACE */ @@ -726,7 +738,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) for (i = 0; i < screen_lines(SP_PARM); i++) { for (j = 0; j < screen_columns(SP_PARM); j++) { bool failed = FALSE; - NCURSES_CH_T *thisline = newscr->_line[i].text; + NCURSES_CH_T *thisline = NewScreen(SP_PARM)->_line[i].text; attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers; attr_t turnon = thisattr & ~rattr; @@ -775,7 +787,9 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) /* find end of span, if it's onscreen */ for (m = i; m < screen_lines(SP_PARM); m++) { for (; n < screen_columns(SP_PARM); n++) { - attr_t testattr = AttrOf(newscr->_line[m].text[n]); + attr_t testattr + = AttrOf(NewScreen(SP_PARM)->_line[m].text[n]); + if ((testattr & SP_PARM->_xmc_triggers) == rattr) { end_onscreen = TRUE; TR(TRACE_ATTRS, @@ -792,7 +806,8 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) foundit:; if (end_onscreen) { - NCURSES_CH_T *lastline = newscr->_line[m].text; + NCURSES_CH_T *lastline = + NewScreen(SP_PARM)->_line[m].text; /* * If there are safely-attributed blanks at the end of @@ -836,10 +851,11 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) /* turn off new attributes over span */ for (p = i; p < screen_lines(SP_PARM); p++) { for (; q < screen_columns(SP_PARM); q++) { - attr_t testattr = AttrOf(newscr->_line[p].text[q]); + attr_t testattr = + AttrOf(NewScreen(SP_PARM)->_line[p].text[q]); if ((testattr & SP_PARM->_xmc_triggers) == rattr) goto foundend; - RemAttr(newscr->_line[p].text[q], turnon); + RemAttr(NewScreen(SP_PARM)->_line[p].text[q], turnon); } q = 0; } @@ -865,7 +881,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) /* show altered highlights after magic-cookie check */ if (USE_TRACEF(TRACE_UPDATE)) { _tracef("After magic-cookie check..."); - _tracedump("newscr", newscr); + _tracedump("newscr", NewScreen(SP_PARM)); _nc_unlock_global(tracef); } #endif /* TRACE */ @@ -873,17 +889,17 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) #endif /* USE_XMC_SUPPORT */ nonempty = 0; - if (curscr->_clear || newscr->_clear) { /* force refresh ? */ + if (CurScreen(SP_PARM)->_clear || NewScreen(SP_PARM)->_clear) { /* force refresh ? */ ClrUpdate(NCURSES_SP_ARG); - curscr->_clear = FALSE; /* reset flag */ - newscr->_clear = FALSE; /* reset flag */ + CurScreen(SP_PARM)->_clear = FALSE; /* reset flag */ + NewScreen(SP_PARM)->_clear = FALSE; /* reset flag */ } else { int changedlines = CHECK_INTERVAL; if (check_pending(NCURSES_SP_ARG)) goto cleanup; - nonempty = min(screen_lines(SP_PARM), newscr->_maxy + 1); + nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1); if (SP_PARM->_scrolling) { _nc_scroll_optimize(); @@ -903,40 +919,40 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) } /* - * newscr->line[i].firstchar is normally set - * by wnoutrefresh. curscr->line[i].firstchar + * newscr.line[i].firstchar is normally set + * by wnoutrefresh. curscr.line[i].firstchar * is normally set by _nc_scroll_window in the * vertical-movement optimization code, */ - if (newscr->_line[i].firstchar != _NOCHANGE - || curscr->_line[i].firstchar != _NOCHANGE) { + if (NewScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE + || CurScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE) { TransformLine(NCURSES_SP_ARGx i); changedlines++; } /* mark line changed successfully */ - if (i <= newscr->_maxy) { - MARK_NOCHANGE(newscr, i); + if (i <= NewScreen(SP_PARM)->_maxy) { + MARK_NOCHANGE(NewScreen(SP_PARM), i); } - if (i <= curscr->_maxy) { - MARK_NOCHANGE(curscr, i); + if (i <= CurScreen(SP_PARM)->_maxy) { + MARK_NOCHANGE(CurScreen(SP_PARM), i); } } } /* put everything back in sync */ - for (i = nonempty; i <= newscr->_maxy; i++) { - MARK_NOCHANGE(newscr, i); + for (i = nonempty; i <= NewScreen(SP_PARM)->_maxy; i++) { + MARK_NOCHANGE(NewScreen(SP_PARM), i); } - for (i = nonempty; i <= curscr->_maxy; i++) { - MARK_NOCHANGE(curscr, i); + for (i = nonempty; i <= CurScreen(SP_PARM)->_maxy; i++) { + MARK_NOCHANGE(CurScreen(SP_PARM), i); } - if (!newscr->_leaveok) { - curscr->_curx = newscr->_curx; - curscr->_cury = newscr->_cury; + if (!NewScreen(SP_PARM)->_leaveok) { + CurScreen(SP_PARM)->_curx = NewScreen(SP_PARM)->_curx; + CurScreen(SP_PARM)->_cury = NewScreen(SP_PARM)->_cury; - GoTo(NCURSES_SP_ARGx curscr->_cury, curscr->_curx); + GoTo(NCURSES_SP_ARGx CurScreen(SP_PARM)->_cury, CurScreen(SP_PARM)->_curx); } cleanup: @@ -952,7 +968,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) UpdateAttrs(SP_PARM, normal); NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); - WINDOW_ATTRS(curscr) = WINDOW_ATTRS(newscr); + WINDOW_ATTRS(CurScreen(SP_PARM)) = WINDOW_ATTRS(NewScreen(SP_PARM)); #if USE_TRACE_TIMES (void) times(&after); @@ -987,10 +1003,10 @@ doupdate(void) * in the wbkgd() call. Assume 'stdscr' for this case. */ #define BCE_ATTRS (A_NORMAL|A_COLOR) -#define BCE_BKGD(win) (((win) == curscr ? stdscr : (win))->_nc_bkgd) +#define BCE_BKGD(win) (((win) == CurScreen(SP_PARM) ? StdScreen(SP_PARM) : (win))->_nc_bkgd) static NCURSES_INLINE NCURSES_CH_T -ClrBlank(WINDOW *win) +ClrBlank(NCURSES_SP_DCLx WINDOW *win) { NCURSES_CH_T blank = blankchar; if (back_color_erase) @@ -1011,8 +1027,9 @@ ClrUpdate(NCURSES_SP_DCL0) TR(TRACE_UPDATE, (T_CALLED("ClrUpdate"))); if (0 != SP_PARM) { int i; - NCURSES_CH_T blank = ClrBlank(stdscr); - int nonempty = min(screen_lines(SP_PARM), newscr->_maxy + 1); + NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); + int nonempty = min(screen_lines(SP_PARM), + NewScreen(SP_PARM)->_maxy + 1); ClearScreen(NCURSES_SP_ARGx blank); @@ -1037,11 +1054,12 @@ ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear) { int j; - if (curscr != 0 + if (CurScreen(SP_PARM) != 0 && SP_PARM->_cursrow >= 0) { for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) { if (j >= 0) { - NCURSES_CH_T *cp = &(curscr->_line[SP_PARM->_cursrow].text[j]); + NCURSES_CH_T *cp = + &(CurScreen(SP_PARM)->_line[SP_PARM->_cursrow].text[j]); if (!CharEq(*cp, blank)) { *cp = blank; @@ -1057,7 +1075,7 @@ ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear) UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eol"); if (clr_eol && SP_PARM->_el_cost <= (screen_columns(SP_PARM) - SP_PARM->_curscol)) { - putp(clr_eol); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_eol); } else { int count = (screen_columns(SP_PARM) - SP_PARM->_curscol); while (count-- > 0) @@ -1085,14 +1103,17 @@ ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank) UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eos"); - tputs(clr_eos, screen_lines(SP_PARM) - row, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + clr_eos, + screen_lines(SP_PARM) - row, + NCURSES_SP_NAME(_nc_outch)); while (col < screen_columns(SP_PARM)) - curscr->_line[row].text[col++] = blank; + CurScreen(SP_PARM)->_line[row].text[col++] = blank; for (row++; row < screen_lines(SP_PARM); row++) { for (col = 0; col < screen_columns(SP_PARM); col++) - curscr->_line[row].text[col] = blank; + CurScreen(SP_PARM)->_line[row].text[col] = blank; } } @@ -1109,21 +1130,21 @@ ClrBottom(NCURSES_SP_DCLx int total) int row; int col; int top = total; - int last = min(screen_columns(SP_PARM), newscr->_maxx + 1); - NCURSES_CH_T blank = newscr->_line[total - 1].text[last - 1]; + int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1); + NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1]; bool ok; if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) { for (row = total - 1; row >= 0; row--) { for (col = 0, ok = TRUE; ok && col < last; col++) { - ok = (CharEq(newscr->_line[row].text[col], blank)); + ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank)); } if (!ok) break; for (col = 0; ok && col < last; col++) { - ok = (CharEq(curscr->_line[row].text[col], blank)); + ok = (CharEq(CurScreen(SP_PARM)->_line[row].text[col], blank)); } if (!ok) top = row; @@ -1151,7 +1172,7 @@ ClrBottom(NCURSES_SP_DCLx int total) #define xmc_turn_on(sp,a,b) ((((a)^(b)) & ~(a) & (sp)->_xmc_triggers) != 0) #endif -#define xmc_new(sp,r,c) newscr->_line[r].text[c] +#define xmc_new(sp,r,c) NewScreen(SP_PARM)->_line[r].text[c] #define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a) #endif /* USE_XMC_SUPPORT */ @@ -1177,8 +1198,8 @@ static void TransformLine(NCURSES_SP_DCLx int const lineno) { int firstChar, oLastChar, nLastChar; - NCURSES_CH_T *newLine = newscr->_line[lineno].text; - NCURSES_CH_T *oldLine = curscr->_line[lineno].text; + NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text; + NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text; int n; bool attrchanged = FALSE; @@ -1230,7 +1251,9 @@ TransformLine(NCURSES_SP_DCLx int const lineno) if (attrchanged) { /* we may have to disregard the whole line */ GoTo(NCURSES_SP_ARGx lineno, firstChar); - ClrToEOL(NCURSES_SP_ARGx ClrBlank(curscr), FALSE); + ClrToEOL(NCURSES_SP_ARGx + ClrBlank(NCURSES_SP_ARGx CurScreen(SP_PARM)), + FALSE); PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno, 0, screen_columns(SP_PARM) - 1); @@ -1322,12 +1345,12 @@ TransformLine(NCURSES_SP_DCLx int const lineno) GoTo(NCURSES_SP_ARGx lineno, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eol"); - putp(clr_eol); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_eol); } else { GoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_bol"); - putp(clr_bol); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_bol); } while (firstChar < nFirstChar) @@ -1510,7 +1533,11 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) #if NCURSES_EXT_FUNCS if (SP_PARM->_coloron && !SP_PARM->_default_color) { - _nc_do_color(GET_SCREEN_PAIR(SP_PARM), 0, FALSE, _nc_outch); + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx + GET_SCREEN_PAIR(SP_PARM), + 0, + FALSE, + NCURSES_SP_NAME(_nc_outch)); if (!back_color_erase) { fast_clear = FALSE; } @@ -1521,7 +1548,7 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) if (clear_screen) { UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clear_screen"); - putp(clear_screen); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clear_screen); SP_PARM->_cursrow = SP_PARM->_curscol = 0; position_check(SP_PARM, SP_PARM->_cursrow, @@ -1533,7 +1560,10 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eos"); - tputs(clr_eos, screen_lines(SP_PARM), _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + clr_eos, + screen_lines(SP_PARM), + NCURSES_SP_NAME(_nc_outch)); } else if (clr_eol) { SP_PARM->_cursrow = SP_PARM->_curscol = -1; @@ -1541,7 +1571,7 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) for (i = 0; i < screen_lines(SP_PARM); i++) { GoTo(NCURSES_SP_ARGx i, 0); TPUTS_TRACE("clr_eol"); - putp(clr_eol); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_eol); } GoTo(NCURSES_SP_ARGx 0, 0); } @@ -1557,7 +1587,7 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) for (i = 0; i < screen_lines(SP_PARM); i++) { for (j = 0; j < screen_columns(SP_PARM); j++) - curscr->_line[i].text[j] = blank; + CurScreen(SP_PARM)->_line[i].text[j] = blank; } TR(TRACE_UPDATE, ("screen cleared")); @@ -1580,7 +1610,10 @@ InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count) /* The order must match that of InsCharCost. */ if (parm_ich) { TPUTS_TRACE("parm_ich"); - tputs(TPARM_1(parm_ich, count), count, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(parm_ich, count), + count, + NCURSES_SP_NAME(_nc_outch)); while (count) { PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); line++; @@ -1588,26 +1621,26 @@ InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count) } } else if (enter_insert_mode && exit_insert_mode) { TPUTS_TRACE("enter_insert_mode"); - putp(enter_insert_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx enter_insert_mode); while (count) { PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); if (insert_padding) { TPUTS_TRACE("insert_padding"); - putp(insert_padding); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_padding); } line++; count--; } TPUTS_TRACE("exit_insert_mode"); - putp(exit_insert_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_insert_mode); } else { while (count) { TPUTS_TRACE("insert_character"); - putp(insert_character); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_character); PutAttrChar(NCURSES_SP_ARGx CHREF(*line)); if (insert_padding) { TPUTS_TRACE("insert_padding"); - putp(insert_padding); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_padding); } line++; count--; @@ -1630,16 +1663,19 @@ DelChar(NCURSES_SP_DCLx int count) TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)", SP_PARM, count, - (long) newscr->_cury, - (long) newscr->_curx)); + (long) NewScreen(SP_PARM)->_cury, + (long) NewScreen(SP_PARM)->_curx)); if (parm_dch) { TPUTS_TRACE("parm_dch"); - tputs(TPARM_1(parm_dch, count), count, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_1(parm_dch, count), + count, + NCURSES_SP_NAME(_nc_outch)); } else { for (n = 0; n < count; n++) { TPUTS_TRACE("delete_character"); - putp(delete_character); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_character); } } } @@ -1692,35 +1728,41 @@ scroll_csr_forward(NCURSES_SP_DCLx GoTo(NCURSES_SP_ARGx bot, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("scroll_forward"); - putp(scroll_forward); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_forward); } else if (n == 1 && delete_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("delete_line"); - putp(delete_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line); } else if (parm_index && top == miny && bot == maxy) { GoTo(NCURSES_SP_ARGx bot, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("parm_index"); - tputs(TPARM_2(parm_index, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_index, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else if (parm_delete_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("parm_delete_line"); - tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_delete_line, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else if (scroll_forward && top == miny && bot == maxy) { GoTo(NCURSES_SP_ARGx bot, 0); UpdateAttrs(SP_PARM, blank); for (i = 0; i < n; i++) { TPUTS_TRACE("scroll_forward"); - putp(scroll_forward); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_forward); } } else if (delete_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); for (i = 0; i < n; i++) { TPUTS_TRACE("delete_line"); - putp(delete_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line); } } else return ERR; @@ -1755,35 +1797,41 @@ scroll_csr_backward(NCURSES_SP_DCLx GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("scroll_reverse"); - putp(scroll_reverse); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_reverse); } else if (n == 1 && insert_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("insert_line"); - putp(insert_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line); } else if (parm_rindex && top == miny && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("parm_rindex"); - tputs(TPARM_2(parm_rindex, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_rindex, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else if (parm_insert_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("parm_insert_line"); - tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_insert_line, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else if (scroll_reverse && top == miny && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); for (i = 0; i < n; i++) { TPUTS_TRACE("scroll_reverse"); - putp(scroll_reverse); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_reverse); } } else if (insert_line && bot == maxy) { GoTo(NCURSES_SP_ARGx top, 0); UpdateAttrs(SP_PARM, blank); for (i = 0; i < n; i++) { TPUTS_TRACE("insert_line"); - putp(insert_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line); } } else return ERR; @@ -1815,14 +1863,17 @@ scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank) UpdateAttrs(SP_PARM, blank); if (n == 1 && delete_line) { TPUTS_TRACE("delete_line"); - putp(delete_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line); } else if (parm_delete_line) { TPUTS_TRACE("parm_delete_line"); - tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_delete_line, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else { /* if (delete_line) */ for (i = 0; i < n; i++) { TPUTS_TRACE("delete_line"); - putp(delete_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line); } } @@ -1830,14 +1881,17 @@ scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank) UpdateAttrs(SP_PARM, blank); if (n == 1 && insert_line) { TPUTS_TRACE("insert_line"); - putp(insert_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line); } else if (parm_insert_line) { TPUTS_TRACE("parm_insert_line"); - tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_2(parm_insert_line, n, 0), + n, + NCURSES_SP_NAME(_nc_outch)); } else { /* if (insert_line) */ for (i = 0; i < n; i++) { TPUTS_TRACE("insert_line"); - putp(insert_line); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line); } } @@ -1860,7 +1914,7 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx int maxy) /* scroll region from top to bot by n lines */ { - NCURSES_CH_T blank = ClrBlank(stdscr); + NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); int i; bool cursor_saved = FALSE; int res; @@ -1889,13 +1943,14 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx && save_cursor && restore_cursor) { cursor_saved = TRUE; TPUTS_TRACE("save_cursor"); - putp(save_cursor); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx save_cursor); } TPUTS_TRACE("change_scroll_region"); - putp(TPARM_2(change_scroll_region, top, bot)); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx + TPARM_2(change_scroll_region, top, bot)); if (cursor_saved) { TPUTS_TRACE("restore_cursor"); - putp(restore_cursor); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx restore_cursor); } else { SP_PARM->_cursrow = SP_PARM->_curscol = -1; } @@ -1903,7 +1958,8 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank); TPUTS_TRACE("change_scroll_region"); - putp(TPARM_2(change_scroll_region, 0, maxy)); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx + TPARM_2(change_scroll_region, 0, maxy)); SP_PARM->_cursrow = SP_PARM->_curscol = -1; } @@ -1937,13 +1993,14 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx && save_cursor && restore_cursor) { cursor_saved = TRUE; TPUTS_TRACE("save_cursor"); - putp(save_cursor); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx save_cursor); } TPUTS_TRACE("change_scroll_region"); - putp(TPARM_2(change_scroll_region, top, bot)); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx + TPARM_2(change_scroll_region, top, bot)); if (cursor_saved) { TPUTS_TRACE("restore_cursor"); - putp(restore_cursor); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx restore_cursor); } else { SP_PARM->_cursrow = SP_PARM->_curscol = -1; } @@ -1952,7 +2009,8 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx -n, top, bot, top, bot, blank); TPUTS_TRACE("change_scroll_region"); - putp(TPARM_2(change_scroll_region, 0, maxy)); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx + TPARM_2(change_scroll_region, 0, maxy)); SP_PARM->_cursrow = SP_PARM->_curscol = -1; } @@ -1975,7 +2033,7 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx if (res == ERR) return (ERR); - _nc_scroll_window(curscr, n, top, bot, blank); + _nc_scroll_window(CurScreen(SP_PARM), n, top, bot, blank); /* shift hash values too - they can be reused */ NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot); @@ -1998,7 +2056,7 @@ NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0) /* make sure terminal is in a sane known state */ SetAttr(SCREEN_ATTRS(SP_PARM), A_NORMAL); - newscr->_clear = TRUE; + NewScreen(SP_PARM)->_clear = TRUE; /* reset color pairs and definitions */ if (SP_PARM->_coloron || SP_PARM->_color_defs) @@ -2019,20 +2077,23 @@ NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0) } if (exit_attribute_mode) - putp(exit_attribute_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_attribute_mode); else { /* turn off attributes */ if (exit_alt_charset_mode) - putp(exit_alt_charset_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_alt_charset_mode); if (exit_standout_mode) - putp(exit_standout_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_standout_mode); if (exit_underline_mode) - putp(exit_underline_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_underline_mode); } if (exit_insert_mode) - putp(exit_insert_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_insert_mode); if (enter_am_mode && exit_am_mode) - putp(auto_right_margin ? enter_am_mode : exit_am_mode); + NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx + (auto_right_margin + ? enter_am_mode + : exit_am_mode)); } #if NCURSES_SP_FUNCS @@ -2070,7 +2131,10 @@ NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) && !SP_PARM->_default_color) { static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); SP_PARM->_default_color = TRUE; - _nc_do_color(-1, 0, FALSE, _nc_outch); + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx + -1, 0, + FALSE, + NCURSES_SP_NAME(_nc_outch)); SP_PARM->_default_color = FALSE; mvcur(SP_PARM->_cursrow, diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c index 0b5648b0..46bde8ad 100644 --- a/ncurses/widechar/lib_vid_attr.c +++ b/ncurses/widechar/lib_vid_attr.c @@ -33,9 +33,13 @@ #include #include -MODULE_ID("$Id: lib_vid_attr.c,v 1.7 2009/05/02 23:30:44 tom Exp $") +#ifndef CUR +#define CUR SP_TERMTYPE +#endif + +MODULE_ID("$Id: lib_vid_attr.c,v 1.11 2009/05/10 00:48:29 tom Exp $") -#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc) +#define doPut(mode) TPUTS_TRACE(#mode); NCURSES_SP_NAME(tputs)(NCURSES_SP_ARGx mode, 1, outc) #define TurnOn(mask,mode) \ if ((turn_on & mask) && mode) { doPut(mode); } @@ -50,18 +54,20 @@ MODULE_ID("$Id: lib_vid_attr.c,v 1.7 2009/05/02 23:30:44 tom Exp $") if ((pair != old_pair) \ || (fix_pair0 && (pair == 0)) \ || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \ - _nc_do_color(old_pair, pair, reverse, outc); \ + NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx \ + old_pair, pair, \ + reverse, outc); \ } \ } #define set_color(mode, pair) mode &= ALL_BUT_COLOR; mode |= COLOR_PAIR(pair) NCURSES_EXPORT(int) -NCURSES_SP_NAME(vid_puts)(NCURSES_SP_DCLx - attr_t newmode, - short pair, - void *opts GCC_UNUSED, - int (*outc) (int)) +NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx + attr_t newmode, + short pair, + void *opts GCC_UNUSED, + NCURSES_SP_OUTC outc) { #if NCURSES_EXT_COLORS static attr_t previous_attr = A_NORMAL; @@ -163,16 +169,18 @@ NCURSES_SP_NAME(vid_puts)(NCURSES_SP_DCLx } else if (set_attributes) { if (turn_on || turn_off) { TPUTS_TRACE("set_attributes"); - tputs(TPARM_9(set_attributes, - (newmode & A_STANDOUT) != 0, - (newmode & A_UNDERLINE) != 0, - (newmode & A_REVERSE) != 0, - (newmode & A_BLINK) != 0, - (newmode & A_DIM) != 0, - (newmode & A_BOLD) != 0, - (newmode & A_INVIS) != 0, - (newmode & A_PROTECT) != 0, - (newmode & A_ALTCHARSET) != 0), 1, outc); + NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx + TPARM_9(set_attributes, + (newmode & A_STANDOUT) != 0, + (newmode & A_UNDERLINE) != 0, + (newmode & A_REVERSE) != 0, + (newmode & A_BLINK) != 0, + (newmode & A_DIM) != 0, + (newmode & A_BOLD) != 0, + (newmode & A_INVIS) != 0, + (newmode & A_PROTECT) != 0, + (newmode & A_ALTCHARSET) != 0), + 1, outc); previous_attr &= ALL_BUT_COLOR; previous_pair = 0; } @@ -237,10 +245,26 @@ NCURSES_SP_NAME(vid_puts)(NCURSES_SP_DCLx #else T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair)); set_color(newmode, pair); - returnCode(vidputs(newmode, outc)); + returnCode(NCURSES_SP_NAME(vidputs) (NCURSES_SP_ARGx newmode, outc)); #endif } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +vid_puts(attr_t newmode, + short pair, + void *opts GCC_UNUSED, + NCURSES_OUTC outc) +{ + SetSafeOutcWrapper(outc); + return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN, + newmode, + pair, + opts, + _nc_outc_wrapper); +} +#endif + #undef vid_attr NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx @@ -249,16 +273,14 @@ NCURSES_SP_NAME(vid_attr) (NCURSES_SP_DCLx void *opts) { T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), pair)); - returnCode(vid_puts(newmode, pair, opts, _nc_outch)); + returnCode(NCURSES_SP_NAME(vid_puts) (NCURSES_SP_ARGx + newmode, + pair, + opts, + NCURSES_SP_NAME(_nc_outch))); } #if NCURSES_SP_FUNCS -NCURSES_EXPORT(int) -vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int)) -{ - return NCURSES_SP_NAME(vid_puts) (CURRENT_SCREEN, newmode, pair, opts, outc); -} - NCURSES_EXPORT(int) vid_attr(attr_t newmode, short pair, void *opts) { @@ -271,12 +293,12 @@ vid_attr(attr_t newmode, short pair, void *opts) * we can use termattrs() for part of the logic. */ NCURSES_EXPORT(attr_t) -term_attrs(void) +NCURSES_SP_NAME(term_attrs) (NCURSES_SP_DCL0) { attr_t attrs; T((T_CALLED("term_attrs()"))); - attrs = termattrs(); + attrs = SP_PARM ? NCURSES_SP_NAME(termattrs) (NCURSES_SP_ARG) : 0; /* these are only supported for wide-character mode */ if (enter_horizontal_hl_mode) @@ -294,3 +316,11 @@ term_attrs(void) returnAttr(attrs); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(attr_t) +term_attrs(void) +{ + return NCURSES_SP_NAME(term_attrs) (CURRENT_SCREEN); +} +#endif -- 2.44.0