class

Opal::Input::TextInput

Inherits Reference < Object

Interactive single-line text input field supporting Tab completion, ghost text preview, cursor navigation, and history.

Constructors

new(prompt : String = "> ", value : String = "", autocomplete : Autocomplete | Nil = nil)
Source

Instance methods

accept_autocomplete

Accepts the currently visible ghost text suggestion

Source
autocomplete
Source
autocomplete

Configures autocomplete using a block DSL

Source
autocomplete=(autocomplete : Autocomplete | Nil)
Source
current_ghost_text

Current ghost text preview suffix

Source
cursor_pos
Source
cursor_pos=(cursor_pos : Int32)
Source
delete_backward

Deletes the character immediately preceding the cursor

Source
delete_forward

Deletes the character at the cursor

Source
handle_key(event : Terminal::KeyEvent) : Bool

Handles a key event. Returns true if Enter was pressed (submission), false otherwise.

Source
history
Source
history=(history : Array(String))
Source
insert(ch : Char) : Nil

Inserts a character at the current cursor position

Source
move_end
Source
move_left

Moves cursor left

Source
move_right

Moves cursor right

Source
move_start
Source
prompt
Source
prompt=(prompt : String)
Source
read_line(driver : Terminal::Driver | Nil = nil) : String

Interactively reads user input until Enter is pressed, drawing in-place updates and ghost text.

Source
value
Source
value=(value : String)
Source