diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-12-13 16:10:08 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-12-13 16:10:08 +1100 |
| commit | 64b106c13e18c33be0f2b0de532054e0ed3f731d (patch) | |
| tree | b54b1c90d941bc456b4d51e864970720bdf2d648 /lib/lua-term/core.c | |
| parent | 5a2f0b08e0e3f20cda977b510b680d5843ae7283 (diff) | |
| download | tangara-fw-64b106c13e18c33be0f2b0de532054e0ed3f731d.tar.gz | |
add a cool lua repl
Diffstat (limited to 'lib/lua-term/core.c')
| -rw-r--r-- | lib/lua-term/core.c | 27 |
1 files changed, 27 insertions, 0 deletions
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 <lua.h> +#include <lauxlib.h> +#include <lualib.h> +#ifndef _MSC_VER +# include <unistd.h> +#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; +} |
