class

Glimmer::TUI::Input

Inherits Reference < Object

Input handles reading raw keyboard input from the terminal.

It supports special keys like arrows, page up/down, etc.

Constants

CONTROL_CODES = {KEY_ENTER => KeyEvent::Type::Enter, KEY_TAB => KeyEvent::Type::Tab, KEY_BACKSPACE => KeyEvent::Type::Backspace, 8 => KeyEvent::Type::Backspace, KEY_ESC => KeyEvent::Type::Escape, KEY_CTRL_C => KeyEvent::Type::CtrlC, KEY_CTRL_D => KeyEvent::Type::CtrlD, KEY_CTRL_U => KeyEvent::Type::CtrlU, KEY_SPACE => KeyEvent::Type::Space}

Mapping of character codes to key types.

ESCAPE_READ_TIMEOUT = 0.005.seconds
ESCAPE_SEQUENCES = {"[A" => KeyEvent::Type::Up, "[B" => KeyEvent::Type::Down, "[C" => KeyEvent::Type::Right, "[D" => KeyEvent::Type::Left, "[H" => KeyEvent::Type::Home, "[1~" => KeyEvent::Type::Home, "[F" => KeyEvent::Type::End, "[4~" => KeyEvent::Type::End, "[5~" => KeyEvent::Type::PageUp, "[6~" => KeyEvent::Type::PageDown}

Mapping of escape sequences to key types.

KEY_BACKSPACE = 127
KEY_CTRL_C = 3
KEY_CTRL_D = 4
KEY_CTRL_U = 21
KEY_ENTER = 13
KEY_ESC = 27

Key codes

KEY_SPACE = 32
KEY_TAB = 9

Constructors

new(io : IO::FileDescriptor = STDIN)
Source

Instance methods

disable_raw_mode

Disables raw mode and restores original settings

Source
enable_raw_mode

Enables raw mode for the terminal using stty

Source
finalize

Cleans up resources

Source
read_key

Reads a single key event from stdin (blocking)

Source
ready?

Returns true if input reading is active (raw mode is enabled).

Source
wait_for_key(timeout : Time::Span) : Bool

Checks if input is available within the given timeout.

Source

Nested types