about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-05 09:47:47 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-03-05 09:47:47 -0800
commit057f4a2870188bfdbdc59b3f16f3b3b4fb3a4304 (patch)
treec12d7781eef5a178764d6fbbb9861df735e0405d /src
parent520cc099971584913e8b8eca811849c7e2e6ce67 (diff)
downloadteliva-057f4a2870188bfdbdc59b3f16f3b3b4fb3a4304.tar.gz
anagrams.tlv: slightly more responsive
Now we cancel screen-painting if any key is pressed.

However it looks like just computing the list of anagrams can take a
long time.
Diffstat (limited to 'src')
-rw-r--r--src/lcurses/window.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lcurses/window.c b/src/lcurses/window.c
index 02fccb2..e3fcc70 100644
--- a/src/lcurses/window.c
+++ b/src/lcurses/window.c
@@ -1361,6 +1361,25 @@ Wgetch(lua_State *L)
 
 
 /***
+Put back a character obtained from @{getch}
+@function ungetch
+@int ch
+@treturn OK or ERR
+@see mvwgetch(3x)
+@see getch
+*/
+static int
+Wungetch(lua_State *L)
+{
+	int ch = checkint(L, 2);
+	int result = ungetch(ch);
+	if (result == ERR)
+		return 0;
+	return pushintresult(result);
+}
+
+
+/***
 Call @{move} then @{getch}
 @function mvgetch
 @int y
@@ -1893,6 +1912,7 @@ static const luaL_Reg curses_window_fns[] =
 	LCURSES_FUNC( Wtimeout		),
 	LCURSES_FUNC( Wtouch		),
 	LCURSES_FUNC( Wtouchline	),
+	LCURSES_FUNC( Wungetch		),
 	LCURSES_FUNC( Wvline		),
 	LCURSES_FUNC( Wwbkgd		),
 	LCURSES_FUNC( Wwbkgdset		),