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.
This commit is contained in:
parent
520cc09997
commit
057f4a2870
12
anagrams.tlv
12
anagrams.tlv
|
@ -228,6 +228,7 @@
|
||||||
- __teliva_timestamp: original
|
- __teliva_timestamp: original
|
||||||
main:
|
main:
|
||||||
>function main()
|
>function main()
|
||||||
|
> Window:nodelay(true)
|
||||||
> while true do
|
> while true do
|
||||||
> render(Window)
|
> render(Window)
|
||||||
> update(Window)
|
> update(Window)
|
||||||
|
@ -236,7 +237,11 @@
|
||||||
- __teliva_timestamp: original
|
- __teliva_timestamp: original
|
||||||
update:
|
update:
|
||||||
>function update(window)
|
>function update(window)
|
||||||
> local key = window:getch()
|
> local key
|
||||||
|
> while true do
|
||||||
|
> key = window:getch()
|
||||||
|
> if key then break end
|
||||||
|
> end
|
||||||
> if key == curses.KEY_LEFT then
|
> if key == curses.KEY_LEFT then
|
||||||
> if cursor > 1 then
|
> if cursor > 1 then
|
||||||
> cursor = cursor-1
|
> cursor = cursor-1
|
||||||
|
@ -277,6 +282,11 @@
|
||||||
> for i, w in ipairs(results) do
|
> for i, w in ipairs(results) do
|
||||||
> window:addstr(w)
|
> window:addstr(w)
|
||||||
> window:addstr(' ')
|
> window:addstr(' ')
|
||||||
|
> local tmp = window:getch()
|
||||||
|
> if tmp then
|
||||||
|
> window:ungetch(tmp)
|
||||||
|
> break
|
||||||
|
> end
|
||||||
> end
|
> end
|
||||||
> end
|
> end
|
||||||
>
|
>
|
||||||
|
|
|
@ -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}
|
Call @{move} then @{getch}
|
||||||
@function mvgetch
|
@function mvgetch
|
||||||
|
@ -1893,6 +1912,7 @@ static const luaL_Reg curses_window_fns[] =
|
||||||
LCURSES_FUNC( Wtimeout ),
|
LCURSES_FUNC( Wtimeout ),
|
||||||
LCURSES_FUNC( Wtouch ),
|
LCURSES_FUNC( Wtouch ),
|
||||||
LCURSES_FUNC( Wtouchline ),
|
LCURSES_FUNC( Wtouchline ),
|
||||||
|
LCURSES_FUNC( Wungetch ),
|
||||||
LCURSES_FUNC( Wvline ),
|
LCURSES_FUNC( Wvline ),
|
||||||
LCURSES_FUNC( Wwbkgd ),
|
LCURSES_FUNC( Wwbkgd ),
|
||||||
LCURSES_FUNC( Wwbkgdset ),
|
LCURSES_FUNC( Wwbkgdset ),
|
||||||
|
|
Loading…
Reference in New Issue