From e4f3559acc2e56eec552ce635f486888364d7e25 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 9 Oct 2019 13:18:34 -0700 Subject: [PATCH] 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). --- doc/fixes36.3 | 8 +++++--- sys/share/unixtty.c | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 71572a441..49c49674c 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -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 diff --git a/sys/share/unixtty.c b/sys/share/unixtty.c index dafbc8f44..3196f3b3d 100644 --- a/sys/share/unixtty.c +++ b/sys/share/unixtty.c @@ -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);