about summary refs log tree commit diff stats
path: root/src/lcurses
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-05 14:44:37 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-03-05 14:44:37 -0800
commit5530995188a4e094f1f29e208271524a08d0426f (patch)
treed31712ca05bb77ba18098f79d3c28cd7e65fe7a1 /src/lcurses
parentf72340cc372babac08f89bdda1c589c45a7396fd (diff)
downloadteliva-5530995188a4e094f1f29e208271524a08d0426f.tar.gz
reliably exit on confirmation
Until now you had to press ctrl-x twice in rapid succession to exit if
an app turned on non-blocking keyboard with nodelay(true). This became
particularly noticeable after the previous change to anagrams.tlv, which
could no longer exit.
Diffstat (limited to 'src/lcurses')
-rw-r--r--src/lcurses/window.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lcurses/window.c b/src/lcurses/window.c
index e3fcc70..4ab3ad4 100644
--- a/src/lcurses/window.c
+++ b/src/lcurses/window.c
@@ -1343,7 +1343,11 @@ Wgetch(lua_State *L)
 		color_set(COLOR_PAIR_NORMAL, NULL);
 		attroff(A_BOLD|A_REVERSE);
 
-		if (wgetch(w) != c)
+		int secondc;
+		do  /* just in case getch is currently non-blocking (nodelay) */
+			secondc = wgetch(w);
+		while(secondc == ERR);
+		if (c != secondc)
 			return pushintresult(0);
 
 		if (c == CTRL_X) {