diff options
Diffstat (limited to 'core.c')
-rw-r--r-- | core.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ | |||
1 | #include <lua.h> | ||
2 | #include <lauxlib.h> | ||
3 | #include <lualib.h> | ||
4 | |||
5 | static int | ||
6 | lua_isatty(lua_State *L) | ||
7 | { | ||
8 | FILE *fp = (FILE *) luaL_checkudata(L, -1, LUA_FILEHANDLE); | ||
9 | |||
10 | lua_pushboolean(L, isatty(fileno(fp))); | ||
11 | return 1; | ||
12 | } | ||
13 | |||
14 | int | ||
15 | luaopen_term_core(lua_State *L) | ||
16 | { | ||
17 | lua_newtable(L); | ||
18 | lua_pushcfunction(L, lua_isatty); | ||
19 | lua_setfield(L, -2, "isatty"); | ||
20 | |||
21 | return 1; | ||
22 | } | ||