class Opal::Input::TextInput

Overview

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

Defined in:

opal/input/text_input.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(prompt : String = "> ", value : String = "", autocomplete : Autocomplete | Nil = nil) #

[View source]

Instance Method Detail

def accept_autocomplete : Bool #

Accepts the currently visible ghost text suggestion


[View source]
def autocomplete : Autocomplete | Nil #

[View source]
def autocomplete(&block : Autocomplete -> Nil) : self #

Configures autocomplete using a block DSL


[View source]
def autocomplete=(autocomplete : Autocomplete | Nil) #

[View source]
def current_ghost_text : String | Nil #

Current ghost text preview suffix


[View source]
def cursor_pos : Int32 #

[View source]
def cursor_pos=(cursor_pos : Int32) #

[View source]
def delete_backward : Nil #

Deletes the character immediately preceding the cursor


[View source]
def delete_forward : Nil #

Deletes the character at the cursor


[View source]
def handle_key(event : Terminal::KeyEvent) : Bool #

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


[View source]
def history : Array(String) #

[View source]
def history=(history : Array(String)) #

[View source]
def insert(ch : Char) : Nil #

Inserts a character at the current cursor position


[View source]
def move_end : Nil #

[View source]
def move_left : Nil #

Moves cursor left


[View source]
def move_right : Nil #

Moves cursor right


[View source]
def move_start : Nil #

[View source]
def prompt : String #

[View source]
def prompt=(prompt : String) #

[View source]
def read_line(driver : Terminal::Driver | Nil = nil) : String #

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


[View source]
def value : String #

[View source]
def value=(value : String) #

[View source]