diff options
-rw-r--r-- | src/hanoi.lua | 3 | ||||
-rw-r--r-- | src/lcurseslib.c | 22 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/hanoi.lua b/src/hanoi.lua index 6a2311d..f3d08fa 100644 --- a/src/hanoi.lua +++ b/src/hanoi.lua @@ -36,8 +36,7 @@ end local function render(screen) screen:clear() - local lines = curses.lines() - local cols = curses.cols() + local lines, cols = screen:getmaxyx() local line = math.floor(lines/2) local col = math.floor(cols/4) for i,t in ipairs(tower) do diff --git a/src/lcurseslib.c b/src/lcurseslib.c index 3aeba75..baafbf5 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -109,11 +109,33 @@ static int Wclear (lua_State *L) { } +static int Wgetyx (lua_State *L) { + WINDOW *w = checkwin(L, 1); + int y, x; + getyx(w, y, x); + lua_pushinteger(L, y); + lua_pushinteger(L, x); + return 2; +} + + +static int Wgetmaxyx (lua_State *L) { + WINDOW *w = checkwin(L, 1); + int y, x; + getmaxyx(w, y, x); + lua_pushinteger(L, y); + lua_pushinteger(L, x); + return 2; +} + + static const luaL_Reg curses_window_methods[] = { {"__tostring", W__tostring}, {"addstr", Waddstr}, {"clear", Wclear}, + {"getmaxyx", Wgetmaxyx}, + {"getyx", Wgetyx}, {NULL, NULL} }; |