beamtea_textinput (beamtea v0.1.2)
View SourceA bubble: a single-line text input.
Handles UTF-8 text entry, a movable caret (arrows, Home/End), backspace and delete, an optional character limit, and a placeholder. Because beamtea hides the hardware cursor, the caret is drawn with reverse video.
init(_) -> {beamtea_textinput:focus(beamtea_textinput:new(#{placeholder => <<"Name">>})), none}.
update({key,K}, M) -> {M1, Cmd} = beamtea_textinput:update({key,K}, M), {M1, Cmd}.
view(M) -> beamtea_textinput:view(M).
%% read it back with beamtea_textinput:value(M)
Summary
Functions
Empty the input.
Create a text input. Options: prompt (default "> "), placeholder, limit (max chars, default infinity), color (caret/prompt accent).
Replace the value; the caret moves to the end.
Feed a message. Only key messages matter, and only while focused.
The current value as a UTF-8 binary.
Render the prompt, the current text and (when focused) the caret.
Types
Functions
Empty the input.
-spec cursor(model()) -> non_neg_integer().
-spec new() -> model().
Equivalent to new(#{}).
Create a text input. Options: prompt (default "> "), placeholder, limit (max chars, default infinity), color (caret/prompt accent).
Replace the value; the caret moves to the end.
-spec update(term(), model()) -> {model(), beamtea:cmd()}.
Feed a message. Only key messages matter, and only while focused.
The current value as a UTF-8 binary.
Render the prompt, the current text and (when focused) the caret.