class

Termify::Terminal

Inherits Reference < Object

Add UNIX characteristics

Constants

DEFAULT_CURSOR_ROW = 1

Row reported when the terminal cannot be asked, or answers unintelligibly.

VMIN = 6
VTIME = 5

Constructors

new(input : IO = STDIN, output : IO = STDOUT)
Source

Instance methods

color_supported?

Returns true if the terminal is likely to support ANSI color output. Does not change the console; use #setup_console for that.

Source
cursor_row

Return the row number of the cursor's current position.

Asking requires a terminal on both ends: the query goes to the output and the reply arrives on the input. Where either is redirected there is nobody to answer, so this returns DEFAULT_CURSOR_ROW rather than waiting.

Source
input

Where queries are written and replies are read. Everything built on Terminal writes through output rather than reaching for STDOUT, so a caller and its terminal cannot address different devices.

Source
interactive?

True when both ends are a terminal, and so when a query may be asked at all. Overriding this is how a spec reaches the code beyond the gate.

Source
output
Source
restore_console

Restore console (after setup); does nothing on *nix platforms but is needed for Windows

Source
setup_console

Setup console terminal mode; does nothing on *nix platforms but is needed for Windows

Source
truecolor_supported?

Returns true if the terminal advertises truecolor support. Callers should fall back to 256-color or 8/16 if this returns false.

Source
with_raw_input

Temporarily switch input to raw + VT mode, yield, then restore input mode. Output mode is left as-is (already set up by setup_console).

Source