pub struct TextEditor { /* private fields */ }Expand description
Text editor with cursor and selection management.
Implementations§
Source§impl TextEditor
impl TextEditor
Sourcepub fn cursor(&self) -> &TextCursor
pub fn cursor(&self) -> &TextCursor
Get the cursor position.
Sourcepub fn selection(&self) -> Option<&TextSelection>
pub fn selection(&self) -> Option<&TextSelection>
Get the selection, if any.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Check if there’s an active selection.
Sourcepub fn set_cursor(&mut self, position: usize)
pub fn set_cursor(&mut self, position: usize)
Set the cursor position (byte offset).
Sourcepub fn move_cursor_start(&mut self)
pub fn move_cursor_start(&mut self)
Move cursor to start of text.
Sourcepub fn move_cursor_end(&mut self)
pub fn move_cursor_end(&mut self)
Move cursor to end of text.
Sourcepub fn move_cursor_left(&mut self)
pub fn move_cursor_left(&mut self)
Move cursor left by one character.
Sourcepub fn move_cursor_right(&mut self)
pub fn move_cursor_right(&mut self)
Move cursor right by one character.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection.
Sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert a character at the cursor position.
Sourcepub fn insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert a string at the cursor position.
Sourcepub fn delete_char(&mut self)
pub fn delete_char(&mut self)
Delete character before cursor (backspace).
Sourcepub fn delete_char_forward(&mut self)
pub fn delete_char_forward(&mut self)
Delete character after cursor (delete key).
Sourcepub fn delete_selection(&mut self)
pub fn delete_selection(&mut self)
Delete the current selection.
Sourcepub fn selected_text(&self) -> Option<&str>
pub fn selected_text(&self) -> Option<&str>
Get selected text.
Sourcepub fn replace_selection(&mut self, text: &str)
pub fn replace_selection(&mut self, text: &str)
Replace selected text with new text.
Auto Trait Implementations§
impl Freeze for TextEditor
impl RefUnwindSafe for TextEditor
impl Send for TextEditor
impl Sync for TextEditor
impl Unpin for TextEditor
impl UnsafeUnpin for TextEditor
impl UnwindSafe for TextEditor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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