Skip to main content

TextArea

Struct TextArea 

Source
pub struct TextArea { /* private fields */ }
Expand description

Multi-line text editor widget.

Implementations§

Source§

impl TextArea

Source

pub fn new() -> Self

Create a new empty text area.

Source

pub fn handle_event(&mut self, event: &Event) -> bool

Handle a terminal event.

Returns true if the state changed.

Source

pub fn with_text(self, text: &str) -> Self

Set initial text content (builder).

Source

pub fn with_placeholder(self, text: impl Into<String>) -> Self

Set placeholder text (builder).

Source

pub fn with_focus(self, focused: bool) -> Self

Set focused state (builder).

Source

pub fn with_line_numbers(self, show: bool) -> Self

Enable line numbers (builder).

Source

pub fn with_style(self, style: Style) -> Self

Set base style (builder).

Source

pub fn with_cursor_line_style(self, style: Style) -> Self

Set cursor line highlight style (builder).

Source

pub fn with_selection_style(self, style: Style) -> Self

Set selection style (builder).

Source

pub fn with_soft_wrap(self, wrap: bool) -> Self

Enable soft wrapping (builder).

Source

pub fn with_max_height(self, max: usize) -> Self

Set maximum height in lines (builder). 0 = fill available area.

Source

pub fn text(&self) -> String

Get the full text content.

Source

pub fn set_text(&mut self, text: &str)

Set the full text content (resets cursor and undo history).

Source

pub fn line_count(&self) -> usize

Number of lines.

Source

pub fn cursor(&self) -> CursorPosition

Current cursor position.

Source

pub fn set_cursor_position(&mut self, pos: CursorPosition)

Set cursor position (clamped to bounds). Clears selection.

Source

pub fn is_empty(&self) -> bool

Whether the textarea is empty.

Source

pub fn selection(&self) -> Option<Selection>

Current selection, if any.

Source

pub fn selected_text(&self) -> Option<String>

Get selected text.

Source

pub fn is_focused(&self) -> bool

Whether the widget has focus.

Source

pub fn set_focused(&mut self, focused: bool)

Set focus state.

Source

pub fn editor(&self) -> &Editor

Access the underlying editor.

Source

pub fn editor_mut(&mut self) -> &mut Editor

Mutable access to the underlying editor.

Source

pub fn insert_text(&mut self, text: &str)

Insert text at cursor.

Source

pub fn insert_char(&mut self, ch: char)

Insert a single character.

Source

pub fn insert_newline(&mut self)

Insert a newline.

Source

pub fn delete_backward(&mut self)

Delete backward (backspace).

Source

pub fn delete_forward(&mut self)

Delete forward (delete key).

Source

pub fn delete_word_backward(&mut self)

Delete word backward (Ctrl+Backspace).

Source

pub fn delete_to_end_of_line(&mut self)

Delete to end of line (Ctrl+K).

Source

pub fn undo(&mut self)

Undo last edit.

Source

pub fn redo(&mut self)

Redo last undo.

Source

pub fn move_left(&mut self)

Move cursor left.

Source

pub fn move_right(&mut self)

Move cursor right.

Source

pub fn move_up(&mut self)

Move cursor up.

Source

pub fn move_down(&mut self)

Move cursor down.

Source

pub fn move_word_left(&mut self)

Move cursor left by word.

Source

pub fn move_word_right(&mut self)

Move cursor right by word.

Source

pub fn move_to_line_start(&mut self)

Move to start of line.

Source

pub fn move_to_line_end(&mut self)

Move to end of line.

Source

pub fn move_to_document_start(&mut self)

Move to start of document.

Source

pub fn move_to_document_end(&mut self)

Move to end of document.

Source

pub fn select_left(&mut self)

Extend selection left.

Source

pub fn select_right(&mut self)

Extend selection right.

Source

pub fn select_up(&mut self)

Extend selection up.

Source

pub fn select_down(&mut self)

Extend selection down.

Source

pub fn select_all(&mut self)

Select all.

Source

pub fn clear_selection(&mut self)

Clear selection.

Source

pub fn page_up(&mut self, state: &TextAreaState)

Page up (move viewport and cursor up by viewport height).

Source

pub fn page_down(&mut self, state: &TextAreaState)

Page down (move viewport and cursor down by viewport height).

Trait Implementations§

Source§

impl Clone for TextArea

Source§

fn clone(&self) -> TextArea

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextArea

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TextArea

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StatefulWidget for TextArea

Source§

type State = TextAreaState

The state type associated with this widget.
Source§

fn render(&self, area: Rect, frame: &mut Frame<'_>, state: &mut Self::State)

Render the widget into the frame, potentially modifying state. Read more
Source§

impl Widget for TextArea

Source§

fn render(&self, area: Rect, frame: &mut Frame<'_>)

Render the widget into the frame at the given area. Read more
Source§

fn is_essential(&self) -> bool

Whether this widget is essential and should always render. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more