curses on unix - terminal reset needed after abort

Noticed while investigating the message loop.  If I had level files
from an interrupted game and was asked "Destroy old game?" when
starting a new one, answering 'n' left the terminal in an unusable
state.  Executing 'stty sane' (invisibly since input echo was off)
repaired things but the user shouldn't have to do that.

Change unixtty.c's error() to shut down windowing if that has been
initialized.  This might need some tweaking for tty, which will now
clear the screen before showing the startup error message.  Other
systems besides unix use unixtty.c so are affected, but I think the
change doesn't introduce anything that should cause trouble (aside
from the potential screen erasure).
This commit is contained in:
PatR
2019-10-09 13:18:34 -07:00
parent bab05ea680
commit e4f3559acc
2 changed files with 10 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.126 $ $NHDT-Date: 1570408209 2019/10/07 00:30:09 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.128 $ $NHDT-Date: 1570652307 2019/10/09 20:18:27 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -210,8 +210,6 @@ tty: revert the attempt to fix "message line anomaly: if autodecribe feedback
wrapped to second line, the wrapped portion wasn't erased when a
shorter line was shown or getpos was dismissed" because it disrupted
prompts that spanned more than one line, a more significant issue
unix: sysconf CHECK_PLNAME=1 wouldn't work if attempt to obtain unix username
failed even though it didn't need that username
Platform- and/or Interface-Specific Fixes or Features
@@ -302,6 +300,10 @@ tty: take two, if/when autodecribe feedback wraps past top line, clear
['exposed by git' section has an entry for reversal of 'take one']
tty: video attributes (bold, inverse, &c) for status highlighting sometimes
were scrambled
unix: sysconf CHECK_PLNAME=1 wouldn't work if attempt to obtain unix username
failed even though it didn't need that username
unix+curses: startup error only reset terminal for tty; one noticeable
example was answering 'n' to "Destroy old game?"
Windows: some startup error messages were not being delivered successfully

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 unixtty.c $NHDT-Date: 1548372343 2019/01/24 23:25:43 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.6 unixtty.c $NHDT-Date: 1570652308 2019/10/09 20:18:28 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.26 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -243,6 +243,7 @@ const char *s;
iflags.cbreak = (CBRKON(inittyb.cbrkflgs & CBRKMASK)) ? ON : OFF;
curttyb.inputflags |= STRIPHI;
setioctls();
settty_needed = FALSE;
}
void
@@ -471,6 +472,9 @@ VA_DECL(const char *, s)
{
VA_START(s);
VA_INIT(s, const char *);
if (iflags.window_inited)
exit_nhwindows((char *) 0); /* for tty, will call settty() */
if (settty_needed)
settty((char *) 0);
Vprintf(s, VA_ARGS);