class

Termisu::Terminfo

Inherits Reference / Object

Terminfo database interface for terminal capability management.

Provides access to terminal control sequences by loading capabilities from the system terminfo database with fallback to hardcoded values for common terminals (xterm, linux).

Loading Strategy

  1. Attempts to load capabilities from terminfo database at standard locations
  2. Falls back to built-in escape sequences for xterm/linux if database unavailable
  3. Merges database values with builtins, preferring database values

Usage

terminfo = Termisu::Terminfo.new
puts terminfo.clear_screen_seq # => "\e[H\e[2J"
puts terminfo.bold_seq         # => "\e[1m"

Note: All capability methods return escape sequence STRINGS, not actions. The _seq suffix indicates this clearly.

Constants

Log = Termisu::Logs::Terminfo

Constructors

Instance methods

attrs_are_standard?

True when every attribute-enable capability equals its standard ECMA-48 SGR sequence (byte-identical to the xterm/linux builtins). Set once during initialization and never mutated afterwards (fiber-safe). Exposed so Terminal's combined apply_sgr path only emits hardcoded SGR parameters when they match what the granular terminfo-driven path would produce; exotic TERMs with non-CSI attribute sequences fall back to that path.

Source
background_color_seq(color_index : Int32) : String

Returns escape sequence to set background color.

Uses the terminfo setab capability with tparm processing.

Source
bold_seq

Returns escape sequence to enable bold (bold). Uses cached value to avoid hash lookup overhead.

Source
clear_screen_seq

Returns escape sequence to clear screen (clear).

Source
column_address_seq(col : Int32) : String

Returns escape sequence to move cursor to column N (0-based).

Source
cup_is_standard?

True when the loaded cup capability equals STANDARD_CUP. Set once during initialization and never mutated afterwards (fiber-safe). Exposed so Terminal can stream CSI cursor moves directly (byte-identical to cursor_position_seq output) without a per-move String.

Source
cup_seq

Returns the raw cup capability string (parametrized).

Use cursor_position_seq to get a ready-to-use sequence with coordinates. Uses cached value to avoid hash lookup overhead.

Source
cursor_backward_seq(n : Int32) : String

Returns escape sequence to move cursor backward N columns.

Source
cursor_down_seq(n : Int32) : String

Returns escape sequence to move cursor down N rows.

Source
cursor_forward_seq(n : Int32) : String

Returns escape sequence to move cursor forward N columns.

Source
cursor_position_seq(row : Int32, col : Int32) : String

Returns escape sequence to move cursor to position (row, col).

Coordinates are 0-based and converted to 1-based by the %i operation in the capability string. When the loaded cup is the standard ANSI template, a direct-interpolation fast path is used (byte-identical to tparm output); non-standard cup strings fall back to tparm processing.

Source
cursor_up_seq(n : Int32) : String

Returns escape sequence to move cursor up N rows.

Source
delete_lines_seq(n : Int32) : String

Returns escape sequence to delete N lines at cursor.

Source
dim_seq

Returns escape sequence to enable dim/faint mode (dim). Uses cached value to avoid hash lookup overhead.

Source
enter_ca_seq

Returns escape sequence to enter alternate screen (smcup).

Source
enter_keypad_seq

Returns escape sequence to enter keypad mode (smkx).

Source
erase_chars_seq(n : Int32) : String

Returns escape sequence to erase N characters at cursor.

Source
exit_ca_seq

Returns escape sequence to exit alternate screen (rmcup).

Source
exit_keypad_seq

Returns escape sequence to exit keypad mode (rmkx).

Source
foreground_color_seq(color_index : Int32) : String

Returns escape sequence to set foreground color.

Uses the terminfo setaf capability with tparm processing.

Source
from_status_line_seq

Returns escape sequence for from status line (fsl).

Source
hidden_seq

Returns escape sequence to enable hidden/invisible mode (invis). Uses cached value to avoid hash lookup overhead.

Source
hide_cursor_seq

Returns escape sequence to hide cursor (civis). Uses cached value to avoid hash lookup overhead.

Source
insert_lines_seq(n : Int32) : String

Returns escape sequence to insert N blank lines at cursor.

Source
italic_seq

Returns escape sequence to enable italic/cursive mode (sitm). Uses cached value to avoid hash lookup overhead.

Source
reset_attrs_seq

Returns escape sequence to reset all attributes (sgr0). Uses cached value to avoid hash lookup overhead.

Source
reverse_seq

Returns escape sequence to enable reverse video (rev). Uses cached value to avoid hash lookup overhead.

Source
row_address_seq(row : Int32) : String

Returns escape sequence to move cursor to row N (0-based).

Source
setab_seq

Returns the raw setab capability string (parametrized background color). Uses cached value to avoid hash lookup overhead.

Source
setaf_seq

Returns the raw setaf capability string (parametrized foreground color). Uses cached value to avoid hash lookup overhead.

Source
show_cursor_seq

Returns escape sequence to show cursor (cnorm). Uses cached value to avoid hash lookup overhead.

Source
strikethrough_seq

Returns escape sequence to enable strikethrough mode (smxx). Uses cached value to avoid hash lookup overhead.

Source
to_status_line_seq

Returns escape sequence to status line (tsl).

Source
underline_seq

Returns escape sequence to enable underline (smul). Uses cached value to avoid hash lookup overhead.

Source

Nested types