class

Glimmer::TUI::Terminal

Inherits Reference < Object

Terminal handles low-level terminal operations including raw mode,

cursor control, and screen management.

Constants

BLINK = "#{CSI}5m"
BOLD = "#{CSI}1m"
CLEAR_LINE = "#{CSI}2K"
CLEAR_SCREEN = "#{CSI}2J"

Screen control

CSI = "#{ESC}["
CURSOR_BACK = "#{CSI}D"
CURSOR_DOWN = "#{CSI}B"
CURSOR_FORWARD = "#{CSI}C"
CURSOR_HOME = "#{CSI}H"

Cursor movement

CURSOR_NEXT_LINE = "#{CSI}E"
CURSOR_PREV_LINE = "#{CSI}F"
CURSOR_UP = "#{CSI}A"
DIM = "#{CSI}2m"
ENTER_ALT_SCREEN = "#{ESC}[?1049h"

Alternate screen buffer

ESC = "\e"

ANSI escape codes

EXIT_ALT_SCREEN = "#{ESC}[?1049l"
HIDDEN = "#{CSI}8m"
HIDE_CURSOR = "#{CSI}?25l"
RESET = "#{CSI}0m"

Colors

RESTORE_CURSOR = "#{ESC}8"
REVERSE = "#{CSI}7m"
SAVE_CURSOR = "#{ESC}7"
SHOW_CURSOR = "#{CSI}?25h"
UNDERLINE = "#{CSI}4m"

Class methods

background_color(r : Int32, g : Int32, b : Int32) : String

Sets background color

Source
clear

Clears the entire screen

Source
clear_to_beginning_of_line

Clears from cursor to beginning of line

Source
clear_to_end_of_line

Clears from cursor to end of line

Source
enter_alt_screen

Enters alternate screen buffer

Source
exit_alt_screen

Exits alternate screen buffer

Source
foreground_color(r : Int32, g : Int32, b : Int32) : String

Sets text color (foreground)

Source
height

Returns terminal height

Source
hide_cursor

Hides the cursor

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

Moves cursor to specific position (1-indexed)

Source
reset

Resets all text attributes

Source
show_cursor

Shows the cursor

Source
size

Returns terminal size as {height, width}

Source
width

Returns terminal width

Source