/****************************************************************************
- * 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 *
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.65 2007/03/10 23:39:27 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.71 2008/06/21 20:55:11 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
* aside from possibly delaying a filter() call until some terminals have been
* initialized.
*/
-static bool filter_mode = FALSE;
-
NCURSES_EXPORT(void)
filter(void)
{
START_TRACE();
T((T_CALLED("filter")));
- filter_mode = TRUE;
+ _nc_prescreen.filter_mode = TRUE;
returnVoid;
}
{
START_TRACE();
T((T_CALLED("nofilter")));
- filter_mode = FALSE;
+ _nc_prescreen.filter_mode = FALSE;
returnVoid;
}
#endif
{
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_lock_global(curses);
+
+ current = SP;
+ its_term = (SP ? SP->_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);
/* allow user to set maximum escape delay from the environment */
if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
-#if USE_REENTRANT
- SP->_ESCDELAY = value;
-#else
- ESCDELAY = value;
-#endif
+ set_escdelay(value);
}
- if (_nc_setupscreen(LINES, COLS, ofp, filter_mode, slk_format) == ERR) {
+ if (_nc_setupscreen(LINES,
+ COLS,
+ ofp,
+ _nc_prescreen.filter_mode,
+ slk_format) == ERR) {
_nc_set_screen(current);
result = 0;
} else {
+ /*
+ * 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);
result = SP;
}
}
- _nc_handle_sigwinch(1);
+ _nc_unlock_global(curses);
returnSP(result);
}