class

Bubbles::TextInput::Model

Inherits Reference < Object

Model is the Bubble Tea model for this text input element.

Constructors

new

New creates a new model with default settings.

Source

Instance methods

available_suggestions

AvailableSuggestions returns the list of available suggestions.

Source
blur

Blur removes the focus state on the model. When the model is blurred it can not receive keyboard input and the cursor will be hidden.

Source
char_limit
Source
char_limit=(char_limit : Int32)
Source
copy

copy creates a copy of the model for functional updates.

Source
current_suggestion

CurrentSuggestion returns the currently selected suggestion.

Source
current_suggestion_index

CurrentSuggestionIndex returns the currently selected suggestion index.

Source
current_suggestion_index=(current_suggestion_index : Int32)
Source
cursor

Cursor returns a Tea::Cursor for rendering a real cursor in a Bubble Tea program. This requires that virtual_cursor is set to false.

Note that you will almost certainly also need to adjust the offset cursor position per the textarea's per the textarea's position in the terminal.

Example:

In your top-level View function:

f = Tea::Frame.new(m.textarea.view) f.cursor = m.textarea.cursor f.cursor.position.x += offset_x f.cursor.position.y += offset_y

Source
cursor=(pos : Int32)
Source
cursor_end

CursorEnd moves the cursor to the end of the input field.

Source
cursor_start

CursorStart moves the cursor to the start of the input field.

Source
echo_character
Source
echo_character=(echo_character : Char)
Source
echo_mode
Source
echo_mode=(echo_mode : EchoMode)
Source
err=(err : Exception | Nil)
Source
focus

Focus sets the focus state on the model. When the model is in focus it can receive keyboard input and the cursor will be shown.

Source
focus=(focus : Bool)
Source
focused?

Focused returns the focus state on the model.

Source
init

Init returns the initial command(s) for the model.

Source
key_map
Source
key_map=(key_map : KeyMap)
Source
matched_suggestions

MatchedSuggestions returns the list of matched suggestions.

Source
matched_suggestions=(matched_suggestions : Array(Array(Char)))
Source
next_suggestion

next_suggestion selects the next suggestion. Made public for test parity with Go (Go test in same package calls it directly).

Source
offset
Source
offset=(offset : Int32)
Source
offset_right
Source
offset_right=(offset_right : Int32)
Source
placeholder
Source
placeholder=(placeholder : String)
Source
pos=(pos : Int32)
Source
position

Position returns the cursor position.

Source
previous_suggestion

previous_suggestion selects the previous suggestion. Made public for test parity with Go (Go test in same package calls it directly).

Source
prompt
Source
prompt=(prompt : String)
Source
reset

Reset sets the input to its default state with no input.

Source
rsan
Source
rsan=(rsan : Sanitizer | Nil)
Source
set_cursor(pos : Int32)

SetCursor moves the cursor to the given position. If the position is out of bounds the cursor will be moved to the start or end accordingly.

Source
set_styles(s : Styles)

SetStyles sets the styles for the text input.

Source
set_suggestions(suggestions : Array(String))

SetSuggestions sets the suggestions for the input.

Source
set_value(s : String)

SetValue sets the value of the text input.

Source
set_virtual_cursor(v : Bool)

SetVirtualCursor sets whether the model should use a virtual cursor.

Source
set_width(w : Int32)

SetWidth sets the width of the text input.

Source
show_suggestions=(show_suggestions : Bool)
Source
show_suggestions?
Source
styles

Styles returns the current set of styles.

Source
styles=(s : Styles)
Source
suggestions
Source
suggestions=(suggestions : Array(Array(Char)))
Source
suggestions=(suggestions : Array(String))
Source
update(msg : Tea::Msg) : Tuple(self, Tea::Cmd | Nil)

Update handles incoming messages and returns an updated model along with optional commands.

Source
update_suggestions

update_suggestions refreshes the list of matching suggestions. Made public for test parity with Go (Go test in same package calls it directly).

Source
use_virtual_cursor
Source
use_virtual_cursor=(use_virtual_cursor : Bool)
Source
validate
Source
validate=(validate : ValidateFunc | Nil)
Source
value

Value returns the value of the text input.

Source
value=(value : Array(Char))

Private fields

Source
value=(s : String)
Source
view

View renders the model's current state as a string for display.

Source
virtual_cursor

VirtualCursor returns whether the model is using a virtual cursor.

Source
virtual_cursor=(virtual_cursor : Cursor::Model)
Source
virtual_cursor=(v : Bool)
Source
virtual_cursor?
Source
width
Source
width=(width : Int32)
Source