pub struct TextArea {
pub buffer: TextBuffer,
pub cursor: CursorState,
pub undo_stack: UndoStack,
pub scroll_offset: usize,
pub show_line_numbers: bool,
pub style: Style,
pub cursor_style: Style,
pub selection_style: Style,
pub line_number_style: Style,
/* private fields */
}Expand description
A multi-line text editing widget.
Supports cursor movement, text selection, undo/redo, soft wrapping, optional line numbers, and pluggable syntax highlighting.
Fields§
§buffer: TextBufferThe text content.
cursor: CursorStateCursor and selection state.
undo_stack: UndoStackUndo/redo history.
scroll_offset: usizeIndex of the first visible logical line.
show_line_numbers: boolWhether to show line numbers in the left gutter.
style: StyleBase text style.
cursor_style: StyleStyle for the cursor cell.
selection_style: StyleStyle for selected text.
line_number_style: StyleStyle for line numbers.
Implementations§
Source§impl TextArea
impl TextArea
Sourcepub fn with_highlighter(self, h: Box<dyn Highlighter>) -> Self
pub fn with_highlighter(self, h: Box<dyn Highlighter>) -> Self
Set a custom syntax highlighter.
Sourcepub fn with_style(self, s: Style) -> Self
pub fn with_style(self, s: Style) -> Self
Set the base text style.
Sourcepub fn with_line_numbers(self, show: bool) -> Self
pub fn with_line_numbers(self, show: bool) -> Self
Enable or disable line numbers.
Sourcepub fn with_cursor_style(self, s: Style) -> Self
pub fn with_cursor_style(self, s: Style) -> Self
Set the cursor display style.
Sourcepub fn with_selection_style(self, s: Style) -> Self
pub fn with_selection_style(self, s: Style) -> Self
Set the selection display style.
Sourcepub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Insert a character at the cursor position.
Sourcepub fn insert_str(&mut self, text: &str)
pub fn insert_str(&mut self, text: &str)
Insert a string at the cursor position.
Sourcepub fn delete_backward(&mut self)
pub fn delete_backward(&mut self)
Delete the character before the cursor (backspace).
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete the character at the cursor position (delete key).
Sourcepub fn delete_selection(&mut self) -> bool
pub fn delete_selection(&mut self) -> bool
Delete the currently selected text, if any.
Returns true if a selection was deleted.
Sourcepub fn ensure_cursor_visible(&mut self, area_height: u16)
pub fn ensure_cursor_visible(&mut self, area_height: u16)
Ensure the cursor is within the visible area, adjusting scroll.