pub struct TextInput {Show 14 fields
pub err: Option<String>,
pub prompt: String,
pub placeholder: String,
pub echo_mode: EchoMode,
pub echo_character: char,
pub cursor: Cursor,
pub prompt_style: Style,
pub text_style: Style,
pub placeholder_style: Style,
pub completion_style: Style,
pub char_limit: usize,
pub width: usize,
pub key_map: KeyMap,
pub show_suggestions: bool,
/* private fields */
}Expand description
Single-line text input model.
Fields§
§err: Option<String>Current error from validation.
prompt: StringPrompt displayed before input.
placeholder: StringPlaceholder text when empty.
echo_mode: EchoModeEcho mode (normal, password, none).
echo_character: charCharacter to display in password mode.
cursor: CursorCursor model.
prompt_style: StyleStyle for the prompt.
text_style: StyleStyle for the text.
placeholder_style: StyleStyle for the placeholder.
completion_style: StyleStyle for completions.
char_limit: usizeMaximum characters allowed (0 = no limit).
width: usizeMaximum display width (0 = no limit).
key_map: KeyMapKey bindings.
show_suggestions: boolWhether to show suggestions.
Implementations§
Source§impl TextInput
impl TextInput
Sourcepub fn set_prompt(&mut self, prompt: impl Into<String>)
pub fn set_prompt(&mut self, prompt: impl Into<String>)
Sets the prompt string.
Sourcepub fn set_placeholder(&mut self, placeholder: impl Into<String>)
pub fn set_placeholder(&mut self, placeholder: impl Into<String>)
Sets the placeholder text.
Sourcepub fn set_echo_mode(&mut self, mode: EchoMode)
pub fn set_echo_mode(&mut self, mode: EchoMode)
Sets the echo mode.
Sourcepub fn set_cursor(&mut self, pos: usize)
pub fn set_cursor(&mut self, pos: usize)
Sets the cursor position.
Sourcepub fn cursor_start(&mut self)
pub fn cursor_start(&mut self)
Moves cursor to start of input.
Sourcepub fn cursor_end(&mut self)
pub fn cursor_end(&mut self)
Moves cursor to end of input.
Sourcepub fn set_suggestions(&mut self, suggestions: &[&str])
pub fn set_suggestions(&mut self, suggestions: &[&str])
Sets the suggestions list.
Sourcepub fn set_validate<F>(&mut self, f: F)
pub fn set_validate<F>(&mut self, f: F)
Sets the validation function.
Sourcepub fn available_suggestions(&self) -> Vec<String>
pub fn available_suggestions(&self) -> Vec<String>
Returns available suggestions as strings.
Sourcepub fn matched_suggestions(&self) -> Vec<String>
pub fn matched_suggestions(&self) -> Vec<String>
Returns matched suggestions as strings.
Sourcepub fn current_suggestion_index(&self) -> usize
pub fn current_suggestion_index(&self) -> usize
Returns the current suggestion index.
Sourcepub fn current_suggestion(&self) -> String
pub fn current_suggestion(&self) -> String
Returns the current suggestion.
Trait Implementations§
Source§impl Model for TextInput
impl Model for TextInput
Source§fn init(&self) -> Option<Cmd>
fn init(&self) -> Option<Cmd>
Initialize the text input.
If focused and cursor is in blink mode, returns a blink command.