From 64b106c13e18c33be0f2b0de532054e0ed3f731d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 13 Dec 2023 16:10:08 +1100 Subject: add a cool lua repl --- lib/lua-term/core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/lua-term/core.c (limited to 'lib/lua-term/core.c') diff --git a/lib/lua-term/core.c b/lib/lua-term/core.c new file mode 100644 index 00000000..7a144086 --- /dev/null +++ b/lib/lua-term/core.c @@ -0,0 +1,27 @@ +#define _POSIX_C_SOURCE 200112L + +#include +#include +#include +#ifndef _MSC_VER +# include +#endif + +static int +lua_isatty(lua_State *L) +{ + FILE **fp = (FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE); + + lua_pushboolean(L, isatty(fileno(*fp))); + return 1; +} + +int +luaopen_term_core(lua_State *L) +{ + lua_newtable(L); + lua_pushcfunction(L, lua_isatty); + lua_setfield(L, -2, "isatty"); + + return 1; +} -- cgit v1.2.3