oh, that's just a cosmetic thing

So why isn't this working?
  a = curses:stdscr()
  a:addstr(abc)

The error is "attempt to index global 'a' (a userdata value)"
This commit is contained in:
Kartik K. Agaram 2021-11-05 12:00:02 -07:00
parent f2d61064fb
commit ac6c9319f9
1 changed files with 13 additions and 0 deletions

View File

@ -81,6 +81,18 @@ static int optint (lua_State *L, int narg, lua_Integer def) {
}
static int W__tostring (lua_State *L) {
WINDOW **w = lc_getwin(L, 1);
char buff[34];
if (*w == NULL)
strcpy(buff, "closed");
else
sprintf(buff, "%p", lua_touserdata(L, 1));
lua_pushfstring(L, "curses window (%s)", buff);
return 1;
}
static int Waddstr (lua_State *L) {
WINDOW *w = checkwin(L, 1);
const char *str = luaL_checkstring(L, 2);
@ -92,6 +104,7 @@ static int Waddstr (lua_State *L) {
static const luaL_Reg curses_window_methods[] =
{
{"__tostring", W__tostring},
{"addstr", Waddstr},
{NULL, NULL}
};