From 057f4a2870188bfdbdc59b3f16f3b3b4fb3a4304 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 5 Mar 2022 09:47:47 -0800 Subject: 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. --- src/lcurses/window.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/lcurses/window.c') 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 @@ -1360,6 +1360,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 @@ -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 ), -- cgit 1.4.1-2-gfad0