tur/term
terminal utilities: size, tty detection, raw mode, ANSI colors.
Since: Phase B1
term/width
(term/width :int)
return the terminal column width.
Number of columns, or 80 as a fallback if ioctl fails.
(term/width) ; => 80
Since: Phase B2
term/height
(term/height :int)
return the terminal row height.
Number of rows, or 24 as a fallback if ioctl fails.
(term/height) ; => 24
Since: Phase B2
term/is-tty?
(term/is-tty? [fd :int] :bool)
test whether a file descriptor refers to a terminal.
| fd | file descriptor (0=stdin, 1=stdout, 2=stderr) |
true if fd is connected to a terminal.
(term/is-tty? 1) ; => true when stdout is a tty
Since: Phase B2
term/set-raw
(term/set-raw [fd :int] :int)
put a terminal into raw mode (no line buffering or echo).
| fd | file descriptor of the terminal |
0 on success, -1 on error.
(term/set-raw 0) ; => 0
Since: Phase B2
term/set-cooked
(term/set-cooked [fd :int] :int)
restore a terminal to cooked (canonical) mode.
| fd | file descriptor of the terminal |
0 on success, -1 on error.
(term/set-cooked 0) ; => 0
Since: Phase B2
term/bold
(term/bold [s :cstr] :cstr)
wrap a string in ANSI bold codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI bold, or a plain copy if not a tty or NO_COLOR is set. The caller must free.
(term/bold "hello") ; => "\x1b[1mhello\x1b[0m"
Since: Phase B2
term/dim
(term/dim [s :cstr] :cstr)
wrap a string in ANSI dim codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI dim, or a plain copy. Caller must free.
(term/dim "note") ; => "\x1b[2mnote\x1b[0m"
Since: Phase B2
term/red
(term/red [s :cstr] :cstr)
wrap a string in ANSI red foreground codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI red, or a plain copy. Caller must free.
(term/red "error") ; => "\x1b[31merror\x1b[0m"
Since: Phase B2
term/green
(term/green [s :cstr] :cstr)
wrap a string in ANSI green foreground codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI green, or a plain copy. Caller must free.
(term/green "ok") ; => "\x1b[32mok\x1b[0m"
Since: Phase B2
term/yellow
(term/yellow [s :cstr] :cstr)
wrap a string in ANSI yellow foreground codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI yellow, or a plain copy. Caller must free.
(term/yellow "warn") ; => "\x1b[33mwarn\x1b[0m"
Since: Phase B2
term/blue
(term/blue [s :cstr] :cstr)
wrap a string in ANSI blue foreground codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI blue, or a plain copy. Caller must free.
(term/blue "info") ; => "\x1b[34minfo\x1b[0m"
Since: Phase B2
term/cyan
(term/cyan [s :cstr] :cstr)
wrap a string in ANSI cyan foreground codes.
| s | NUL-terminated cstr |
Heap-allocated cstr with ANSI cyan, or a plain copy. Caller must free.
(term/cyan "debug") ; => "\x1b[36mdebug\x1b[0m"
Since: Phase B2