File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ description :
3+ " Terminal helpers for checking TTY state and reading terminal dimensions."
4+ ---
5+
6+ # ` tty `
7+
8+ Terminal helpers for checking TTY state and reading terminal dimensions.
9+
10+ ## Functions
11+
12+ <a id =" fn-isatty " ></a >
13+
14+ ### ` isatty(fd?) `
15+
16+ Check whether a file descriptor or Lua file handle is attached to a terminal.
17+
18+ ** Parameters** :
19+
20+ - ` fd? ` (` integer|file* ` ): A file descriptor number or a Lua file handle.
21+
22+ ** Return** :
23+
24+ - ` isatty ` (` boolean ` )
25+
26+ ** Example** :
27+
28+ ``` lua
29+ local tty = require " tty"
30+
31+ print (tty .isatty ())
32+ print (tty .isatty (2 ))
33+ print (tty .isatty (io.stdout ))
34+ ```
35+
36+ <a id =" fn-size " ></a >
37+
38+ ### ` size(fd?) `
39+
40+ Get the terminal size for stdout, or for a specific file descriptor or Lua file
41+ handle.
42+
43+ ** Parameters** :
44+
45+ - ` fd? ` (` integer|file* ` ): A file descriptor number or a Lua file handle.
46+
47+ ** Return** :
48+
49+ - ` rows ` (` integer ` ): Number of terminal rows.
50+ - ` cols ` (` integer ` ): Number of terminal columns.
51+
52+ ** Example** :
53+
54+ ``` lua
55+ local tty = require " tty"
56+
57+ local rows , cols = tty .size ()
58+ print ((" terminal: %dx%d" ):format (cols , rows ))
59+ ```
You can’t perform that action at this time.
0 commit comments