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
+11 -9
View File
@@ -45,16 +45,17 @@ typedef struct tty_mi {
/* descriptor for tty-based windows */
struct WinDesc {
int flags; /* window flags */
xint16 type; /* type of window */
boolean active; /* true if window is active */
short offx, offy; /* offset from topleft of display */
long rows, cols; /* dimensions */
long curx, cury; /* current cursor position */
long maxrow, maxcol; /* the maximum size used -- for MENU wins */
int flags; /* window flags */
xint16 type; /* type of window */
boolean active; /* true if window is active */
boolean blanked; /* for erase_tty_screen(); not used [yet?] */
short offx, offy; /* offset from topleft of display */
long rows, cols; /* dimensions */
long curx, cury; /* current cursor position */
long maxrow, maxcol; /* the maximum size used -- for MENU wins;
* maxcol is also used by WIN_MESSAGE for
* tracking the ^P command */
unsigned long mbehavior; /* menu behavior flags (MENU) */
/* maxcol is also used by WIN_MESSAGE for */
/* tracking the ^P command */
short *datlen; /* allocation size for *data */
char **data; /* window data [row][column] */
char *morestr; /* string to display instead of default */
@@ -218,6 +219,7 @@ E void g_putch(int);
E void g_pututf8(uint8 *);
#endif
#endif /* ENHANCED_SYMBOLS */
extern void erase_tty_screen(void);
E void win_tty_init(int);
/* external declarations */