about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hanoi.lua9
-rw-r--r--src/lcurseslib.c13
2 files changed, 17 insertions, 5 deletions
diff --git a/src/hanoi.lua b/src/hanoi.lua
index d8c6cb6..f3d08fa 100644
--- a/src/hanoi.lua
+++ b/src/hanoi.lua
@@ -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
 
 
diff --git a/src/lcurseslib.c b/src/lcurseslib.c
index e32ce31..85ef62a 100644
--- a/src/lcurseslib.c
+++ b/src/lcurseslib.c
@@ -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},