pub struct CodeEditorHandle { /* private fields */ }Expand description
A handle onto a live editor, cloneable and detachable from the widget.
The EditorHandle pattern: an app keeps one to drive the editor from a
toolbar, a shortcut, or a test without holding the widget itself.
Implementations§
Source§impl CodeEditorHandle
impl CodeEditorHandle
Sourcepub fn cursor_position(&self) -> usize
pub fn cursor_position(&self) -> usize
The caret’s document position.
Sourcepub fn cursor_position_signal(&self) -> Signal<usize>
pub fn cursor_position_signal(&self) -> Signal<usize>
The primary caret’s document position — a character offset into the whole document, not a line or column — as a reactive signal. Bind it in a status bar to show a caret position that tracks every caret move, not only edits.
Sourcepub fn caret_count(&self) -> Signal<usize>
pub fn caret_count(&self) -> Signal<usize>
Live caret count — 1 unless multi-caret editing is active.
Sourcepub fn bracket_match(&self) -> Signal<Option<(usize, usize)>>
pub fn bracket_match(&self) -> Signal<Option<(usize, usize)>>
The bracket next to the caret and its match, as document positions, or
None. Populated only when the editor was configured with
match_brackets and bracket pairs; a status surface can bind it, or an
app can read it to drive its own overlay.
pub fn has_selection(&self) -> Signal<bool>
pub fn can_undo(&self) -> Signal<bool>
Sourcepub fn undo(&self)
pub fn undo(&self)
Undo this editor’s last edit.
The handle could report can_undo long before it could
act on it, which left a host able to light an Undo button here and
unable to make it do anything. Ctrl+Z inside the widget always worked;
this is the same command from outside.
Sourcepub fn select_all(&self)
pub fn select_all(&self)
Select the whole document.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Is this editor refusing edits?
pub fn can_redo(&self) -> Signal<bool>
Sourcepub fn document_version(&self) -> Signal<u64>
pub fn document_version(&self) -> Signal<u64>
Bumps on every content or format change.
pub fn scroll_y(&self) -> Signal<f32>
Trait Implementations§
Source§impl Clone for CodeEditorHandle
impl Clone for CodeEditorHandle
Source§fn clone(&self) -> CodeEditorHandle
fn clone(&self) -> CodeEditorHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CodeEditorHandle
impl Debug for CodeEditorHandle
Source§impl TextSurface for CodeEditorHandle
impl TextSurface for CodeEditorHandle
Source§fn paste_plain(&self, ctx: &EventContext<'_>)
fn paste_plain(&self, ctx: &EventContext<'_>)
Code has no rich formatting to strip; the plain paste is the paste.
Source§fn can_undo(&self) -> bool
fn can_undo(&self) -> bool
fn undo(&self)
fn redo(&self)
Source§fn has_selection(&self) -> bool
fn has_selection(&self) -> bool
Source§fn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Source§fn allows_copy(&self) -> bool
fn allows_copy(&self) -> bool
Source§fn history_frozen(&self) -> bool
fn history_frozen(&self) -> bool
fn cut(&self, ctx: &EventContext<'_>)
fn copy(&self, ctx: &EventContext<'_>)
fn paste(&self, ctx: &EventContext<'_>)
fn select_all(&self)
Auto Trait Implementations§
impl !RefUnwindSafe for CodeEditorHandle
impl !Send for CodeEditorHandle
impl !Sync for CodeEditorHandle
impl !UnwindSafe for CodeEditorHandle
impl Freeze for CodeEditorHandle
impl Unpin for CodeEditorHandle
impl UnsafeUnpin for CodeEditorHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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