From 96587d2acfe8a6d5395c80bb78a08256f894f52b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 8 Mar 2023 12:16:43 +0200 Subject: [PATCH] Fix curses quitting when trying to move parse_escape_sequence changed getch timeout, but when receiving a certain escape sequence, it returned without changing the timeout back. This caused all subsequent getch calls be non-blocking, and getch returns ERR when there's no input waiting in that mode. NetHack interprets ERR as the terminal going away, so performs an automatic save. --- win/curses/cursmisc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index d312208cc..bc3db49af 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -1073,8 +1073,10 @@ parse_escape_sequence(void) if (ret == 'O') { /* Numeric keypad */ /* ESC O */ ret = getch(); - if (ret >= 112 && ret <= 121) + if (ret >= 112 && ret <= 121) { + timeout(-1); return ret - 112 + '0'; /* Convert to number */ + } if (ret == ERR) ret = 'O'; /* there was no third char; treat as ESC O below */