~/bend-docscommunity

tty.bend relies on unsafe/foreign

raw source on the hub · import bend-kit-tty@0.1.0.1/tty.bend as Tty

Terminal detection, dimensions, ANSI color and Unicode display-width text. Source: https://github.com/paymog/bend-kit/tree/main/tty

2 imports
import Base
import ./text.bend as Text

Definitions

def style source · line 21 · raw

@enabled:Bool -> @code:U32 -> @text:String -> String

Apply one numeric ANSI SGR code and reset it, or leave the text unchanged.

def auto_style source · line 24 · raw

@code:U32 -> @text:String -> IO(String)

def width source · line 30 · raw

@text:String -> U32

Display columns for Unicode text. Control characters are not terminal cursor movements.

def pad_right source · line 34 · raw

@text:String -> @cols:U32 -> String

Append spaces until text occupies at least cols display columns.

Effects (foreign code)

effect stdout_tty source · line 6 · raw

IO(Bool)

Standard output is a terminal.

foreign: effs/tty.c, effs/tty.js

effect size source · line 11 · raw

IO(Maybe<&1, Pair(U32, U32)>)

Terminal columns and rows; None when stdout is not a terminal or its size is unavailable.

foreign: effs/tty.c, effs/tty.js

effect color_enabled source · line 16 · raw

IO(Bool)

Automatic styling is enabled only for a terminal without NO_COLOR.

foreign: effs/tty.c, effs/tty.js