Skip to content

Commit ccf1c83

Browse files
docs(tty): generate API docs (#10)
Co-authored-by: haithium <128622475+haithium@users.noreply.github.com>
1 parent 84baa07 commit ccf1c83

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

docs/src/tty/api/tty.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
```

0 commit comments

Comments
 (0)