X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_newterm.c;h=11397fba6629ebd5b37c846c7b1f745c0863334a;hp=fe201d6b8e27054570510fe736c7a549a6e77f27;hb=26522e4669dbf45cba32138b5d81c6c292e88e60;hpb=027ae42953e3186daed8f3882da73de48291b606 diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c index fe201d6b..11397fba 100644 --- a/ncurses/base/lib_newterm.c +++ b/ncurses/base/lib_newterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2006 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 * @@ -30,6 +30,7 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * ****************************************************************************/ /* @@ -45,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.64 2006/01/14 15:36:24 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 @@ -94,65 +99,103 @@ _nc_initscr(void) * aside from possibly delaying a filter() call until some terminals have been * initialized. */ -static bool filter_mode = FALSE; - NCURSES_EXPORT(void) -filter(void) +NCURSES_SP_NAME(filter) (NCURSES_SP_DCL0) { START_TRACE(); T((T_CALLED("filter"))); - filter_mode = TRUE; + _nc_prescreen.filter_mode = TRUE; returnVoid; } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +filter(void) +{ + NCURSES_SP_NAME(filter) (CURRENT_SCREEN); +} +#endif + #if NCURSES_EXT_FUNCS /* * An extension, allowing the application to open a new screen without * requiring it to also be filtered. */ NCURSES_EXPORT(void) -nofilter(void) +NCURSES_SP_NAME(nofilter) (NCURSES_SP_DCL0) { START_TRACE(); T((T_CALLED("nofilter"))); - filter_mode = FALSE; + _nc_prescreen.filter_mode = FALSE; returnVoid; } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(void) +nofilter(void) +{ + NCURSES_SP_NAME(nofilter) (CURRENT_SCREEN); +} #endif +#endif /* NCURSES_EXT_FUNCS */ NCURSES_EXPORT(SCREEN *) -newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) +NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx + NCURSES_CONST char *name, + FILE *ofp, + FILE *ifp) { int value; int errret; - int slk_format = _nc_slk_format; SCREEN *current; SCREEN *result = 0; + TERMINAL *its_term; START_TRACE(); T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp)); - _nc_handle_sigwinch(0); + _nc_init_pthreads(); + _nc_lock_global(curses); - /* allow user to set maximum escape delay from the environment */ - if ((value = _nc_getenv_num("ESCDELAY")) >= 0) { - ESCDELAY = value; - } + current = SP_PARM; + its_term = (SP_PARM ? SP_PARM->_term : 0); /* this loads the capability entry, then sets LINES and COLS */ - if (setupterm(name, fileno(ofp), &errret) == ERR) { - result = 0; - } else { + if (setupterm(name, fileno(ofp), &errret) != ERR) { + int slk_format = _nc_globals.slk_format; + /* * This actually allocates the screen structure, and saves the original * terminal settings. */ - current = SP; _nc_set_screen(0); - if (_nc_setupscreen(LINES, COLS, ofp, filter_mode, slk_format) == ERR) { + + /* allow user to set maximum escape delay from the environment */ + if ((value = _nc_getenv_num("ESCDELAY")) >= 0) { + set_escdelay(value); + } + + if (_nc_setupscreen(LINES, + COLS, + ofp, + _nc_prescreen.filter_mode, + slk_format) == ERR) { _nc_set_screen(current); result = 0; } else { + assert(SP_PARM != 0); + /* + * In setupterm() we did a set_curterm(), but it was before we set + * SP. So the "current" screen's terminal pointer was overwritten + * with a different terminal. Later, in _nc_setupscreen(), we set + * SP and the terminal pointer in the new screen. + * + * Restore the terminal-pointer for the pre-existing screen, if + * any. + */ + if (current) + current->_term = its_term; + /* if the terminal type has real soft labels, set those up */ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format)) _nc_slk_initialize(stdscr, COLS); @@ -211,6 +254,14 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) result = SP; } } - _nc_handle_sigwinch(1); + _nc_unlock_global(curses); returnSP(result); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(SCREEN *) +newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp) +{ + return NCURSES_SP_NAME(newterm) (CURRENT_SCREEN, name, ofp, ifp); +} +#endif