From: Thomas E. Dickey Date: Sun, 25 May 2008 00:49:27 +0000 (+0000) Subject: ncurses 5.6 - patch 20080524 X-Git-Tag: v5.7~25 X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff_plain;h=9edffa2f21102c06dcf682d58b074c407bcedd0a;ds=sidebyside ncurses 5.6 - patch 20080524 + modify _nc_keypad() to make it switch temporarily as needed to the screen which must be updated. + wrap cur_term variable to help make _nc_keymap() thread-safe, and always set the screen's copy of this variable in set_curterm(). + restore curs_set() state after endwin()/refresh() (report/patch Miroslav Lichvar) --- diff --git a/NEWS b/NEWS index 0ff55540..f14402b6 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.1235 2008/05/17 19:51:30 tom Exp $ +-- $Id: NEWS,v 1.1237 2008/05/24 22:23:07 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,14 @@ 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. +20080524 + + modify _nc_keypad() to make it switch temporarily as needed to the + screen which must be updated. + + wrap cur_term variable to help make _nc_keymap() thread-safe, and + always set the screen's copy of this variable in set_curterm(). + + restore curs_set() state after endwin()/refresh() (report/patch + Miroslav Lichvar) + 20080517 + modify configure script to note that --enable-ext-colors and --enable-ext-mouse are not experimental, but extensions from diff --git a/dist.mk b/dist.mk index 2429baa8..fc57d6af 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.642 2008/05/17 18:44:56 tom Exp $ +# $Id: dist.mk,v 1.643 2008/05/24 12:05:32 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 = 6 -NCURSES_PATCH = 20080517 +NCURSES_PATCH = 20080524 # 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 6f0fca33..5fc20529 100644 --- a/include/MKterm.h.awk.in +++ b/include/MKterm.h.awk.in @@ -1,7 +1,7 @@ # vile:awkmode BEGIN { print "/****************************************************************************" - print " * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *" + print " * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *" print " * *" print " * Permission is hereby granted, free of charge, to any person obtaining a *" print " * copy of this software and associated documentation files (the *" @@ -34,7 +34,7 @@ BEGIN { print "/* and: Thomas E. Dickey 1995-on */" print "/****************************************************************************/" print "" - print "/* $Id: MKterm.h.awk.in,v 1.49 2007/08/18 11:44:26 tom Exp $ */" + print "/* $Id: MKterm.h.awk.in,v 1.50 2008/05/24 23:13:59 tom Exp $ */" print "" print "/*" print "** term.h -- Definition of struct term" @@ -228,9 +228,8 @@ END { print " char * _termname; /* used for termname() */" print "} TERMINAL;" print "" - print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" - print "" print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@" + print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);" @@ -241,6 +240,7 @@ END { print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);" print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);" print "" + print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())" print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())" print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())" print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())" @@ -253,6 +253,8 @@ END { print "" print "#else" print "" + print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" + print "" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];" print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];" diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 03fe1937..b6447723 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ /* - * $Id: curses.priv.h,v 1.374 2008/05/17 21:24:44 tom Exp $ + * $Id: curses.priv.h,v 1.375 2008/05/24 23:08:27 tom Exp $ * * curses.priv.h * @@ -645,6 +645,7 @@ typedef struct { chtype *real_acs_map; int _LINES; int _COLS; + TERMINAL *_cur_term; #ifdef TRACE long _outchars; const char *_tputs_trace; diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c index d30d3ed1..2f6fe4f6 100644 --- a/ncurses/tinfo/init_keytry.c +++ b/ncurses/tinfo/init_keytry.c @@ -36,7 +36,7 @@ #include -MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $") +MODULE_ID("$Id: init_keytry.c,v 1.12 2008/05/24 21:44:51 tom Exp $") /* ** _nc_init_keytry() @@ -45,6 +45,13 @@ MODULE_ID("$Id: init_keytry.c,v 1.11 2008/05/03 23:09:15 tom Exp $") ** */ +/* + * Internal entrypoints use SCREEN* parameter to obtain capabilities rather + * than cur_term. + */ +#undef CUR +#define CUR (sp->_term)->type. + #if BROKEN_LINKER #undef _nc_tinfo_fkeys #endif diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c index 8fccc2f8..e1b4f942 100644 --- a/ncurses/tinfo/lib_cur_term.c +++ b/ncurses/tinfo/lib_cur_term.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc. * + * Copyright (c) 1998-2003,2008 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 * @@ -40,9 +40,17 @@ #include /* TTY, cur_term */ #include /* ospeed */ -MODULE_ID("$Id: lib_cur_term.c,v 1.13 2003/12/27 18:21:30 tom Exp $") +MODULE_ID("$Id: lib_cur_term.c,v 1.15 2008/05/24 23:11:18 tom Exp $") +#if USE_REENTRANT +NCURSES_EXPORT(TERMINAL *) +NCURSES_PUBLIC_VAR(cur_term) (void) +{ + return (SP != 0 && SP->_term != 0) ? SP->_term : _nc_prescreen._cur_term; +} +#else NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0; +#endif NCURSES_EXPORT(TERMINAL *) set_curterm(TERMINAL * termp) @@ -51,10 +59,18 @@ set_curterm(TERMINAL * termp) T((T_CALLED("set_curterm(%p)"), termp)); - if ((cur_term = termp) != 0) { - ospeed = _nc_ospeed(cur_term->_baudrate); + if (SP) + SP->_term = termp; +#if USE_REENTRANT + _nc_prescreen._cur_term = termp; +#else + cur_term = termp; +#endif + if (termp != 0) { + ospeed = _nc_ospeed(termp->_baudrate); PC = (pad_char != NULL) ? pad_char[0] : 0; } + T((T_RETURN("%p"), oldterm)); return (oldterm); } @@ -69,7 +85,7 @@ del_curterm(TERMINAL * termp) FreeIfNeeded(termp->_termname); free(termp); if (termp == cur_term) - cur_term = 0; + set_curterm(0); returnCode(OK); } returnCode(ERR); diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c index ba37e5dc..ff61d69a 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.43 2008/03/29 21:16:49 tom Exp $") +MODULE_ID("$Id: lib_data.c,v 1.44 2008/05/24 23:09:21 tom Exp $") /* * OS/2's native linker complains if we don't initialize public data when @@ -226,6 +226,7 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = { NULL, /* real_acs_map */ 0, /* LINES */ 0, /* COLS */ + 0, /* cur_term */ #ifdef TRACE 0L, /* _outchars */ NULL, /* _tputs_trace */ diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c index 98aae24b..ae6b2c5b 100644 --- a/ncurses/tinfo/lib_options.c +++ b/ncurses/tinfo/lib_options.c @@ -43,7 +43,10 @@ #include -MODULE_ID("$Id: lib_options.c,v 1.52 2008/05/03 23:09:20 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.55 2008/05/25 00:32:17 tom Exp $") + +static int _nc_curs_set(SCREEN *, int); +static int _nc_meta(SCREEN *, bool); NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) @@ -134,23 +137,11 @@ keypad(WINDOW *win, bool flag) NCURSES_EXPORT(int) meta(WINDOW *win GCC_UNUSED, bool flag) { - int result = ERR; + int result; /* Ok, we stay relaxed and don't signal an error if win is NULL */ T((T_CALLED("meta(%p,%d)"), win, flag)); - - if (SP != 0) { - SP->_use_meta = flag; - - if (flag && meta_on) { - TPUTS_TRACE("meta_on"); - putp(meta_on); - } else if (!flag && meta_off) { - TPUTS_TRACE("meta_off"); - putp(meta_off); - } - result = OK; - } + result = _nc_meta(SP, flag); returnCode(result); } @@ -159,43 +150,10 @@ meta(WINDOW *win GCC_UNUSED, bool flag) NCURSES_EXPORT(int) curs_set(int vis) { - int result = ERR; + int result; T((T_CALLED("curs_set(%d)"), vis)); - if (SP != 0 && vis >= 0 && vis <= 2) { - int cursor = SP->_cursor; - - if (vis == cursor) { - result = cursor; - } else { - result = (cursor == -1 ? 1 : cursor); - switch (vis) { - case 2: - if (cursor_visible) { - TPUTS_TRACE("cursor_visible"); - putp(cursor_visible); - } else - result = ERR; - break; - case 1: - if (cursor_normal) { - TPUTS_TRACE("cursor_normal"); - putp(cursor_normal); - } else - result = ERR; - break; - case 0: - if (cursor_invisible) { - TPUTS_TRACE("cursor_invisible"); - putp(cursor_invisible); - } else - result = ERR; - break; - } - SP->_cursor = vis; - _nc_flush(); - } - } + result = _nc_curs_set(SP, vis); returnCode(result); } @@ -239,6 +197,35 @@ has_key(int keycode) } #endif /* NCURSES_EXT_FUNCS */ +/* + * Internal entrypoints use SCREEN* parameter to obtain capabilities rather + * than cur_term. + */ +#undef CUR +#define CUR (sp->_term)->type. + +static int +_nc_putp(const char *name GCC_UNUSED, const char *value) +{ + int rc = ERR; + + if (value) { + TPUTS_TRACE(name); + rc = putp(value); + } + return rc; +} + +static int +_nc_putp_flush(const char *name, const char *value) +{ + int rc = _nc_putp(name, value); + if (rc != ERR) { + _nc_flush(); + } + return rc; +} + /* Turn the keypad on/off * * Note: we flush the output because changing this mode causes some terminals @@ -249,22 +236,92 @@ has_key(int keycode) NCURSES_EXPORT(int) _nc_keypad(SCREEN *sp, bool flag) { - if (flag && keypad_xmit) { - TPUTS_TRACE("keypad_xmit"); - putp(keypad_xmit); - _nc_flush(); - } else if (!flag && keypad_local) { - TPUTS_TRACE("keypad_local"); - putp(keypad_local); - _nc_flush(); - } + int rc = ERR; if (sp != 0) { - if (flag && !sp->_tried) { - _nc_init_keytry(sp); - sp->_tried = TRUE; +#ifdef USE_PTHREADS + /* + * We might have this situation in a multithreaded application that + * has wgetch() reading in more than one thread. putp() and below + * may use SP explicitly. + */ + if (sp != SP) { + SCREEN *save_sp; + + /* cannot use use_screen(), since that is not in tinfo library */ + _nc_lock_global(use_screen); + save_sp = SP; + SP = sp; + rc = _nc_keypad(sp, flag); + SP = save_sp; + _nc_unlock_global(use_screen); + } else +#endif + { + if (flag) { + (void) _nc_putp_flush("keypad_xmit", keypad_xmit); + } else if (!flag && keypad_local) { + (void) _nc_putp_flush("keypad_local", keypad_local); + } + + if (flag && !sp->_tried) { + _nc_init_keytry(sp); + sp->_tried = TRUE; + } + sp->_keypad_on = flag; + rc = OK; } - sp->_keypad_on = flag; } - return (OK); + return (rc); +} + +static int +_nc_curs_set(SCREEN *sp, int vis) +{ + int result = ERR; + + T((T_CALLED("curs_set(%d)"), vis)); + if (sp != 0 && vis >= 0 && vis <= 2) { + int cursor = sp->_cursor; + + if (vis == cursor) { + result = cursor; + } else { + switch (vis) { + case 2: + result = _nc_putp_flush("cursor_visible", cursor_visible); + break; + case 1: + result = _nc_putp_flush("cursor_normal", cursor_normal); + break; + case 0: + result = _nc_putp_flush("cursor_invisible", cursor_invisible); + break; + } + if (result != ERR) + result = (cursor == -1 ? 1 : cursor); + sp->_cursor = vis; + } + } + returnCode(result); +} + +static int +_nc_meta(SCREEN *sp, bool flag) +{ + int result = ERR; + + /* Ok, we stay relaxed and don't signal an error if win is NULL */ + + if (SP != 0) { + SP->_use_meta = flag; + + if (flag) { + _nc_putp("meta_on", meta_on); + } else { + _nc_putp("meta_off", meta_off); + } + result = OK; + } + return result; } diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c index 19984c92..891b6487 100644 --- a/ncurses/tty/lib_mvcur.c +++ b/ncurses/tty/lib_mvcur.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 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 * @@ -155,7 +155,7 @@ #include #include -MODULE_ID("$Id: lib_mvcur.c,v 1.110 2007/08/11 16:15:57 tom Exp $") +MODULE_ID("$Id: lib_mvcur.c,v 1.111 2008/05/24 14:36:54 Miroslav.Lichvar Exp $") #define WANT_CHAR(y, x) SP->_newscr->_line[y].text[x] /* desired state */ #define BAUDRATE cur_term->_baudrate /* bits per second */ @@ -426,8 +426,11 @@ _nc_mvcur_wrap(void) mvcur(-1, -1, screen_lines - 1, 0); /* set cursor to normal mode */ - if (SP->_cursor != -1) + if (SP->_cursor != -1) { + int cursor = SP->_cursor; curs_set(1); + SP->_cursor = cursor; + } if (exit_ca_mode) { TPUTS_TRACE("exit_ca_mode"); diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c index 6d460818..6973379a 100644 --- a/ncurses/tty/lib_twait.c +++ b/ncurses/tty/lib_twait.c @@ -62,7 +62,9 @@ # endif #endif -MODULE_ID("$Id: lib_twait.c,v 1.57 2008/05/03 21:35:57 tom Exp $") +#undef CUR + +MODULE_ID("$Id: lib_twait.c,v 1.58 2008/05/24 15:08:01 tom Exp $") static long _nc_gettime(TimeType * t0, bool first) diff --git a/test/rain.c b/test/rain.c index 411306a7..f4a5e7f3 100644 --- a/test/rain.c +++ b/test/rain.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: rain.c,v 1.33 2008/03/22 18:12:01 tom Exp $ + * $Id: rain.c,v 1.34 2008/05/24 23:34:34 tom Exp $ */ #include @@ -323,6 +323,7 @@ main(int argc GCC_UNUSED, last[j].x = random_x(); last[j].y = random_y(); } + j = 0; #endif while (!done) {