/*
* Copyright (c) 1981, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
if ((new_screen = calloc(1, sizeof(SCREEN))) == NULL)
return NULL;
__CTRACE(__CTRACE_INIT, "newterm\n");
new_screen->infd = infd;
/*
* POSIX standard says this should be set to infd by default,
* but this seems to break nvi by leaving an unrefreshed screen.
* Also, the line breakout optimisation advertised in ncurses
* doesn't actually do anything, so explicitly disabling it here makes
* sense for the time being.
* A caller can always enable it by calling typeahead(3) anyway.
*/
new_screen->checkfd = -1; // fileno(infd);
new_screen->outfd = outfd;
new_screen->echoit = new_screen->nl = 1;
new_screen->pfast = new_screen->rawmode = new_screen->noqch = 0;
new_screen->filtered = filtered;
filtered = FALSE; /* filter() must precede each newterm() */
new_screen->nca = A_NORMAL;
new_screen->color_type = COLOR_NONE;
new_screen->COLOR_PAIRS = 0;
new_screen->curpair = -1;
new_screen->old_mode = 1;
new_screen->stdbuf = NULL;
new_screen->stdscr = NULL;
new_screen->curscr = NULL;
new_screen->__virtscr = NULL;
new_screen->curwin = 0;
new_screen->notty = FALSE;
new_screen->resized = 0;
new_screen->unget_len = 32;
/*
* bleh - it seems that apps expect the first newterm to set
* up the curses screen.... emulate this.
*/
if (_cursesi_screen == NULL || _cursesi_screen->endwin) {
set_term(new_screen);
}
/* free up the terminfo stuff */
if (screen->term != NULL)
del_curterm(screen->term);
/* walk the window list and kill all the parent windows */
while ((list = screen->winlistp) != NULL) {
delwin(list->winp);
if (list == screen->winlistp)
/* sanity - abort if window didn't remove itself */
break;
}
}