window:getmaxyx()
This commit is contained in:
parent
595a963671
commit
a4ce7ffbd0
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue