From: Thomas E. Dickey Date: Sun, 7 Jun 2009 00:51:13 +0000 (+0000) Subject: ncurses 5.7 - patch 20090606 X-Git-Tag: v5.8~88 X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=d4ede7c5fa6a269d338fea32cd93bf39083dda8c ncurses 5.7 - patch 20090606 + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). --- diff --git a/NEWS b/NEWS index 4da6e362..b84e0a4b 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.1392 2009/05/30 19:19:59 tom Exp $ +-- $Id: NEWS,v 1.1393 2009/06/06 21:41:06 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. +20090606 + + continue integrating "sp-funcs" by Juergen Pfeifer (incomplete). + 20090530 + fix an infinite recursion when adding a legacy-coding 8-bit value using insch() (report by Clemens Ladisch). diff --git a/dist.mk b/dist.mk index 22884a3d..227a8fb8 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.702 2009/05/30 13:36:52 tom Exp $ +# $Id: dist.mk,v 1.703 2009/06/06 15:37:29 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 = 20090530 +NCURSES_PATCH = 20090606 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/ncurses/base/keyok.c b/ncurses/base/keyok.c index 706e5405..ed00ba75 100644 --- a/ncurses/base/keyok.c +++ b/ncurses/base/keyok.c @@ -33,7 +33,7 @@ #include -MODULE_ID("$Id: keyok.c,v 1.8 2009/02/15 00:31:38 tom Exp $") +MODULE_ID("$Id: keyok.c,v 1.9 2009/06/06 19:24:57 tom Exp $") /* * Enable (or disable) ncurses' interpretation of a keycode by adding (or @@ -49,12 +49,17 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag) { int code = ERR; - int count = 0; - char *s; + T((T_CALLED("keyok(%p, %d,%d)"), SP_PARM, c, flag)); +#ifdef USE_TERM_DRIVER + code = CallDriver_2(sp, kyOk, c, flag); +#else T((T_CALLED("keyok(%d,%d)"), c, flag)); if (c >= 0) { + int count = 0; + char *s; unsigned ch = (unsigned) c; + if (flag) { while ((s = _nc_expand_try(SP_PARM->_key_ok, ch, &count, 0)) != 0 && _nc_remove_key(&(SP_PARM->_key_ok), ch)) { @@ -75,6 +80,7 @@ NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag) } } } +#endif returnCode(code); } diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c index 3ad82150..590b8907 100644 --- a/ncurses/base/lib_color.c +++ b/ncurses/base/lib_color.c @@ -44,10 +44,10 @@ #include #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_color.c,v 1.91 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_color.c,v 1.92 2009/06/06 20:26:16 tom Exp $") /* * These should be screen structure members. They need to be globals for @@ -199,18 +199,18 @@ init_color_table(NCURSES_SP_DCL0) tp = (hue_lightness_saturation) ? hls_palette : cga_palette; for (n = 0; n < COLORS; n++) { if (InPalette(n)) { - SP->_color_table[n] = tp[n]; + SP_PARM->_color_table[n] = tp[n]; } else { - SP->_color_table[n] = tp[n % MAX_PALETTE]; + SP_PARM->_color_table[n] = tp[n % MAX_PALETTE]; if (hue_lightness_saturation) { - SP->_color_table[n].green = 100; + SP_PARM->_color_table[n].green = 100; } else { - if (SP->_color_table[n].red) - SP->_color_table[n].red = 1000; - if (SP->_color_table[n].green) - SP->_color_table[n].green = 1000; - if (SP->_color_table[n].blue) - SP->_color_table[n].blue = 1000; + if (SP_PARM->_color_table[n].red) + SP_PARM->_color_table[n].red = 1000; + if (SP_PARM->_color_table[n].green) + SP_PARM->_color_table[n].green = 1000; + if (SP_PARM->_color_table[n].blue) + SP_PARM->_color_table[n].blue = 1000; } } } @@ -238,16 +238,12 @@ reset_color_pair(NCURSES_SP_DCL0) * someone has changed the color definitions. */ bool -_nc_reset_colors(void) -{ -#if NCURSES_SP_FUNCS - SCREEN *sp = CURRENT_SCREEN; -#endif +NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0) { int result = FALSE; T((T_CALLED("_nc_reset_colors()"))); - if (SP->_color_defs > 0) - SP->_color_defs = -(SP->_color_defs); + if (SP_PARM->_color_defs > 0) + SP_PARM->_color_defs = -(SP_PARM->_color_defs); if (reset_color_pair(NCURSES_SP_ARG)) result = TRUE; @@ -259,6 +255,14 @@ _nc_reset_colors(void) returnBool(result); } +#if NCURSES_SP_FUNCS +bool +_nc_reset_colors(void) +{ + return NCURSES_SP_NAME(_nc_reset_colors) (CURRENT_SCREEN); +} +#endif + NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0) { @@ -685,13 +689,13 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx TPARM_1(set_color_pair, pair), 1, outc); return; - } else if (SP != 0) { + } else if (SP_PARM != 0) { pair_content((short) pair, &fg, &bg); } } if (old_pair >= 0 - && SP != 0 + && SP_PARM != 0 && pair_content(old_pair, &old_fg, &old_bg) != ERR) { if ((isDefaultColor(fg) && !isDefaultColor(old_fg)) || (isDefaultColor(bg) && !isDefaultColor(old_bg))) { @@ -701,11 +705,11 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx * the terminal description, treat it as screen's indicator of ECMA * SGR 39 and SGR 49, and assume the two sequences are independent. */ - if (SP->_has_sgr_39_49 + if (SP_PARM->_has_sgr_39_49 && isDefaultColor(old_bg) && !isDefaultColor(old_fg)) { NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[39m", 1, outc); - } else if (SP->_has_sgr_39_49 + } else if (SP_PARM->_has_sgr_39_49 && isDefaultColor(old_fg) && !isDefaultColor(old_bg)) { NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx "\033[49m", 1, outc); diff --git a/ncurses/base/lib_mvwin.c b/ncurses/base/lib_mvwin.c index 090d8fe7..8b2f816b 100644 --- a/ncurses/base/lib_mvwin.c +++ b/ncurses/base/lib_mvwin.c @@ -29,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * ****************************************************************************/ /* @@ -40,11 +42,15 @@ #include -MODULE_ID("$Id: lib_mvwin.c,v 1.15 2009/04/18 18:25:37 tom Exp $") +MODULE_ID("$Id: lib_mvwin.c,v 1.16 2009/06/06 20:25:07 tom Exp $") NCURSES_EXPORT(int) mvwin(WINDOW *win, int by, int bx) { +#if NCURSES_SP_FUNCS + SCREEN *sp = _nc_screen_of(win); +#endif + T((T_CALLED("mvwin(%p,%d,%d)"), win, by, bx)); if (!win || (win->_flags & _ISPAD)) @@ -96,8 +102,8 @@ mvwin(WINDOW *win, int by, int bx) } #endif - if (by + win->_maxy > screen_lines(CURRENT_SCREEN) - 1 - || bx + win->_maxx > screen_columns(CURRENT_SCREEN) - 1 + if (by + win->_maxy > screen_lines(SP_PARM) - 1 + || bx + win->_maxx > screen_columns(SP_PARM) - 1 || by < 0 || bx < 0) returnCode(ERR); diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c index 7d3b02be..26090828 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.57 2009/05/09 23:40:03 tom Exp $") +MODULE_ID("$Id: lib_newwin.c,v 1.58 2009/06/06 17:53:11 tom Exp $") #define window_is(name) ((sp)->_##name == win) @@ -362,18 +362,6 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags) * internally, and it is useful to allow those to be invoked without switching * SCREEN's, e.g., for multi-threaded applications. */ -NCURSES_EXPORT(SCREEN *) -_nc_screen_of(WINDOW *win) -{ - SCREEN *sp = 0; - - if (win != 0) { - WINDOWLIST *wp = (WINDOWLIST *) win; - sp = wp->screen; - } - return (sp); -} - #if NCURSES_SP_FUNCS NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN *sp) diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c index 2a9cafb7..25b9b40a 100644 --- a/ncurses/base/lib_refresh.c +++ b/ncurses/base/lib_refresh.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,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 * @@ -30,6 +30,7 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * ****************************************************************************/ /* @@ -41,24 +42,27 @@ #include -MODULE_ID("$Id: lib_refresh.c,v 1.41 2007/09/29 20:39:34 tom Exp $") +MODULE_ID("$Id: lib_refresh.c,v 1.42 2009/06/06 20:27:39 tom Exp $") NCURSES_EXPORT(int) wrefresh(WINDOW *win) { int code; +#if NCURSES_SP_FUNCS + SCREEN *SP_PARM = _nc_screen_of(win); +#endif T((T_CALLED("wrefresh(%p)"), win)); if (win == 0) { code = ERR; - } else if (win == curscr) { - curscr->_clear = TRUE; - code = doupdate(); + } else if (win == CurScreen(SP_PARM)) { + CurScreen(SP_PARM)->_clear = TRUE; + code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG); } else if ((code = wnoutrefresh(win)) == OK) { if (win->_clear) - newscr->_clear = TRUE; - code = doupdate(); + NewScreen(SP_PARM)->_clear = TRUE; + code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG); /* * Reset the clearok() flag in case it was set for the special * case in hardscroll.c (if we don't reset it here, we'll get 2 @@ -81,6 +85,9 @@ wnoutrefresh(WINDOW *win) #if USE_SCROLL_HINTS bool wide; #endif +#if NCURSES_SP_FUNCS + SCREEN *SP_PARM = _nc_screen_of(win); +#endif T((T_CALLED("wnoutrefresh(%p)"), win)); #ifdef TRACE @@ -101,8 +108,8 @@ wnoutrefresh(WINDOW *win) begx = win->_begx; begy = win->_begy; - newscr->_nc_bkgd = win->_nc_bkgd; - WINDOW_ATTRS(newscr) = WINDOW_ATTRS(win); + NewScreen(SP_PARM)->_nc_bkgd = win->_nc_bkgd; + WINDOW_ATTRS(NewScreen(SP_PARM)) = WINDOW_ATTRS(win); /* merge in change information from all subwindows of this window */ wsyncdown(win); @@ -122,7 +129,7 @@ wnoutrefresh(WINDOW *win) * windows). Note that changing this formula will not break any code, * merely change the costs of various update cases. */ - wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1)); + wide = (begx <= 1 && win->_maxx >= (NewScreen(SP_PARM)->_maxx - 1)); #endif win->_flags &= ~_HASMOVED; @@ -137,13 +144,13 @@ wnoutrefresh(WINDOW *win) /* limit(dst_col) */ limit_x = win->_maxx; /* limit(src_col) */ - if (limit_x > newscr->_maxx - begx) - limit_x = newscr->_maxx - begx; + if (limit_x > NewScreen(SP_PARM)->_maxx - begx) + limit_x = NewScreen(SP_PARM)->_maxx - begx; for (src_row = 0, dst_row = begy + win->_yoffset; - src_row <= win->_maxy && dst_row <= newscr->_maxy; + src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy; src_row++, dst_row++) { - register struct ldat *nline = &newscr->_line[dst_row]; + register struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]); register struct ldat *oline = &win->_line[src_row]; if (oline->firstchar != _NOCHANGE) { @@ -225,7 +232,8 @@ wnoutrefresh(WINDOW *win) * this character. Find the end of the character. */ ++j; - while (j <= newscr->_maxx && isWidecExt(nline->text[j])) { + while (j <= NewScreen(SP_PARM)->_maxx && + isWidecExt(nline->text[j])) { fix_right = j++; } } @@ -269,18 +277,18 @@ wnoutrefresh(WINDOW *win) if (win->_clear) { win->_clear = FALSE; - newscr->_clear = TRUE; + NewScreen(SP_PARM)->_clear = TRUE; } if (!win->_leaveok) { - newscr->_cury = win->_cury + win->_begy + win->_yoffset; - newscr->_curx = win->_curx + win->_begx; + NewScreen(SP_PARM)->_cury = win->_cury + win->_begy + win->_yoffset; + NewScreen(SP_PARM)->_curx = win->_curx + win->_begx; } - newscr->_leaveok = win->_leaveok; + NewScreen(SP_PARM)->_leaveok = win->_leaveok; #ifdef TRACE if (USE_TRACEF(TRACE_UPDATE)) { - _tracedump("newscr", newscr); + _tracedump("newscr", NewScreen(SP_PARM)); _nc_unlock_global(tracef); } #endif /* TRACE */ diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c index aa1592e0..176edc4e 100644 --- a/ncurses/base/lib_screen.c +++ b/ncurses/base/lib_screen.c @@ -36,15 +36,15 @@ #include #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_screen.c,v 1.34 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_screen.c,v 1.35 2009/06/06 20:26:17 tom Exp $") #define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */ NCURSES_EXPORT(WINDOW *) -getwin(FILE *filep) +NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep) { WINDOW tmp, *nwin; int n; @@ -61,9 +61,12 @@ getwin(FILE *filep) returnWin(0); if (tmp._flags & _ISPAD) { - nwin = newpad(tmp._maxy + 1, tmp._maxx + 1); + nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx + tmp._maxy + 1, tmp._maxx + 1); } else { - nwin = newwin(tmp._maxy + 1, tmp._maxx + 1, 0, 0); + nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx + tmp._maxy + 1, + tmp._maxx + 1, 0, 0); } /* @@ -117,6 +120,14 @@ getwin(FILE *filep) returnWin(nwin); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(WINDOW *) +getwin(FILE *filep) +{ + return NCURSES_SP_NAME(getwin) (CURRENT_SCREEN, filep); +} +#endif + NCURSES_EXPORT(int) putwin(WINDOW *win, FILE *filep) { @@ -150,16 +161,16 @@ NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file) { FILE *fp = 0; - T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file))); + T((T_CALLED("scr_restore(%p,%s)"), SP_PARM, _nc_visbuf(file))); if (_nc_access(file, R_OK) < 0 || (fp = fopen(file, "rb")) == 0) { returnCode(ERR); } else { - delwin(newscr); - SP_PARM->_newscr = getwin(fp); + delwin(NewScreen(SP_PARM)); + NewScreen(SP_PARM) = getwin(fp); #if !USE_REENTRANT - newscr = SP_PARM->_newscr; + newscr = NewScreen(SP_PARM); #endif (void) fclose(fp); returnCode(OK); @@ -195,24 +206,29 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file) { FILE *fp = 0; + int code = ERR; - T((T_CALLED("scr_init(%s)"), _nc_visbuf(file))); - - if (exit_ca_mode && non_rev_rmcup) - returnCode(ERR); + T((T_CALLED("scr_init(%p,%s)"), SP_PARM, _nc_visbuf(file))); - if (_nc_access(file, R_OK) < 0 - || (fp = fopen(file, "rb")) == 0) { - returnCode(ERR); - } else { - delwin(curscr); - SP_PARM->_curscr = getwin(fp); + if (SP_PARM != 0 && +#ifdef USE_TERM_DRIVER + InfoOf(SP_PARM).caninit +#else + !(exit_ca_mode && non_rev_rmcup) +#endif + ) { + if (_nc_access(file, R_OK) >= 0 + && (fp = fopen(file, "rb")) != 0) { + delwin(CurScreen(SP_PARM)); + CurScreen(SP_PARM) = getwin(fp); #if !USE_REENTRANT - curscr = SP_PARM->_curscr; + curscr = CurScreen(SP_PARM); #endif - (void) fclose(fp); - returnCode(OK); + (void) fclose(fp); + code = OK; + } } + returnCode(code); } #if NCURSES_SP_FUNCS @@ -226,15 +242,15 @@ scr_init(const char *file) NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file) { - T((T_CALLED("scr_set(%s)"), _nc_visbuf(file))); + T((T_CALLED("scr_set(%p,%s)"), SP_PARM, _nc_visbuf(file))); - if (scr_init(file) == ERR) { + if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == ERR) { returnCode(ERR); } else { - delwin(newscr); - SP_PARM->_newscr = dupwin(curscr); + delwin(NewScreen(SP_PARM)); + NewScreen(SP_PARM) = dupwin(curscr); #if !USE_REENTRANT - newscr = SP_PARM->_newscr; + newscr = NewScreen(SP_PARM); #endif returnCode(OK); } diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c index 632bfba0..522d0928 100644 --- a/ncurses/base/lib_set_term.c +++ b/ncurses/base/lib_set_term.c @@ -46,10 +46,10 @@ #include #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_set_term.c,v 1.122 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_set_term.c,v 1.123 2009/06/06 20:26:17 tom Exp $") NCURSES_EXPORT(SCREEN *) set_term(SCREEN *screenp) @@ -554,7 +554,7 @@ _nc_setupscreen(int slines GCC_UNUSED, curscr = SP->_curscr; #endif #if USE_SIZECHANGE - SP->_resize = resizeterm; + SP->_resize = NCURSES_SP_NAME(resizeterm); #endif newscr->_clear = TRUE; diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c index 96ca6a6e..81a01c96 100644 --- a/ncurses/base/lib_slkrefr.c +++ b/ncurses/base/lib_slkrefr.c @@ -38,13 +38,12 @@ * Write SLK window to the (virtual) screen. */ #include -#include /* num_labels, label_*, plab_norm */ #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_slkrefr.c,v 1.20 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_slkrefr.c,v 1.21 2009/06/06 20:26:17 tom Exp $") /* * Paint the info line for the PC style SLK emulation. @@ -70,34 +69,47 @@ slk_paint_info(WINDOW *win) * Write the soft labels to the soft-key window. */ static void -slk_intern_refresh(SLK * slk) +slk_intern_refresh(SCREEN *sp) { -#if NCURSES_SP_FUNCS - SCREEN *sp = CURRENT_SCREEN; -#endif int i; - int fmt = SP->slk_format; + int fmt; + SLK *slk; + int numlab; + + if (sp == 0) + return; + + slk = sp->_slk; + fmt = sp->slk_format; + numlab = InfoOf(sp).numlabels; + + if (slk->hidden) + return; for (i = 0; i < slk->labcnt; i++) { if (slk->dirty || slk->ent[i].dirty) { if (slk->ent[i].visible) { - if (num_labels > 0 && SLK_STDFMT(fmt)) { + if (numlab > 0 && SLK_STDFMT(fmt)) { +#ifdef USE_TERM_DRIVER + CallDriver_2(sp, hwlabel, i + 1, slk->ent[i].form_text); +#else if (i < num_labels) { TPUTS_TRACE("plab_norm"); putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); } +#endif } else { if (fmt == 4) slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); - if (SP->_slk) { - wattrset(slk->win, AttrOf(SP->_slk->attr)); + if (sp->_slk) { + wattrset(slk->win, AttrOf(sp->_slk->attr)); } waddstr(slk->win, slk->ent[i].form_text); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also for the label window */ - wattrset(slk->win, WINDOW_ATTRS(stdscr)); + wattrset(slk->win, WINDOW_ATTRS(StdScreen(sp))); } } slk->ent[i].dirty = FALSE; @@ -105,7 +117,10 @@ slk_intern_refresh(SLK * slk) } slk->dirty = FALSE; - if (num_labels > 0) { + if (numlab > 0) { +#ifdef USE_TERM_DRIVER + CallDriver_1(sp, hwlabelOnOff, slk->hidden ? FALSE : TRUE); +#else if (slk->hidden) { TPUTS_TRACE("label_off"); putp(label_off); @@ -113,6 +128,7 @@ slk_intern_refresh(SLK * slk) TPUTS_TRACE("label_on"); putp(label_on); } +#endif } } @@ -122,13 +138,13 @@ slk_intern_refresh(SLK * slk) NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (NCURSES_SP_DCL0) { - T((T_CALLED("slk_noutrefresh()"))); + T((T_CALLED("slk_noutrefresh(%p)"), SP_PARM)); - if (SP_PARM == NULL || SP_PARM->_slk == NULL) + if (SP_PARM == 0 || SP_PARM->_slk == 0) returnCode(ERR); if (SP_PARM->_slk->hidden) returnCode(OK); - slk_intern_refresh(SP_PARM->_slk); + slk_intern_refresh(SP_PARM); returnCode(wnoutrefresh(SP_PARM->_slk->win)); } @@ -147,13 +163,13 @@ slk_noutrefresh(void) NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_DCL0) { - T((T_CALLED("slk_refresh()"))); + T((T_CALLED("slk_refresh(%p)"), SP_PARM)); - if (SP_PARM == NULL || SP_PARM->_slk == NULL) + if (SP_PARM == 0 || SP_PARM->_slk == 0) returnCode(ERR); if (SP_PARM->_slk->hidden) returnCode(OK); - slk_intern_refresh(SP_PARM->_slk); + slk_intern_refresh(SP_PARM); returnCode(wrefresh(SP_PARM->_slk->win)); } diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 71277786..a978f298 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.420 2009/05/30 15:53:46 tom Exp $ + * $Id: curses.priv.h,v 1.421 2009/06/06 18:12:52 tom Exp $ * * curses.priv.h * @@ -340,6 +340,7 @@ color_t; #endif #else /* !(NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT) */ + #define if_EXT_COLORS(stmt) /* nothing */ #define SetPair(value,p) RemAttr(value, A_COLOR), \ SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p))) @@ -932,6 +933,7 @@ struct screen { */ bool _nc_sp_idlok; bool _nc_sp_idcok; + #define _nc_idlok SP->_nc_sp_idlok #define _nc_idcok SP->_nc_sp_idcok @@ -987,7 +989,7 @@ struct screen { * This supports automatic resizing */ #if USE_SIZECHANGE - int (*_resize)(int,int); + int (*_resize)(NCURSES_SP_DCLx int y, int x); #endif /* @@ -1804,8 +1806,9 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums; * On systems with a broken linker, define 'SP' as a function to force the * linker to pull in the data-only module with 'SP'. */ +#define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1) + #if BROKEN_LINKER -#define SP _nc_screen() extern NCURSES_EXPORT(SCREEN *) _nc_screen (void); extern NCURSES_EXPORT(int) _nc_alloc_screen (void); extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); @@ -1814,7 +1817,7 @@ extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *); /* current screen is private data; avoid possible linking conflicts too */ extern NCURSES_EXPORT_VAR(SCREEN *) SP; #define CURRENT_SCREEN SP -#define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0) +#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0) #define _nc_set_screen(sp) SP = sp #endif @@ -2012,9 +2015,6 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int); * We put the safe versions of various calls here as they are not published * part of the API up to now */ -extern NCURSES_EXPORT(SCREEN*) _nc_SP(void); - -extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_set_curterm)(SCREEN*,TERMINAL*); extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(cur_term)(SCREEN *sp); extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int); extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*); diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c index dd4286ce..746d69a3 100644 --- a/ncurses/tinfo/entries.c +++ b/ncurses/tinfo/entries.c @@ -28,6 +28,7 @@ /**************************************************************************** * Author: Thomas E. Dickey * + * and: Juergen Pfeifer * ****************************************************************************/ #include @@ -37,7 +38,7 @@ #include #include -MODULE_ID("$Id: entries.c,v 1.11 2009/03/14 15:22:37 tom Exp $") +MODULE_ID("$Id: entries.c,v 1.12 2009/06/06 18:54:42 tom Exp $") /**************************************************************************** * @@ -120,8 +121,8 @@ _nc_leaks_tinfo(void) _nc_free_tparm(); _nc_tgetent_leaks(); - if (cur_term != 0) - del_curterm(cur_term); + if (HasTerminal(CURRENT_SCREEN)) + del_curterm(TerminalOf(CURRENT_SCREEN)); _nc_free_entries(_nc_head); _nc_get_type(0); diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c index d0bec27c..85e161d9 100644 --- a/ncurses/tinfo/lib_acs.c +++ b/ncurses/tinfo/lib_acs.c @@ -30,16 +30,16 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2008 * ****************************************************************************/ #include -#include /* ena_acs, acs_chars */ #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_acs.c,v 1.39 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_acs.c,v 1.40 2009/06/06 18:08:04 tom Exp $") #if BROKEN_LINKER || USE_REENTRANT #define MyBuffer _nc_prescreen.real_acs_map @@ -58,14 +58,29 @@ NCURSES_EXPORT_VAR (chtype) acs_map[ACS_LEN] = }; #endif -NCURSES_EXPORT(void) -_nc_init_acs(void) +#ifdef USE_TERM_DRIVER +NCURSES_EXPORT(chtype) +NCURSES_SP_NAME(_nc_acs_char) (NCURSES_SP_DCLx int c) { -#if NCURSES_SP_FUNCS - SCREEN *sp = CURRENT_SCREEN; + chtype *map; + if (c < 0 || c >= ACS_LEN) + return (chtype) 0; + map = (SP_PARM != 0) ? SP_PARM->_acs_map : +#if BROKEN_LINKER || USE_REENTRANT + _nc_prescreen.real_acs_map +#else + acs_map #endif + ; + return map[c]; +} +#endif /* USE_TERM_DRIVER */ + +NCURSES_EXPORT(void) +NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0) +{ chtype *fake_map = acs_map; - chtype *real_map = SP != 0 ? SP->_acs_map : fake_map; + chtype *real_map = SP_PARM != 0 ? SP_PARM->_acs_map : fake_map; int j; T(("initializing ACS map")); @@ -79,8 +94,8 @@ _nc_init_acs(void) for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; fake_map[j] = A_ALTCHARSET | j; - if (SP) - SP->_screen_acs_map[j] = FALSE; + if (SP_PARM) + SP_PARM->_screen_acs_map[j] = FALSE; } } else { for (j = 1; j < ACS_LEN; ++j) { @@ -126,6 +141,9 @@ _nc_init_acs(void) real_map['|'] = '!'; /* should be not-equal */ real_map['}'] = 'f'; /* should be pound-sterling symbol */ +#ifdef USE_TERM_DRIVER + CallDriver_2(SP_PARM, initacs, real_map, fake_map); +#else if (ena_acs != NULL) { TPUTS_TRACE("ena_acs"); putp(ena_acs); @@ -198,4 +216,13 @@ _nc_init_acs(void) _nc_unlock_global(tracef); } #endif /* TRACE */ +#endif } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +_nc_init_acs(void) +{ + NCURSES_SP_NAME(_nc_init_acs) (CURRENT_SCREEN); +} +#endif diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c index 1f912d9a..71261eda 100644 --- a/ncurses/tinfo/lib_data.c +++ b/ncurses/tinfo/lib_data.c @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: lib_data.c,v 1.53 2009/05/30 15:59:25 tom Exp $") +MODULE_ID("$Id: lib_data.c,v 1.54 2009/06/06 18:46:31 tom Exp $") /* * OS/2's native linker complains if we don't initialize public data when @@ -51,17 +51,17 @@ MODULE_ID("$Id: lib_data.c,v 1.53 2009/05/30 15:59:25 tom Exp $") NCURSES_EXPORT(WINDOW *) NCURSES_PUBLIC_VAR(stdscr) (void) { - return SP ? SP->_stdscr : 0; + return CURRENT_SCREEN ? StdScreen(CURRENT_SCREEN) : 0; } NCURSES_EXPORT(WINDOW *) NCURSES_PUBLIC_VAR(curscr) (void) { - return SP ? SP->_curscr : 0; + return CURRENT_SCREEN ? CurScreen(CURRENT_SCREEN) : 0; } NCURSES_EXPORT(WINDOW *) NCURSES_PUBLIC_VAR(newscr) (void) { - return SP ? SP->_newscr : 0; + return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : 0; } #else NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0; @@ -93,7 +93,7 @@ _nc_screen(void) NCURSES_EXPORT(int) _nc_alloc_screen(void) { - return ((my_screen = typeCalloc(SCREEN, 1)) != 0); + return ((my_screen = _nc_alloc_screen_sp()) != 0); } NCURSES_EXPORT(void) @@ -103,6 +103,7 @@ _nc_set_screen(SCREEN *sp) } #else + NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */ #endif /* *INDENT-OFF* */ @@ -140,7 +141,9 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = { 0, /* tgetent_index */ 0, /* tgetent_sequence */ +#ifndef USE_SP_WINDOWLIST 0, /* _nc_windowlist */ +#endif #if USE_HOME_TERMINFO NULL, /* home_terminfo */ @@ -174,7 +177,9 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = { { CHARS_0s, CHARS_0s }, /* traceatr_color_buf */ 0, /* traceatr_color_sel */ -1, /* traceatr_color_last */ - +#if !defined(USE_PTHREADS) && USE_REENTRANT + 0, /* nested_tracef */ +#endif #endif /* TRACE */ #ifdef USE_PTHREADS PTHREAD_MUTEX_INITIALIZER, /* mutex_curses */ @@ -196,8 +201,10 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { TRUE, /* use_env */ FALSE, /* filter_mode */ A_NORMAL, /* previous_attr */ +#ifndef USE_SP_RIPOFF RIPOFF_0s, /* ripoff */ NULL, /* rsp */ +#endif { /* tparm_state */ #ifdef TRACE NULL, /* tname */ @@ -236,6 +243,23 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { }; /* *INDENT-ON* */ +/* + * wgetch() and other functions with a WINDOW* parameter may use a SCREEN* + * internally, and it is useful to allow those to be invoked without switching + * SCREEN's, e.g., for multi-threaded applications. + */ +NCURSES_EXPORT(SCREEN *) +_nc_screen_of(WINDOW *win) +{ + SCREEN *sp = 0; + + if (win != 0) { + WINDOWLIST *wp = (WINDOWLIST *) win; + sp = wp->screen; + } + return (sp); +} + /******************************************************************************/ #ifdef USE_PTHREADS static void diff --git a/ncurses/tinfo/lib_kernel.c b/ncurses/tinfo/lib_kernel.c index 861c6541..558b2073 100644 --- a/ncurses/tinfo/lib_kernel.c +++ b/ncurses/tinfo/lib_kernel.c @@ -47,9 +47,8 @@ */ #include -#include /* cur_term */ -MODULE_ID("$Id: lib_kernel.c,v 1.25 2009/02/15 00:47:52 tom Exp $") +MODULE_ID("$Id: lib_kernel.c,v 1.27 2009/06/06 21:25:50 tom Exp $") static int _nc_vdisable(void) @@ -83,15 +82,17 @@ NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (NCURSES_SP_DCL0) { int result = ERR; - T((T_CALLED("erasechar()"))); + TERMINAL *termp = TerminalOf(SP_PARM); - if (cur_term != 0) { + T((T_CALLED("erasechar(%p)"), SP_PARM)); + + if (termp != 0) { #ifdef TERMIOS - result = cur_term->Ottyb.c_cc[VERASE]; + result = termp->Ottyb.c_cc[VERASE]; if (result == _nc_vdisable()) result = ERR; #else - result = cur_term->Ottyb.sg_erase; + result = termp->Ottyb.sg_erase; #endif } returnCode(result); @@ -116,15 +117,17 @@ NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (NCURSES_SP_DCL0) { int result = ERR; - T((T_CALLED("killchar()"))); + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("killchar(%p)"), SP_PARM)); - if (cur_term != 0) { + if (termp != 0) { #ifdef TERMIOS - result = cur_term->Ottyb.c_cc[VKILL]; + result = termp->Ottyb.c_cc[VKILL]; if (result == _nc_vdisable()) result = ERR; #else - result = cur_term->Ottyb.sg_kill; + result = termp->Ottyb.sg_kill; #endif } returnCode(result); @@ -148,15 +151,17 @@ killchar(void) NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0) { - T((T_CALLED("flushinp()"))); + TERMINAL *termp = TerminalOf(SP_PARM); + + T((T_CALLED("flushinp(%p)"), SP_PARM)); - if (cur_term != 0) { + if (termp != 0) { #ifdef TERMIOS - tcflush(cur_term->Filedes, TCIFLUSH); + tcflush(termp->Filedes, TCIFLUSH); #else errno = 0; do { - ioctl(cur_term->Filedes, TIOCFLUSH, 0); + ioctl(termp->Filedes, TIOCFLUSH, 0); } while (errno == EINTR); #endif diff --git a/ncurses/tinfo/lib_napms.c b/ncurses/tinfo/lib_napms.c index 07f0585d..6f13cc4b 100644 --- a/ncurses/tinfo/lib_napms.c +++ b/ncurses/tinfo/lib_napms.c @@ -51,13 +51,16 @@ #endif #endif -MODULE_ID("$Id: lib_napms.c,v 1.18 2009/02/15 00:48:27 tom Exp $") +MODULE_ID("$Id: lib_napms.c,v 1.19 2009/06/06 18:50:30 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms) { T((T_CALLED("napms(%d)"), ms)); +#ifdef USE_TERM_DRIVER + CallDriver_1(sp, nap, ms); +#else /* !USE_TERM_DRIVER */ #if HAVE_NANOSLEEP { struct timespec request, remaining; @@ -71,6 +74,7 @@ NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms) #else _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0)); #endif +#endif /* !USE_TERM_DRIVER */ returnCode(OK); } diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c index 6f466673..e5abd4de 100644 --- a/ncurses/tinfo/lib_print.c +++ b/ncurses/tinfo/lib_print.c @@ -29,30 +29,27 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer * ****************************************************************************/ #include -#include - #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_print.c,v 1.18 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_print.c,v 1.19 2009/06/06 20:26:17 tom Exp $") NCURSES_EXPORT(int) -mcprint(char *data, int len) +NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx 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; errno = 0; - if (!cur_term || (!prtr_non && (!prtr_on || !prtr_off))) { + if (!HasTInfoTerminal(SP_PARM) || (!prtr_non && (!prtr_on || !prtr_off))) { errno = ENODEV; return (ERR); } @@ -85,15 +82,24 @@ mcprint(char *data, int len) * data has actually been shipped to the terminal. If the write(2) * operation is truly atomic we're protected from this. */ - res = write(cur_term->Filedes, mybuf, onsize + len + offsize); + res = write(TerminalOf(SP_PARM)->Filedes, mybuf, onsize + len + offsize); /* * By giving up our scheduler slot here we increase the odds that the * kernel will ship the contiguous clist items from the last write * immediately. */ +#ifndef __MINGW32__ (void) sleep(0); - +#endif free(mybuf); return (res); } + +#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER) +NCURSES_EXPORT(int) +mcprint(char *data, int len) +{ + return NCURSES_SP_NAME(mcprint) (CURRENT_SCREEN, data, len); +} +#endif diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index b01df6a2..2cab9baf 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -54,7 +54,7 @@ #include /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_setup.c,v 1.116 2009/05/30 20:39:21 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.117 2009/06/06 17:56:31 tom Exp $") /**************************************************************************** * @@ -347,7 +347,7 @@ _nc_update_screensize(SCREEN *sp) if (sp != 0 && sp->_resize != 0) { if ((new_lines != old_lines) || (new_cols != old_cols)) - sp->_resize(new_lines, new_cols); + sp->_resize(NCURSES_SP_ARGx new_lines, new_cols); sp->_sig_winch = FALSE; } } diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c index fbaacb42..af4d8f84 100644 --- a/ncurses/tinfo/lib_termcap.c +++ b/ncurses/tinfo/lib_termcap.c @@ -50,7 +50,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_termcap.c,v 1.66 2009/05/23 23:47:34 tom Exp $") +MODULE_ID("$Id: lib_termcap.c,v 1.67 2009/05/30 20:05:20 tom Exp $") NCURSES_EXPORT_VAR(char *) UP = 0; NCURSES_EXPORT_VAR(char *) BC = 0; @@ -83,14 +83,26 @@ NCURSES_EXPORT_VAR(char *) BC = 0; NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) { - int errcode; + int errcode = ERR; int n; bool found_cache = FALSE; +#ifdef USE_TERM_DRIVER + TERMINAL *termp = 0; +#endif START_TRACE(); T((T_CALLED("tgetent()"))); +#ifdef USE_TERM_DRIVER + _nc_setupterm_ex(&termp, (NCURSES_CONST char *) name, + STDOUT_FILENO, &errcode, TRUE); + + if (termp == 0 || + !((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo) + return (errcode); +#else _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE); +#endif /* * In general we cannot tell if the fixed sgr0 is still used by the @@ -114,7 +126,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) /* * Also free the terminfo data that we loaded (much bigger leak). */ - if (LAST_TRM != 0 && LAST_TRM != cur_term) { + if (LAST_TRM != 0 && LAST_TRM != TerminalOf(SP_PARM)) { TERMINAL *trm = LAST_TRM; NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM); for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) @@ -136,7 +148,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) } CacheInx = best; } - LAST_TRM = cur_term; + LAST_TRM = TerminalOf(SP_PARM); LAST_SEQ = ++CacheSeq; PC = 0; @@ -158,7 +170,7 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name) if (backspace_if_not_bs != NULL) BC = backspace_if_not_bs; - if ((FIX_SGR0 = _nc_trim_sgr0(&(cur_term->type))) != 0) { + if ((FIX_SGR0 = _nc_trim_sgr0(&(TerminalOf(SP_PARM)->type))) != 0) { if (!strcmp(FIX_SGR0, exit_attribute_mode)) { if (FIX_SGR0 != exit_attribute_mode) { free(FIX_SGR0); @@ -204,9 +216,9 @@ NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx NCURSES_CONST char *id) { unsigned i; - T((T_CALLED("tgetflag(%s)"), id)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + T((T_CALLED("tgetflag(%p, %s)"), SP_PARM, id)); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_boolean(i, tp) { const char *capname = ExtBoolname(tp, i, boolcodes); if (!strncmp(id, capname, 2)) { @@ -240,9 +252,9 @@ NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx NCURSES_CONST char *id) { unsigned i; - T((T_CALLED("tgetnum(%s)"), id)); - if (cur_term != 0) { - TERMTYPE *tp = &(cur_term->type); + T((T_CALLED("tgetnum(%p, %s)"), SP_PARM, id)); + if (HasTInfoTerminal(SP_PARM)) { + TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); for_each_number(i, tp) { const char *capname = ExtNumname(tp, i, numcodes); if (!strncmp(id, capname, 2)) { @@ -279,8 +291,8 @@ NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx NCURSES_CONST char *id, char **area) char *result = NULL; T((T_CALLED("tgetstr(%s,%p)"), id, area)); - 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, strcodes); if (!strncmp(id, capname, 2)) { diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c index 0bea1b78..6cadbca1 100644 --- a/ncurses/tinfo/lib_tputs.c +++ b/ncurses/tinfo/lib_tputs.c @@ -51,7 +51,7 @@ #include /* ospeed */ #include -MODULE_ID("$Id: lib_tputs.c,v 1.74 2009/05/23 23:56:23 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.75 2009/05/30 19:44:43 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */ @@ -85,6 +85,9 @@ NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms) { T((T_CALLED("delay_output(%p,%d)"), SP_PARM, ms)); + if (!HasTInfoTerminal(SP_PARM)) + returnCode(ERR); + if (no_pad_char) { NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); napms(ms); @@ -128,7 +131,7 @@ NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch) { COUNT_OUTCHARS(1); - if (SP_PARM != 0 + if (HasTInfoTerminal(SP_PARM) && SP_PARM->_cleanup) { char tmp = ch; /* @@ -217,10 +220,13 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx } #endif /* TRACE */ + if (SP_PARM != 0 && !HasTInfoTerminal(SP_PARM)) + return ERR; + if (!VALID_STRING(string)) return ERR; - if (cur_term == 0) { + if (SP_PARM != 0 && SP_PARM->_term == 0) { always_delay = FALSE; normal_delay = TRUE; } else { diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c index 8115662e..17b13b2d 100644 --- a/ncurses/tinfo/lib_ttyflags.c +++ b/ncurses/tinfo/lib_ttyflags.c @@ -36,40 +36,45 @@ */ #include -#include /* cur_term */ #ifndef CUR -#define CUR SP_TERMTYPE +#define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_ttyflags.c,v 1.24 2009/05/10 00:48:29 tom Exp $") +MODULE_ID("$Id: lib_ttyflags.c,v 1.25 2009/06/06 19:10:05 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; - if (buf == 0) { + if (buf == 0 || SP_PARM == 0) { result = ERR; } else { - if (cur_term == 0) { + TERMINAL *termp = TerminalOf(SP_PARM); + + if (0 == termp) { result = ERR; } else { +#ifdef USE_TERM_DRIVER + result = CallDriver_2(SP_PARM, sgmode, FALSE, buf); +#else for (;;) { - if (GET_TTY(cur_term->Filedes, buf) != 0) { + if (GET_TTY(termp->Filedes, buf) != 0) { if (errno == EINTR) continue; result = ERR; } break; } +#endif } if (result == ERR) memset(buf, 0, sizeof(*buf)); TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s", - cur_term ? cur_term->Filedes : -1, + termp ? termp->Filedes : -1, _nc_trace_ttymode(buf))); } return (result); @@ -88,14 +93,19 @@ NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; - if (buf == 0) { + if (buf == 0 || SP_PARM == 0) { result = ERR; } else { - if (cur_term == 0) { + TERMINAL *termp = TerminalOf(SP_PARM); + + if (0 == termp) { result = ERR; } else { +#ifdef USE_TERM_DRIVER + result = CallDriver_2(SP_PARM, sgmode, TRUE, buf); +#else for (;;) { - if (SET_TTY(cur_term->Filedes, buf) != 0) { + if (SET_TTY(termp->Filedes, buf) != 0) { if (errno == EINTR) continue; if ((errno == ENOTTY) && (SP_PARM != 0)) @@ -104,9 +114,10 @@ NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf) } break; } +#endif } TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s", - cur_term ? cur_term->Filedes : -1, + termp ? termp->Filedes : -1, _nc_trace_ttymode(buf))); } return (result); @@ -124,23 +135,28 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0) { int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); - T((T_CALLED("def_shell_mode()"))); + T((T_CALLED("def_shell_mode(%p)"), SP_PARM)); - if (cur_term != 0) { + if (termp != 0) { +#ifdef USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, mode, FALSE, TRUE); +#else /* * If XTABS was on, remove the tab and backtab capabilities. */ - if (_nc_get_tty_mode(&cur_term->Ottyb) == OK) { + if (_nc_get_tty_mode(&termp->Ottyb) == OK) { #ifdef TERMIOS - if (cur_term->Ottyb.c_oflag & OFLAGS_TABS) + if (termp->Ottyb.c_oflag & OFLAGS_TABS) tab = back_tab = NULL; #else - if (cur_term->Ottyb.sg_flags & XTABS) + if (termp->Ottyb.sg_flags & XTABS) tab = back_tab = NULL; #endif rc = OK; } +#endif } returnCode(rc); } @@ -157,21 +173,26 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0) { int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); - T((T_CALLED("def_prog_mode()"))); + T((T_CALLED("def_prog_mode(%p)"), SP_PARM)); - if (cur_term != 0) { + if (termp != 0) { +#ifdef USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, mode, TRUE, TRUE); +#else /* * Turn off the XTABS bit in the tty structure if it was on. */ - if (_nc_get_tty_mode(&cur_term->Nttyb) == OK) { + if (_nc_get_tty_mode(&termp->Nttyb) == OK) { #ifdef TERMIOS - cur_term->Nttyb.c_oflag &= ~OFLAGS_TABS; + termp->Nttyb.c_oflag &= ~OFLAGS_TABS; #else - cur_term->Nttyb.sg_flags &= ~XTABS; + termp->Nttyb.sg_flags &= ~XTABS; #endif rc = OK; } +#endif } returnCode(rc); } @@ -187,19 +208,26 @@ def_prog_mode(void) NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0) { - T((T_CALLED("reset_prog_mode()"))); + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); - if (cur_term != 0) { - if (_nc_set_tty_mode(&cur_term->Nttyb) == OK) { + T((T_CALLED("reset_prog_mode(%p)"), SP_PARM)); + + if (termp != 0) { +#ifdef USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, mode, TRUE, FALSE); +#else + if (_nc_set_tty_mode(&termp->Nttyb) == OK) { if (SP_PARM) { if (SP_PARM->_keypad_on) _nc_keypad(SP_PARM, TRUE); NC_BUFFERED(SP_PARM, TRUE); } - returnCode(OK); + rc = OK; } +#endif } - returnCode(ERR); + returnCode(rc); } #if NCURSES_SP_FUNCS @@ -213,17 +241,24 @@ reset_prog_mode(void) NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0) { - T((T_CALLED("reset_shell_mode()"))); + int rc = ERR; + TERMINAL *termp = TerminalOf(SP_PARM); - if (cur_term != 0) { + T((T_CALLED("reset_shell_mode(%p)"), SP_PARM)); + + if (termp != 0) { +#ifdef USE_TERM_DRIVER + rc = CallDriver_2(SP_PARM, mode, FALSE, FALSE); +#else if (SP_PARM) { _nc_keypad(SP_PARM, FALSE); _nc_flush(); NC_BUFFERED(SP_PARM, FALSE); } - returnCode(_nc_set_tty_mode(&cur_term->Ottyb)); + rc = _nc_set_tty_mode(&termp->Ottyb); +#endif } - returnCode(ERR); + returnCode(rc); } #if NCURSES_SP_FUNCS @@ -235,12 +270,12 @@ reset_shell_mode(void) #endif static TTY * -saved_tty(void) +saved_tty(NCURSES_SP_DCL0) { TTY *result = 0; - if (SP != 0) { - result = &(SP->_saved_tty); + if (SP_PARM != 0) { + result = (TTY *) & (SP_PARM->_saved_tty); } else { if (_nc_prescreen.saved_tty == 0) { _nc_prescreen.saved_tty = typeCalloc(TTY, 1); @@ -255,18 +290,32 @@ saved_tty(void) ** */ +NCURSES_EXPORT(int) +NCURSES_SP_NAME(savetty) (NCURSES_SP_DCL0) +{ + T((T_CALLED("savetty(%p)"), SP_PARM)); + returnCode(NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG))); +} + +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) savetty(void) { - T((T_CALLED("savetty()"))); + return NCURSES_SP_NAME(savetty) (CURRENT_SCREEN); +} +#endif - returnCode(_nc_get_tty_mode(saved_tty())); +NCURSES_EXPORT(int) +NCURSES_SP_NAME(resetty) (NCURSES_SP_DCL0) +{ + T((T_CALLED("resetty(%p)"), SP_PARM)); + returnCode(NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_ARGx saved_tty(NCURSES_SP_ARG))); } +#if NCURSES_SP_FUNCS NCURSES_EXPORT(int) resetty(void) { - T((T_CALLED("resetty()"))); - - returnCode(_nc_set_tty_mode(saved_tty())); + return NCURSES_SP_NAME(resetty) (CURRENT_SCREEN); } +#endif diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index b91053bc..6de4ecb2 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -82,7 +82,7 @@ #include -MODULE_ID("$Id: tty_update.c,v 1.256 2009/05/17 00:13:49 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.257 2009/06/06 20:26:16 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -192,12 +192,13 @@ position_check(NCURSES_SP_DCLx int expected_y, int expected_x, char *legend) static NCURSES_INLINE void GoTo(NCURSES_SP_DCLx int const row, int const col) { - TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)", - row, col, SP_PARM->_cursrow, SP_PARM->_curscol)); + TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)", + SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol)); position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo"); - mvcur(SP_PARM->_cursrow, SP_PARM->_curscol, row, col); + NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx SP_PARM->_cursrow, + SP_PARM->_curscol, row, col); position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo2"); } @@ -558,7 +559,8 @@ 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); - NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx 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, @@ -666,7 +668,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) struct tms before, after; #endif /* USE_TRACE_TIMES */ - T((T_CALLED("doupdate()"))); + T((T_CALLED("_nc_tinfo:doupdate(%p)"), SP_PARM)); #if !USE_REENTRANT /* @@ -806,9 +808,8 @@ 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(NewScreen(SP_PARM)->_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, @@ -870,8 +871,7 @@ 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(NewScreen(SP_PARM)->_line[p].text[q]); + attr_t testattr = AttrOf(newscr->_line[p].text[q]); if ((testattr & SP_PARM->_xmc_triggers) == rattr) goto foundend; RemAttr(NewScreen(SP_PARM)->_line[p].text[q], turnon); @@ -921,7 +921,7 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1); if (SP_PARM->_scrolling) { - _nc_scroll_optimize(); + NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_ARG); } nonempty = ClrBottom(NCURSES_SP_ARGx nonempty); @@ -938,8 +938,8 @@ 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, */ @@ -1022,14 +1022,14 @@ doupdate(void) * in the wbkgd() call. Assume 'stdscr' for this case. */ #define BCE_ATTRS (A_NORMAL|A_COLOR) -#define BCE_BKGD(win) (((win) == CurScreen(SP_PARM) ? StdScreen(SP_PARM) : (win))->_nc_bkgd) +#define BCE_BKGD(sp,win) (((win) == CurScreen(sp) ? StdScreen(sp) : (win))->_nc_bkgd) static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win) { NCURSES_CH_T blank = blankchar; if (back_color_erase) - AddAttr(blank, (AttrOf(BCE_BKGD(win)) & BCE_ATTRS)); + AddAttr(blank, (AttrOf(BCE_BKGD(SP_PARM, win)) & BCE_ATTRS)); return blank; } @@ -1073,7 +1073,7 @@ ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear) { int j; - if (CurScreen(SP_PARM) != 0 + if (SP_PARM != 0 && CurScreen(SP_PARM) != 0 && SP_PARM->_cursrow >= 0) { for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) { if (j >= 0) { @@ -1191,7 +1191,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) NewScreen(SP_PARM)->_line[r].text[c] +#define xmc_new(sp,r,c) NewScreen(sp)->_line[r].text[c] #define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a) #endif /* USE_XMC_SUPPORT */ @@ -1271,8 +1271,8 @@ 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(NCURSES_SP_ARGx CurScreen(SP_PARM)), - FALSE); + ClrBlank(NCURSES_SP_ARGx + CurScreen(SP_PARM)), FALSE); PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno, 0, screen_columns(SP_PARM) - 1); @@ -1432,7 +1432,8 @@ TransformLine(NCURSES_SP_DCLx int const lineno) ClrToEOL(NCURSES_SP_ARGx blank, FALSE); } else if ((nLastChar != oLastChar) && (!CharEq(newLine[nLastChar], oldLine[oLastChar]) - || !(_nc_idcok && has_ic()))) { + || !(SP_PARM->_nc_sp_idcok + && NCURSES_SP_NAME(has_ic) (NCURSES_SP_ARG)))) { GoTo(NCURSES_SP_ARGx lineno, firstChar); if ((oLastChar - nLastChar) > SP_PARM->_el_cost) { if (PutRange(NCURSES_SP_ARGx @@ -1576,7 +1577,6 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) } else if (clr_eos) { SP_PARM->_cursrow = SP_PARM->_curscol = -1; GoTo(NCURSES_SP_ARGx 0, 0); - UpdateAttrs(SP_PARM, blank); TPUTS_TRACE("clr_eos"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx @@ -1585,7 +1585,6 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank) NCURSES_SP_NAME(_nc_outch)); } else if (clr_eol) { SP_PARM->_cursrow = SP_PARM->_curscol = -1; - UpdateAttrs(SP_PARM, blank); for (i = 0; i < screen_lines(SP_PARM); i++) { GoTo(NCURSES_SP_ARGx i, 0); @@ -1933,12 +1932,17 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx int maxy) /* scroll region from top to bot by n lines */ { - NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); + NCURSES_CH_T blank; int i; bool cursor_saved = FALSE; int res; - TR(TRACE_MOVE, ("mvcur_scrolln(%d, %d, %d, %d)", n, top, bot, maxy)); + TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)", SP_PARM, n, top, bot, maxy)); + + if (!IsValidScreen(SP_PARM)) + return (ERR); + + blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); #if USE_XMC_SUPPORT /* @@ -1982,7 +1986,7 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx SP_PARM->_cursrow = SP_PARM->_curscol = -1; } - if (res == ERR && _nc_idlok) + if (res == ERR && SP_PARM->_nc_sp_idlok) res = scroll_idl(NCURSES_SP_ARGx n, top, bot - n + 1, blank); /* @@ -2033,7 +2037,7 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx SP_PARM->_cursrow = SP_PARM->_curscol = -1; } - if (res == ERR && _nc_idlok) + if (res == ERR && SP_PARM->_nc_sp_idlok) res = scroll_idl(NCURSES_SP_ARGx -n, bot + n + 1, top, blank); /* @@ -2079,7 +2083,7 @@ NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0) /* reset color pairs and definitions */ if (SP_PARM->_coloron || SP_PARM->_color_defs) - _nc_reset_colors(); + NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); /* restore user-defined colors, if any */ if (SP_PARM->_color_defs < 0) { @@ -2151,20 +2155,23 @@ NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) static const NCURSES_CH_T blank = NewChar(BLANK_TEXT); SP_PARM->_default_color = TRUE; NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx - -1, 0, + -1, + 0, FALSE, NCURSES_SP_NAME(_nc_outch)); SP_PARM->_default_color = FALSE; - mvcur(SP_PARM->_cursrow, - SP_PARM->_curscol, - screen_lines(SP_PARM) - 1, 0); + NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx + SP_PARM->_cursrow, + SP_PARM->_curscol, + screen_lines(SP_PARM) - 1, + 0); ClrToEOL(NCURSES_SP_ARGx blank, TRUE); } #endif if (SP_PARM->_color_defs) { - _nc_reset_colors(); + NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG); } }