pub struct TextArea { /* private fields */ }Expand description
Multi-line text editor widget.
Implementations§
Source§impl TextArea
impl TextArea
Sourcepub fn handle_event(&mut self, event: &Event) -> bool
pub fn handle_event(&mut self, event: &Event) -> bool
Handle a terminal event.
Returns true if the state changed.
Sourcepub fn with_placeholder(self, text: impl Into<String>) -> Self
pub fn with_placeholder(self, text: impl Into<String>) -> Self
Set placeholder text (builder).
Sourcepub fn with_focus(self, focused: bool) -> Self
pub fn with_focus(self, focused: bool) -> Self
Set focused state (builder).
Sourcepub fn with_line_numbers(self, show: bool) -> Self
pub fn with_line_numbers(self, show: bool) -> Self
Enable line numbers (builder).
Sourcepub fn with_style(self, style: Style) -> Self
pub fn with_style(self, style: Style) -> Self
Set base style (builder).
Sourcepub fn with_cursor_line_style(self, style: Style) -> Self
pub fn with_cursor_line_style(self, style: Style) -> Self
Set cursor line highlight style (builder).
Sourcepub fn with_selection_style(self, style: Style) -> Self
pub fn with_selection_style(self, style: Style) -> Self
Set selection style (builder).
Sourcepub fn with_soft_wrap(self, wrap: bool) -> Self
pub fn with_soft_wrap(self, wrap: bool) -> Self
Enable soft wrapping (builder).
Sourcepub fn with_max_height(self, max: usize) -> Self
pub fn with_max_height(self, max: usize) -> Self
Set maximum height in lines (builder). 0 = fill available area.
Sourcepub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
Set the full text content (resets cursor and undo history).
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of lines.
Sourcepub fn cursor(&self) -> CursorPosition
pub fn cursor(&self) -> CursorPosition
Current cursor position.
Sourcepub fn set_cursor_position(&mut self, pos: CursorPosition)
pub fn set_cursor_position(&mut self, pos: CursorPosition)
Set cursor position (clamped to bounds). Clears selection.
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
Get selected text.
Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Whether the widget has focus.
Sourcepub fn set_focused(&mut self, focused: bool)
pub fn set_focused(&mut self, focused: bool)
Set focus state.
Sourcepub fn editor_mut(&mut self) -> &mut Editor
pub fn editor_mut(&mut self) -> &mut Editor
Mutable access to the underlying editor.
Sourcepub fn insert_text(&mut self, text: &str)
pub fn insert_text(&mut self, text: &str)
Insert text at cursor.
Sourcepub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Insert a single character.
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert a newline.
Sourcepub fn delete_backward(&mut self)
pub fn delete_backward(&mut self)
Delete backward (backspace).
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete forward (delete key).
Sourcepub fn delete_word_backward(&mut self)
pub fn delete_word_backward(&mut self)
Delete word backward (Ctrl+Backspace).
Sourcepub fn delete_to_end_of_line(&mut self)
pub fn delete_to_end_of_line(&mut self)
Delete to end of line (Ctrl+K).
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor right.
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor left by word.
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor right by word.
Sourcepub fn move_to_line_start(&mut self)
pub fn move_to_line_start(&mut self)
Move to start of line.
Sourcepub fn move_to_line_end(&mut self)
pub fn move_to_line_end(&mut self)
Move to end of line.
Sourcepub fn move_to_document_start(&mut self)
pub fn move_to_document_start(&mut self)
Move to start of document.
Sourcepub fn move_to_document_end(&mut self)
pub fn move_to_document_end(&mut self)
Move to end of document.
Sourcepub fn select_left(&mut self)
pub fn select_left(&mut self)
Extend selection left.
Sourcepub fn select_right(&mut self)
pub fn select_right(&mut self)
Extend selection right.
Sourcepub fn select_down(&mut self)
pub fn select_down(&mut self)
Extend selection down.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection.
Sourcepub fn page_up(&mut self, state: &TextAreaState)
pub fn page_up(&mut self, state: &TextAreaState)
Page up (move viewport and cursor up by viewport height).
Sourcepub fn page_down(&mut self, state: &TextAreaState)
pub fn page_down(&mut self, state: &TextAreaState)
Page down (move viewport and cursor down by viewport height).