Skip to content

Commit 1676b55

Browse files
docs: sync gathered documentation from tty (#26)
Co-authored-by: haithium <128622475+haithium@users.noreply.github.com>
1 parent ba2f747 commit 1676b55

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

docs/src/tty/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# tty
2+
3+
[![LuaRocks](https://img.shields.io/luarocks/v/BlueLua/tty?color=blue&style=flat-square)](https://luarocks.org/modules/BlueLua/tty)
4+
![Lua Versions](https://img.shields.io/badge/lua-5.1%20%7C%205.2%20%7C%205.3%20%7C%205.4%20%7C%205.5%20%7C%20LuaJIT-blue?style=flat-square)
5+
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-blue?style=flat-square)
6+
[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/BlueLua/tty/blob/main/LICENSE)
7+
8+
`tty` provides lightweight, cross-platform C-backed Lua bindings for terminal
9+
detection and terminal size inspection.
10+
11+
## ✨ Features
12+
13+
- **TTY Verification**: Check if a Lua file handle (like `io.stdout`,
14+
`io.stdin`), standard stream, or raw file descriptor is interactive.
15+
- **Window Dimension Query**: Retrieve the current width (columns) and height
16+
(rows) of the active terminal dynamically.
17+
- **Multiple Lua Versions**: Compatible with LuaJIT, Lua 5.1, 5.2, 5.3, 5.4, and
18+
5.5.
19+
20+
## 📦 Installation
21+
22+
```sh
23+
luarocks install tty
24+
```
25+
26+
## 🚀 Usage
27+
28+
```lua
29+
local tty = require "tty"
30+
31+
-- Check if standard output is a TTY
32+
if tty.isatty(io.stdout) then
33+
local rows, cols = tty.size()
34+
print(string.format("Terminal size: %dx%d", cols, rows))
35+
else
36+
print("Output is redirected")
37+
end
38+
```

0 commit comments

Comments
 (0)