ansi/term
terminal setup, capability detection, key reading, resize.
term-size
(term-size)
return terminal dimensions as a (cons rows cols) pair.
A two-element cons cell { head=rows, tail=cols }. Falls back to (24 . 80) when TIOCGWINSZ is unavailable.
(let [sz (term-size)] ...) ; head/tail extract rows/cols
Since: tur-ansi AN0
term-no-color?
(term-no-color?)
1 when $NO_COLOR is set and non-empty, 0 otherwise.
term-color-support
(term-color-support)
detect color depth from environment.
0 = no color (NO_COLOR set, or TERM=dumb) 1 = 4-bit (16 colors) 2 = 8-bit (256-color palette) 3 = 24-bit true-color
term-image-protocol
(term-image-protocol)
detect inline-image protocol support.
0 = none, 1 = kitty, 2 = iterm2, 3 = sixel Detection is conservative; callers may still fall back to a text placeholder when a non-zero result fails at runtime.
term-enable-raw
(term-enable-raw)
enable raw terminal mode and install SIGWINCH self-pipe.
term-disable-raw
(term-disable-raw)
restore cooked mode and tear down the SIGWINCH self-pipe.
term-on-resize
(term-on-resize [callback :ptr<void>])
register a callback invoked on SIGWINCH.
| callback | a function pointer of signature void(*)(void), or 0 to | |
| remove the current callback. | ||
| The callback fires from inside term-read-key (after the resize byte | ||
| has been drained from the self-pipe and before "<Resize>" is returned), | ||
| so it runs in normal process context, not from the signal handler. |
term-read-key
(term-read-key)
block until one keypress; return a normalized key string.
term-read-key-timeout
(term-read-key-timeout [ms :int])
like term-read-key but returns "" after ms millis.
Internal definitions
__ansi-collect__ansi-scripted-pop__ansi-keybuf-ptr__ansi-strdup-cstr__ansi-read-key-impl