aboutsummaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2023-11-15 19:28:06 +0100
committerGitHub <noreply@github.com>2023-11-15 19:28:06 +0100
commit90997893cc568c86805afa95db28439c28e32980 (patch)
tree4a692fcc91a811e18023ba1896aeee23fe2ee2c5 /src/term.c
parentf868c16514be69b20a4e771cc347a80c9c439db6 (diff)
parent048f3cec7a18e7a28146f03c3c9e5d89d9613028 (diff)
downloadluasystem-90997893cc568c86805afa95db28439c28e32980.tar.gz
luasystem-90997893cc568c86805afa95db28439c28e32980.tar.bz2
luasystem-90997893cc568c86805afa95db28439c28e32980.zip
Merge pull request #6 from lunarmodules/time
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}