diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-05 12:00:02 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-05 12:00:37 -0700 |
commit | ac6c9319f9af3e5d047842b78859980184699d77 (patch) | |
tree | 2bdf60c50bf6f675bd0c05a1ad5bfd44aef74b88 /src | |
parent | f2d61064fb675bd3cf2249ee71e76f19132b2b11 (diff) | |
download | teliva-ac6c9319f9af3e5d047842b78859980184699d77.tar.gz |
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)"
Diffstat (limited to 'src')
-rw-r--r-- | src/lcurseslib.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lcurseslib.c b/src/lcurseslib.c index 683d418..042c7d8 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -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} }; |