11 SCREEN* luacurses_toscreen(lua_State* L, int index)
13 SCREEN** pscreen = (SCREEN**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_SCREEN);
14 if (!pscreen) luaL_argerror(L, index, "bad screen");
15 if (!*pscreen) luaL_error(L, "attempt to use invalid screen");
19 SCREEN** luacurses_newscreen(lua_State* L)
21 SCREEN** pscreen = (SCREEN**) lua_newuserdata(L, sizeof(SCREEN*));
23 luaL_getmetatable(L, MKLUALIB_META_CURSES_SCREEN);
24 lua_setmetatable(L, -2);
28 void luacurses_regscreen(lua_State* L, const char* name, SCREEN* userdata)
30 lua_pushstring(L, name);
31 SCREEN** pscreen = luacurses_newscreen(L);
36 WINDOW* luacurses_towindow(lua_State* L, int index)
38 WINDOW** pwindow = (WINDOW**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_WINDOW);
39 if (!pwindow) luaL_argerror(L, index, "bad window");
40 if (!*pwindow) luaL_error(L, "attempt to use invalid window");
44 WINDOW** luacurses_newwindow(lua_State* L)
46 WINDOW** pwindow = (WINDOW**) lua_newuserdata(L, sizeof(WINDOW*));
48 luaL_getmetatable(L, MKLUALIB_META_CURSES_WINDOW);
49 lua_setmetatable(L, -2);
53 void luacurses_regwindow(lua_State* L, const char* name, WINDOW* userdata)
55 lua_pushstring(L, name);
56 WINDOW** pwindow = luacurses_newwindow(L);
61 FILE* tofile(lua_State* L, int index)
63 FILE** pf = (FILE**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_FILE);
64 if (!pf) luaL_argerror(L, index, "bad file");
65 if (!*pf) luaL_error(L, "attempt to use invalid file");
69 FILE** newfile(lua_State* L)
71 FILE** pf = (FILE**) lua_newuserdata(L, sizeof(FILE*));
73 luaL_getmetatable(L, MKLUALIB_META_CURSES_FILE);
74 lua_setmetatable(L, -2);
78 void luacurses_regfile(lua_State* L, const char* name, FILE* f)
80 lua_pushstring(L, name);
81 FILE** pf = newfile(L);
86 char* luacurses_wgetnstr(WINDOW* w, int n)
88 char* s = (char*) malloc(n + 1);
93 char* luacurses_window_tostring(WINDOW* w)
95 char* buf = (char*) malloc(64);
96 sprintf(buf, "window %p", w);
100 char* luacurses_screen_tostring(SCREEN* s)
102 char* buf = (char*) malloc(64);
103 sprintf(buf, "screen %p", s);
107 bool luacurses_getmouse(short* id, int* x, int* y, int* z, mmask_t* bstate)
110 int res = getmouse(&e);
120 bool luacurses_ungetmouse (short id, int x, int y, int z, mmask_t bstate)
128 return (ungetmouse(&e) == OK);
131 mmask_t luacurses_addmousemask(mmask_t m)
135 return mousemask(old | m, 0);