From b20dbd285f508047a13b2ebd928eeb7fc49d7d31 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Wed, 19 Mar 2008 12:33:30 -0500 Subject: implement ungetch --- TODO | 2 +- src/curses.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index dce7e9d..af5f36f 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ - chtype arrays (curs_addchstr, curs_inchstr) - the point of these routines is that they are more efficient, since you pass in an array of chtypes rather than an array of chars. how can i expose this functionality? - reading from the screen (curs_instr, curs_inch) -- reading input (ungetch (curs_getch), curs_getstr +- reading input (curs_getstr) - attribute support (curs_attr) - finish up curs_color (color_content, pair_content) - scrolling support (curs_scroll, setscrreg (curs_outopts)) diff --git a/src/curses.c b/src/curses.c index 6eb2066..07814bc 100644 --- a/src/curses.c +++ b/src/curses.c @@ -443,6 +443,18 @@ static int l_getch(lua_State* L) return 1; } +static int l_ungetch(lua_State* L) +{ + const char* ch_str; + int ch; + + ch_str = luaL_checklstring(L, 1, NULL); + ch = get_key_enum(ch_str); + + lua_pushboolean(L, ungetch(ch) == OK); + return 1; +} + static int l_move(lua_State* L) { pos p; @@ -674,6 +686,7 @@ const luaL_Reg reg[] = { { "init_color", l_init_color }, { "init_pair", l_init_pair }, { "getch", l_getch }, + { "ungetch", l_ungetch }, { "move", l_move }, { "addch", l_addch }, { "echochar", l_echochar }, -- cgit v1.2.3-54-g00ecf