window:getmaxyx()

This commit is contained in:
Kartik K. Agaram 2021-11-05 12:25:31 -07:00
parent 595a963671
commit a4ce7ffbd0
2 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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}
};