stdscr binding

print(curses.stdscr())
print(curses:stdscr())
This commit is contained in:
Kartik K. Agaram 2021-11-05 10:51:47 -07:00
parent 8552ad4ced
commit f761d0ae36
1 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,13 @@
#include "lualib.h"
static int Pstdscr(lua_State *L) {
lua_pushstring(L, "curses:stdscr");
lua_rawget(L, LUA_REGISTRYINDEX);
return 1;
}
static int Pcols(lua_State *L) {
lua_pushinteger(L, COLS);
return 1;
@ -14,6 +21,7 @@ static int Pcols(lua_State *L) {
static const struct luaL_Reg curseslib [] = {
{"cols", Pcols},
{"stdscr", Pstdscr},
{NULL, NULL}
};
@ -34,7 +42,11 @@ static void curses_newwin (lua_State *L, WINDOW *nw) {
LUALIB_API int luaopen_curses (lua_State *L) {
luaL_register(L, "curses", curseslib);
/* save main window on registry */
curses_newwin(L, stdscr);
lua_pushstring(L, "curses:stdscr");
lua_pushvalue(L, -2);
lua_rawset(L, LUA_REGISTRYINDEX);
return 1;
}