Documentation
¶
Overview ¶
Package terminal provides terminal-related utilities.
Index ¶
Constants ¶
const DefaultWidth = 50
DefaultWidth is the default terminal width when detection fails.
Variables ¶
var GetSize = term.GetSize
GetSize returns the terminal width and height for the given file descriptor. This is a variable to allow mocking in tests.
var IsTTY = isatty.IsTerminal
IsTTY checks if the file descriptor is a TTY. This is a variable to allow mocking in tests.
Functions ¶
func FdToInt ¶ added in v0.8.0
FdToInt safely converts a file descriptor from uintptr to int. File descriptors are always small non-negative values, so this only guards against a theoretical overflow on 32-bit platforms; on overflow it returns -1, which callers treat as an invalid descriptor.
func GetWidthFromWriter ¶
GetWidthFromWriter returns the terminal width for the given writer. Returns DefaultWidth if detection fails or writer is not a terminal.
func IsTerminalWriter ¶
IsTerminalWriter returns true if the given writer is a terminal.