From a1fad59f2d6a830d8e32c6976a1595cab0e6519c Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 22 May 2026 12:24:32 -0400 Subject: [PATCH] idlecheckpoint support in curses --- include/config.h | 1 + win/curses/cursmisc.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/config.h b/include/config.h index 4fcc892e0..21556bcc4 100644 --- a/include/config.h +++ b/include/config.h @@ -690,6 +690,7 @@ typedef unsigned char uchar; * Currently has support in: * WIN32CON * Qt + * curses */ /* #define IDLECHECKPOINT */ diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 3084d193a..e085d54d3 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -34,16 +34,41 @@ int curses_getch(void) { int ch; + boolean timeoutset = FALSE; - if (iflags.debug_fuzzer) + if (iflags.debug_fuzzer) { ch = randomkey(); - else + } else if (iflags.idlecheckpoint) { + boolean done_a_checkpoint = FALSE; + + done_a_checkpoint = FALSE; + timeout(IDLECHECKPOINT_WAIT_TIME * 1000); + timeoutset = TRUE; + + while (1) { + ch = getch(); + if (ch == ERR && !done_a_checkpoint) { +#ifdef INSURANCE + save_currentstate(); +#endif /* INSURANCE */ + done_a_checkpoint = TRUE; + timeout(-1); + timeoutset = FALSE; + } else { + if (timeoutset) { + timeout(-1); + timeoutset = FALSE; + } + break; + } + } + } else { ch = getch(); + } return ch; } /* Read a character of input from the user */ - int curses_read_char(void) {