Fix saving/restoring tty modes, allow initscr be called twice,

from ncurses 4.1
This commit is contained in:
Andrey A. Chernov 1997-08-25 07:41:15 +00:00
parent 05c5fed8f5
commit 0e7e6efe8f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28698
5 changed files with 66 additions and 29 deletions

View File

@ -1,5 +1,5 @@
# Makefile for ncurses
# $Id: Makefile,v 1.21 1997/02/22 15:07:38 peter Exp $
# $Id: Makefile,v 1.22 1997/08/24 19:09:32 ache Exp $
LIB= ncurses
SHLIB_MAJOR= 3
@ -15,7 +15,7 @@ SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \
lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c
CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO
CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE
DPADD= ${LIBMYTINFO}
LDADD= -lmytinfo

View File

@ -119,6 +119,8 @@ sigaction_t act, oact;
if (SP->_endwin == TRUE) {
T(("coming back from shell mode"));
reset_prog_mode();
if (enter_ca_mode)
putp(enter_ca_mode);
/* is this necessary? */
if (enter_alt_charset_mode)
init_acs();
@ -143,19 +145,17 @@ sigaction_t act, oact;
if (curscr->_clear) { /* force refresh ? */
T(("clearing and updating curscr"));
ClrUpdate(curscr); /* yes, clear all & update */
ClrUpdate(newscr); /* yes, clear all & update */
curscr->_clear = FALSE; /* reset flag */
} else if (newscr->_clear) {
T(("clearing and updating newscr"));
ClrUpdate(newscr);
newscr->_clear = FALSE;
} else {
if (newscr->_clear) {
T(("clearing and updating newscr"));
ClrUpdate(newscr);
newscr->_clear = FALSE;
} else {
T(("Transforming lines"));
for (i = 0; i < lines ; i++) {
if(newscr->_firstchar[i] != _NOCHANGE)
TransformLine(i);
}
T(("Transforming lines"));
for (i = 0; i < lines ; i++) {
if(newscr->_firstchar[i] != _NOCHANGE)
TransformLine(i);
}
}
T(("marking screen as updated"));
@ -213,8 +213,8 @@ int lastNonBlank;
}
T(("updating screen from scratch"));
for (i = 0; i < lines; i++) {
lastNonBlank = columns - 1;
for (i = 0; i < min(lines, scr->_maxy + 1); i++) {
lastNonBlank = scr->_maxx;
while (lastNonBlank >= 0 && scr->_line[i][lastNonBlank] == BLANK)
lastNonBlank--;
@ -229,10 +229,9 @@ int lastNonBlank;
}
for (j = 0; j <= lastNonBlank; j++) {
if (parm_right_cursor) {
static int inspace = 0;
int inspace = 0;
T(("trying to use parm_right_cursor"));
if (parm_right_cursor) {
if ((scr->_line[i][j]) == BLANK) {
inspace++;
continue;
@ -241,6 +240,7 @@ int lastNonBlank;
for (; inspace > 0; inspace--)
PutChar(scr->_line[i][j-1]);
} else {
T(("trying to use parm_right_cursor"));
putp(tparm(parm_right_cursor, inspace));
SP->_curscol += inspace;
}

View File

@ -15,17 +15,26 @@
WINDOW *initscr()
{
static bool initialized = FALSE;
char *name;
#ifdef TRACE
_init_trace();
T(("initscr() called"));
#endif
if (newterm(getenv("TERM"), stdout, stdin) == NULL)
return NULL;
else {
def_shell_mode();
/* Portable applications must not call initscr() more than once */
if (!initialized) {
initialized = TRUE;
if ((name = getenv("TERM")) == 0)
name = "unknown";
if (newterm(name, stdout, stdin) == 0) {
fprintf(stderr, "Error opening terminal: %s.\n", name);
exit(1);
}
/* def_shell_mode - done in newterm */
def_prog_mode();
return(stdscr);
}
return(stdscr);
}

View File

@ -20,10 +20,27 @@
void tstp(int dummy)
{
sigaction_t act, oact;
sigset_t mask;
sigset_t mask, omask;
T(("tstp() called"));
/*
* The user may have changed the prog_mode tty bits, so save them.
*/
def_prog_mode();
/*
* Block window change and timer signals. The latter
* is because applications use timers to decide when
* to repaint the screen.
*/
(void)sigemptyset(&mask);
(void)sigaddset(&mask, SIGALRM);
#ifdef SIGWINCH
(void)sigaddset(&mask, SIGWINCH);
#endif
(void)sigprocmask(SIG_BLOCK, &mask, &omask);
endwin();
sigemptyset(&mask);
@ -41,10 +58,21 @@ sigset_t mask;
T(("SIGCONT received"));
sigaction(SIGTSTP, &oact, NULL);
reset_prog_mode();
flushinp();
if (enter_ca_mode)
putp(enter_ca_mode);
/*
* If the user modified the tty state while suspended, he wants
* those changes to stick. So save the new "default" terminal state.
*/
def_shell_mode();
/*
* This relies on the fact that doupdate() will restore the
* program-mode tty state, and issue enter_ca_mode if need be.
*/
doupdate();
/* Reset the signals. */
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
}

View File

@ -1,5 +1,5 @@
# Makefile for ncurses
# $Id: Makefile,v 1.21 1997/02/22 15:07:38 peter Exp $
# $Id: Makefile,v 1.22 1997/08/24 19:09:32 ache Exp $
LIB= ncurses
SHLIB_MAJOR= 3
@ -15,7 +15,7 @@ SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \
lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c
CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO
CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE
DPADD= ${LIBMYTINFO}
LDADD= -lmytinfo