window:getch()

But how do we get curses.getch() to work?
I don't see it implemented in lcurses.
This commit is contained in:
Kartik K. Agaram 2021-11-05 13:23:14 -07:00
parent 14b16003b1
commit 44258f7657
2 changed files with 17 additions and 5 deletions

View File

@ -65,11 +65,10 @@ end
local function main()
local screen = curses.stdscr()
render(screen)
--? while true do
--? render(screen)
--? update(screen)
--? end
while true do
render(screen)
update(screen)
end
end

View File

@ -135,6 +135,18 @@ static int Wclear (lua_State *L) {
}
static int Wgetch (lua_State *L) {
WINDOW *w = checkwin(L, 1);
int c = wgetch(w);
if (c == ERR)
return 0;
lua_pushinteger(L, c);
return 1;
}
static int Wgetyx (lua_State *L) {
WINDOW *w = checkwin(L, 1);
int y, x;
@ -183,6 +195,7 @@ static const luaL_Reg curses_window_methods[] =
{"attroff", Wattroff},
{"attron", Wattron},
{"clear", Wclear},
{"getch", Wgetch},
{"getmaxyx", Wgetmaxyx},
{"getyx", Wgetyx},
{"mvaddch", Wmvaddch},