Skip to main content

RichEditHandle

Struct RichEditHandle 

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

A cheap, cloneable handle to a shared RichEditCore, so a toolbar can drive the same editor the widget renders. All mutating calls request a redraw.

Implementations§

Source§

impl RichEditHandle

Source

pub fn exec(&self, cmd: &RichCommand)

Apply a formatting command through the shared core.

Source

pub fn common_style_of_selection(&self) -> CommonStyle

Summary of the styles under the current selection (drives toolbar state).

Source

pub fn select_all(&self)

Select the whole document, then request a redraw.

Source

pub fn set_caret(&self, pos: DocPos)

Move the caret to pos (clamped onto a valid position), collapsing any selection, and request a redraw.

Source

pub fn set_selection(&self, range: DocRange)

Set the selection to rangerange.start becomes the fixed anchor and range.end the moving caret, each clamped onto a valid position — and request a redraw.

Source

pub fn selection(&self) -> DocRange

The current selection (anchor → caret; collapsed when they coincide).

Source

pub fn plain_text(&self) -> String

The document’s plain text (blocks joined by \n).

Source

pub fn load(&self, doc: RichDoc)

Replace the editor’s document with doc, resetting the caret to the start and discarding the undo/redo history (the loaded document is the new baseline). Requests a redraw.

Source

pub fn undo(&self)

Undo one step through the shared core, requesting a redraw on change.

Source

pub fn redo(&self)

Redo one step through the shared core, requesting a redraw on change.

Source

pub fn can_undo(&self) -> bool

Whether an undo step is available.

Source

pub fn can_redo(&self) -> bool

Whether a redo step is available.

Source

pub fn begin_preview(&self)

Begin a live-preview session — see RichEditCore::begin_preview. Call when a colour dialog opens, before any preview exec.

Source

pub fn commit_preview(&self)

Commit the live preview (dialog’s Select) — see RichEditCore::commit_preview.

Source

pub fn cancel_preview(&self)

Cancel the live preview (dialog’s Cancel / Escape / close) — restores the state captured when the preview began. See RichEditCore::cancel_preview.

Source

pub fn is_previewing(&self) -> bool

Whether a live preview is currently active. Exposed so a host can assert (in tests) that every dialog-dismissal route unwinds the session.

Source

pub fn is_preview_dirty(&self) -> bool

Whether the active preview session has changed the document. The colour dialog’s click-away handler reads this to decide whether to commit the live change (one undo step) or cancel it silently. See RichEditCore::is_preview_dirty.

Trait Implementations§

Source§

impl Clone for RichEditHandle

Source§

fn clone(&self) -> RichEditHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. 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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.