Tanguv0.35.0
CLI, terminal & markup4 exports
Raw Markdown

/tty

Terminal capability detection, dimensions, raw mode controls, and interactive prompt helpers.

(use /tty)

Functions & symbols#

ask#

function
(tty/ask) -> String | ()

Writes an optional prompt to active `*out*`, flushes, and reads a single line from active `*in*`.

ParameterTypeOptionalDescription
promptAnyrequiredOptional prompt displayed before reading a line
Returns:Any
(let name (tty/ask "Name: "))

color-enabled?#

function
(tty/color-enabled?) -> Bool

Returns `true` if ANSI color output should be enabled for the target stream, honoring `NO_COLOR`, `FORCE_COLOR`, `TERM=dumb`, and TTY status.

ParameterTypeOptionalDescription
streamAny | SymbolrequiredOptional stream value or port symbol (`:out-port`, `:err-port`, `:in-port`); defaults to active `*out*`
Returns:Any
(tty/color-enabled?)
(tty/color-enabled? :err-port)

is-tty?#

function
(tty/is-tty?) -> Bool

Returns `true` if the target stream (defaults to active `*out*`) is attached to an interactive OS terminal (TTY).

ParameterTypeOptionalDescription
streamAny | SymbolrequiredOptional stream value (such as `out-port`, `*out*`, or `Buffer`) or port symbol (`:out-port`, `:err-port`, `:in-port`); defaults to active `*out*`
Returns:Any
(tty/is-tty?)
(tty/is-tty? :err-port)

size#

function
(tty/size) -> Map | ()

Returns `{:cols Int :rows Int}` when attached to a terminal, or `()` when not attached to a TTY.

Returns:Any
(let dims (tty/size))