Liking cljdoc? Tell your friends :D

volley.shell.terminal

The terminal edge: TTY detection, size, cursor control, in-place redraw and raw keyboard input. Decisions live in pure helpers here (frame-string, parse-stty-size, pick-width); the functions ending in ! only print or run stty.

The terminal edge: TTY detection, size, cursor control, in-place redraw
and raw keyboard input. Decisions live in pure helpers here (`frame-string`,
`parse-stty-size`, `pick-width`); the functions ending in `!` only print or
run `stty`.
raw docstring

frame-heightclj

(frame-height {:keys [frame]})

How many rows frame-string leaves redrawable for this frame.

How many rows `frame-string` leaves redrawable for this frame.
sourceraw docstring

frame-stringclj

(frame-string prev-height {:keys [emit frame]})

The text that redraws a frame in place. prev-height is the number of frame lines printed last time (see frame-height). Lines in :emit are printed permanently where the old frame started; :frame lines follow and stay redrawable. Each line replaces whatever was on its row, and anything left over from a taller previous frame is cleared.

The text that redraws a frame in place. `prev-height` is the number of
frame lines printed last time (see `frame-height`). Lines in `:emit` are
printed permanently where the old frame started; `:frame` lines follow and
stay redrawable. Each line replaces whatever was on its row, and anything
left over from a taller previous frame is cleared.
sourceraw docstring

hide-cursorclj

Escape sequence that hides the cursor.

Escape sequence that hides the cursor.
sourceraw docstring

hide-cursor!clj

(hide-cursor!)

Hide the cursor.

Hide the cursor.
sourceraw docstring

parse-stty-sizeclj

(parse-stty-size s)

Parses stty size output ("rows cols") into {:rows n :cols n}, or nil.

Parses `stty size` output ("rows cols") into `{:rows n :cols n}`, or nil.
sourceraw docstring

pick-widthclj

(pick-width stty-output columns-env)

Terminal width from stty size output, else the COLUMNS value, else 80.

Terminal width from `stty size` output, else the COLUMNS value, else 80.
sourceraw docstring

prompt!clj

(prompt! label buffer)

Draws a one-line prompt in place: label> buffer. A nil buffer closes the prompt by moving to a fresh line.

Draws a one-line prompt in place: `label> buffer`. A nil `buffer` closes
the prompt by moving to a fresh line.
sourceraw docstring

read-key!clj

(read-key!)

A pending key press as a character, without waiting, or nil. A lone ESC comes back as \u001b; escape sequences (arrows, function keys) are swallowed and give nil. Call inside with-raw-mode!.

A pending key press as a character, without waiting, or nil. A lone ESC
comes back as `\u001b`; escape sequences (arrows, function keys) are
swallowed and give nil. Call inside `with-raw-mode!`.
sourceraw docstring

redraw!clj

(redraw! prev-height frame)

Prints frame ({:emit [...] :frame [...]}) over the previous one and returns the height to pass to the next call.

Prints `frame` (`{:emit [...] :frame [...]}`) over the previous one and
returns the height to pass to the next call.
sourceraw docstring

show-cursorclj

Escape sequence that shows the cursor.

Escape sequence that shows the cursor.
sourceraw docstring

show-cursor!clj

(show-cursor!)

Show the cursor again.

Show the cursor again.
sourceraw docstring

stdin-tty?clj

(stdin-tty?)

True when stdin is a terminal, so raw mode and key presses make sense.

True when stdin is a terminal, so raw mode and key presses make sense.
sourceraw docstring

tty?clj

(tty?)

True when stdout is a terminal.

True when stdout is a terminal.
sourceraw docstring

widthclj

(width)

Current terminal width: stty size, then $COLUMNS, then 80.

Current terminal width: `stty size`, then $COLUMNS, then 80.
sourceraw docstring

width-check-msclj

How often a live view re-reads the terminal width. Each read runs stty; until it does, a resized terminal shows frames of the old width.

How often a live view re-reads the terminal width. Each read runs
`stty`; until it does, a resized terminal shows frames of the old width.
sourceraw docstring

with-hidden-cursor!clj

(with-hidden-cursor! f)

Runs (f) with the cursor hidden, and shows it again however f ends.

Runs `(f)` with the cursor hidden, and shows it again however `f` ends.
sourceraw docstring

with-raw-mode!clj

(with-raw-mode! f)
(with-raw-mode! f after)

Runs (f) with the terminal in raw-ish mode (no line buffering, no echo) and restores the saved settings when f ends, throws, or the JVM exits. after, when given, runs right after the restore, in the same shutdown hook: JVM shutdown hooks run concurrently, so cleanup that kills child processes must not race the stty that restores the terminal.

Runs `(f)` with the terminal in raw-ish mode (no line buffering, no echo)
and restores the saved settings when `f` ends, throws, or the JVM exits.
`after`, when given, runs right after the restore, in the same shutdown
hook: JVM shutdown hooks run concurrently, so cleanup that kills child
processes must not race the `stty` that restores the terminal.
sourceraw docstring

with-restore!clj

(with-restore! restore f)

Runs (f) and then runs (restore), also if f throws and also on Ctrl-C or any JVM exit, through a shutdown hook. restore must be safe to call twice.

Runs `(f)` and then runs `(restore)`, also if `f` throws and also on
Ctrl-C or any JVM exit, through a shutdown hook. `restore` must be safe to
call twice.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close