-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.lua
More file actions
43 lines (38 loc) · 977 Bytes
/
types.lua
File metadata and controls
43 lines (38 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---@meta tty
---@alias tty.fdLike integer|file* A file descriptor number or a Lua file handle.
---
---Terminal helpers for checking TTY state and reading terminal dimensions.
---
---@class tty
local M = {}
---
---Check whether a file descriptor or Lua file handle is attached to a terminal.
---
---```lua
---local tty = require("tty")
---
---local is_stdout_tty = tty.isatty()
---local is_stderr_tty = tty.isatty(2)
---local is_file_tty = tty.isatty(io.stdout)
---```
---
---@param fd? tty.fdLike
---@return boolean is_tty
---@nodiscard
function M.isatty(fd) end
---
---Get the terminal size for stdout, or for a specific file descriptor or Lua file handle.
---
---```lua
---local tty = require("tty")
---
---local rows, cols = tty.size()
---print(("terminal: %dx%d"):format(cols, rows))
---```
---
---@param fd? tty.fdLike
---@return integer rows Number of terminal rows.
---@return integer cols Number of terminal columns.
---@nodiscard
function M.size(fd) end
return M