aboutsummaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/term.c b/src/term.c
new file mode 100644
index 0000000..2adb1e9
--- /dev/null
+++ b/src/term.c
@@ -0,0 +1,37 @@
1/// @submodule system
2#include <lua.h>
3#include <lauxlib.h>
4#include <lualib.h>
5#include "compat.h"
6
7#ifndef _MSC_VER
8# include <unistd.h>
9#endif
10
11
12/***
13Checks if a file-handle is a TTY.
14
15@function isatty
16@tparam file file the file-handle to check
17@treturn boolean true if the file is a tty
18*/
19static int lua_isatty(lua_State* L) {
20 FILE **fh = (FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE);
21 lua_pushboolean(L, isatty(fileno(*fh)));
22 return 1;
23}
24
25
26
27static luaL_Reg func[] = {
28 { "isatty", lua_isatty },
29 { NULL, NULL }
30};
31
32/*-------------------------------------------------------------------------
33 * Initializes module
34 *-------------------------------------------------------------------------*/
35void term_open(lua_State *L) {
36 luaL_setfuncs(L, func, 0);
37}