TextArea

Struct TextArea 

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

A multi-line text editor widget

§Example

use revue::prelude::*;

let mut editor = TextArea::new()
    .content("Hello, World!\nLine 2")
    .line_numbers(true)
    .wrap(true);

// Handle key events
editor.handle_key(&Key::Char('a'));

Implementations§

Source§

impl TextArea

Source

pub fn new() -> Self

Create a new empty text area

Source

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

Set initial content

Source

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

Enable or disable line numbers

Source

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

Enable or disable word wrap

Source

pub fn read_only(self, read_only: bool) -> Self

Set read-only mode

Source

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

Set focused state

Source

pub fn tab_width(self, width: usize) -> Self

Set tab width

Source

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

Set placeholder text

Source

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

Set maximum number of lines

Source

pub fn fg(self, color: Color) -> Self

Set text color

Source

pub fn bg(self, color: Color) -> Self

Set background color

Source

pub fn cursor_fg(self, color: Color) -> Self

Set cursor color

Source

pub fn selection_bg(self, color: Color) -> Self

Set selection background color

Source

pub fn syntax(self, language: Language) -> Self

Enable syntax highlighting for a language

Source

pub fn syntax_with_theme(self, language: Language, theme: SyntaxTheme) -> Self

Enable syntax highlighting with a custom theme

Source

pub fn set_language(&mut self, language: Language)

Set the syntax highlighting language (mutable)

Source

pub fn get_syntax_language(&self) -> Language

Get the current highlighting language

Source

pub fn get_content(&self) -> String

Get the current text content

Source

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

Set the text content

Source

pub fn line_count(&self) -> usize

Get the number of lines

Source

pub fn cursor_position(&self) -> (usize, usize)

Get the cursor position (primary cursor for backward compatibility)

Source

pub fn cursor_positions(&self) -> Vec<(usize, usize)>

Get all cursor positions

Source

pub fn cursor_count(&self) -> usize

Get the number of cursors

Source

pub fn set_cursor(&mut self, line: usize, col: usize)

Set the cursor position (primary cursor, clears secondary cursors)

Source

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

Get selected text (from primary cursor)

Source

pub fn delete_selection(&mut self)

Delete selected text (from primary cursor)

Source

pub fn has_selection(&self) -> bool

Check if primary cursor has a selection

Source

pub fn start_selection(&mut self)

Start selection at current cursor (primary)

Source

pub fn clear_selection(&mut self)

Clear selection (all cursors)

Source

pub fn undo(&mut self)

Undo the last operation

Source

pub fn redo(&mut self)

Redo the last undone operation

Source

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

Insert a character at cursor

Source

pub fn insert_str(&mut self, s: &str)

Insert a string at cursor

Source

pub fn delete_char_before(&mut self)

Delete character before cursor (backspace)

Source

pub fn delete_char_at(&mut self)

Delete character at cursor (delete key)

Source

pub fn delete_line(&mut self)

Delete the current line

Source

pub fn duplicate_line(&mut self)

Duplicate the current line

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_home(&mut self)

Move to start of line

Source

pub fn move_end(&mut self)

Move to end of line

Source

pub fn move_document_start(&mut self)

Move to start of document

Source

pub fn move_document_end(&mut self)

Move to end of document

Source

pub fn move_word_left(&mut self)

Move cursor by word to the left

Source

pub fn move_word_right(&mut self)

Move cursor by word to the right

Source

pub fn page_up(&mut self, page_size: usize)

Page up

Source

pub fn page_down(&mut self, page_size: usize)

Page down

Source

pub fn select_all(&mut self)

Select all text

Source

pub fn open_find(&mut self)

Open find panel (Ctrl+F)

Source

pub fn open_replace(&mut self)

Open replace panel (Ctrl+H)

Source

pub fn close_find(&mut self)

Close find/replace panel

Source

pub fn is_find_open(&self) -> bool

Check if find panel is open

Source

pub fn find_state(&self) -> Option<&FindReplaceState>

Get find/replace state

Source

pub fn set_find_query(&mut self, query: &str)

Set find query and refresh matches

Source

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

Set replacement text

Source

pub fn find_next(&mut self)

Find next match (F3)

Source

pub fn find_previous(&mut self)

Find previous match (Shift+F3)

Source

pub fn replace_current(&mut self)

Replace current match

Source

pub fn replace_all(&mut self)

Replace all matches (Ctrl+Shift+H)

Source

pub fn toggle_case_sensitive(&mut self)

Toggle case sensitivity

Source

pub fn toggle_whole_word(&mut self)

Toggle whole word matching

Source

pub fn toggle_regex(&mut self)

Toggle regex mode

Source

pub fn add_cursor_at(&mut self, line: usize, col: usize)

Add cursor at position (Alt+Click)

Source

pub fn add_cursor_above(&mut self)

Add cursor above current (Ctrl+Alt+Up)

Source

pub fn add_cursor_below(&mut self)

Add cursor below current (Ctrl+Alt+Down)

Source

pub fn clear_secondary_cursors(&mut self)

Clear all secondary cursors (Escape)

Source

pub fn select_next_occurrence(&mut self)

Select next occurrence of current word/selection (Ctrl+D)

Source

pub fn handle_key(&mut self, key: &Key) -> bool

Handle key event

Source§

impl TextArea

Source

pub fn element_id(self, id: impl Into<String>) -> Self

Set element ID for CSS selector (#id)

Source

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

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Default for TextArea

Source§

fn default() -> Self

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

impl StyledView for TextArea

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for TextArea

Source§

fn id(&self) -> Option<&str>

Get element ID (for CSS #id selectors)
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors)
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM
Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors)
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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