pub struct Model {Show 14 fields
pub err: Option<String>,
pub prompt: String,
pub placeholder: String,
pub echo_mode: EchoMode,
pub echo_character: char,
pub use_virtual_cursor: bool,
pub virtual_cursor: Model,
pub char_limit: usize,
pub styles: Styles,
pub width: usize,
pub key_map: KeyMap,
pub focus: bool,
pub validate: Option<ValidateFunc>,
pub show_suggestions: bool,
/* private fields */
}Expand description
Model is the Bubble Tea model for this text input element.
Fields§
§err: Option<String>The validation error, if any.
prompt: StringGeneral settings. The prompt shown before the input.
placeholder: StringThe placeholder shown when the input is empty.
echo_mode: EchoModeThe echo mode of the input.
echo_character: charThe character used for masking in EchoMode::EchoPassword.
use_virtual_cursor: booluse_virtual_cursor determines whether or not to use the virtual cursor.
virtual_cursor: ModelVirtual cursor manager.
char_limit: usizeCharLimit is the maximum amount of characters this input element will accept. If 0 or less, there’s no limit.
styles: StylesStyling. FocusedStyle and BlurredStyle are used to style the textarea in focused and blurred states.
width: usizeWidth is the maximum number of characters that can be displayed at once. It essentially treats the text field like a horizontally scrolling viewport. If 0 or less this setting is ignored.
key_map: KeyMapKeyMap encodes the keybindings recognized by the widget.
focus: boolfocus indicates whether user input focus should be on this input component. When false, ignore keyboard input and hide the cursor.
validate: Option<ValidateFunc>Validate is a function that checks whether or not the text within the
input is valid. If it is not valid, the Err field will be set to the
error returned by the function.
show_suggestions: boolShould the input suggest to complete.
Implementations§
Source§impl Model
impl Model
Sourcepub fn virtual_cursor(&self) -> bool
pub fn virtual_cursor(&self) -> bool
VirtualCursor returns whether the model is using a virtual cursor.
Sourcepub fn set_virtual_cursor(&mut self, v: bool)
pub fn set_virtual_cursor(&mut self, v: bool)
SetVirtualCursor sets whether the model should use a virtual cursor.
Sourcepub fn set_styles(&mut self, s: Styles)
pub fn set_styles(&mut self, s: Styles)
SetStyles sets the styles for the text input.
Sourcepub fn cursor(&self) -> Option<Cursor>
pub fn cursor(&self) -> Option<Cursor>
Cursor returns a real cursor for rendering in a Bubble Tea program.
This requires that use_virtual_cursor is
false.
Sourcepub fn set_cursor(&mut self, pos: usize)
pub fn set_cursor(&mut self, pos: usize)
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.
Sourcepub fn cursor_start(&mut self)
pub fn cursor_start(&mut self)
CursorStart moves the cursor to the start of the input field.
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
CursorEnd moves the cursor to the end of the input field.
Sourcepub fn focus(&mut self) -> Cmd
pub fn focus(&mut self) -> Cmd
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.
Sourcepub fn blur(&mut self)
pub fn blur(&mut self)
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.
Sourcepub fn set_suggestions(&mut self, suggestions: &[String])
pub fn set_suggestions(&mut self, suggestions: &[String])
SetSuggestions sets the suggestions for the input.
Sourcepub fn available_suggestions(&self) -> Vec<String>
pub fn available_suggestions(&self) -> Vec<String>
AvailableSuggestions returns the list of available suggestions.
Sourcepub fn matched_suggestions(&self) -> Vec<String>
pub fn matched_suggestions(&self) -> Vec<String>
MatchedSuggestions returns the list of matched suggestions.
Sourcepub fn current_suggestion_index(&self) -> usize
pub fn current_suggestion_index(&self) -> usize
CurrentSuggestionIndex returns the currently selected suggestion index.
Sourcepub fn current_suggestion(&self) -> String
pub fn current_suggestion(&self) -> String
CurrentSuggestion returns the currently selected suggestion.
Sourcepub fn can_accept_suggestion(&self) -> bool
pub fn can_accept_suggestion(&self) -> bool
canAcceptSuggestion returns whether there is an acceptable suggestion to autocomplete the current value.