aboutsummaryrefslogtreecommitdiff
path: root/core.c
blob: 425c3e9a4e44495303372ecb41c92358ede15146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <unistd.h>

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;
}