redo tty resizing

Rest of 'not PR #1102'.  Resizing the terminal while getpos was in
operation recalculated the map from scratch instead of redrawing what
the core considers to already be shown.  And it was always operating
while an asynchronous signal was excuting which could potentially
clobber whatever was running at the time the signal arrived.

This uses same redrawing as the prior '^R during getpos()' fix.  It
also only performs the resize while tty_nhgetch() is waiting for
input.  If that is the situation at the time that the signal arrives
then it will resize immediately (while in the asynchronous signal
handler); if not, it will set a flag and tty_nhgetch() will do the
resize the next time it gets called.

This builds with TTY_PERM_INVENT enabled and doesn't seem to be any
worse than before, but there are bugs with that.  The only way I could
get perminv to appear was to save and restore, then perm_invent was
honored for both RC file and mO command.  And once I managed to get it
to display, moving an item from a lower case slot to slot 'A', made
that item vanish; nothing appeared in the invent's right hand panel.

Both of those misbehaviors already happen prior to this commit.  I
also saw an abort+panictrace if I resized while at the "Dump core?"
prompt when running the pre-commit code and didn't see that with the
post-commit code (although the prompt wasn't shown so I couldn't tell
that it was waiting for an answer).  The abort probably sounds scarier
than it warrants; I suspect that the pre-commit code just treated the
resize as answering 'y' for some reason, possibly a stale value in the
variable it uses.
This commit is contained in:
PatR
2023-10-12 18:45:14 -07:00
parent f70f84aee7
commit 284452796c
10 changed files with 318 additions and 152 deletions

View File

@@ -582,6 +582,23 @@ VA_DECL(const char *, s)
#endif
exit(EXIT_FAILURE);
}
#ifdef SIGWINCH
/* called by resize_tty(wintty.c) after receiving a SIGWINCH signal;
terminal size has changed and we should update LI and CO (from termcap) */
void
getwindowsz(void)
{
/*
* gettty() has code to do this, but it can't be used directly because
* it fetches terminal state in order to reset that upon termination.
* We need to avoid clobbering other saved state with values used by
* game-in-progress. For now, do nothing.
*/
return;
}
#endif
#ifdef ENHANCED_SYMBOLS
/*
* set in tty_start_screen() and allows
@@ -592,6 +609,8 @@ VA_DECL(const char *, s)
void
tty_utf8graphics_fixup(void)
{
return;
}
#endif /* ENHANCED_SYMBOLS */
/*vmstty.c */