Skip to main content

EditorHandle

Struct EditorHandle 

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

A clone-able, 'static handle to a RichTextEditor’s shared state.

Use this when a toolbar, palette, command panel, or other external widget needs to invoke editor commands from on_activate_fn / ctx.effect closures that outlive the borrow of &editor. RichTextEditor itself is move-only (the optional custom_context_menu factory holds a Box<dyn Fn>, which prevents Clone), so a closure cannot just capture editor.clone(). Obtain a handle via RichTextEditor::handle() and clone it into each closure that needs to issue commands.

EditorHandle mirrors the toolbar-relevant subset of the editor’s public API:

Cloning is cheap (an Rc clone). All clones share the same underlying state — mutations through any clone, through other clones, or through the originating RichTextEditor are all immediately observable through the same signals.

Implementations§

Source§

impl EditorHandle

Source

pub fn to_djot(&self) -> String

This editor’s content as Djot.

The counterpart to insert_djot: a toolbar or command that can write into an editor it did not build should be able to read it back the same way. Without this the only route to the text is the host’s own document bookkeeping, which knows about the editors it mounted and not about the ones a list or a card grid created — so a command ends up working on some surfaces and silently doing nothing on others.

Empty string on a serialisation error, matching TextDocument::to_djot’s own callers: a command reading an editor has no better answer than “nothing there”, and propagating a Result here would push that decision onto every call site.

Source

pub fn to_plain_text(&self) -> String

This editor’s content as the addressable plain text — the view whose character offsets are the document’s own.

The counterpart to to_djot for a caller that has an offset (a caret, a selection, a click) and needs to know what is there. An inline image appears as its U+FFFC, so offsets into this string are offsets into the document, character for character — which the .txt export’s view deliberately is not.

Empty string on error, for the same reason to_djot returns one.

Source

pub fn is_empty(&self) -> bool

Whether this editor holds no text at all.

character_count() == 0, so a document of one empty paragraph is empty but one holding only spaces is not — the distinction a caller usually wants is to_djot().trim().is_empty(), and this is the cheap O(1) pre-check.

Source

pub fn focused_signal(&self) -> Signal<bool>

Reactive signal — true while this editor holds keyboard focus. See RichTextEditor::focused_signal.

Source

pub fn select_range(&self, start: usize, end: usize)

Select the character range [start, end) without collapsing (anchor at start, caret at end). See RichTextEditor::select_range.

Source

pub fn replace_range(&self, start: usize, end: usize, text: &str)

Replace the character range [start, end) with text, leaving the caret after the inserted text.

The counterpart to select_range for callers that must rewrite a span rather than merely reveal it — a spell-check correction picked from a context menu, an autocorrect, a replace-this-occurrence action. It goes through the widget’s internal cursor, so the edit behaves exactly like typed text: it lands on the editor’s undo stack as one entry (the replacement is a single insert-over-selection), fires the document’s change notifications, and leaves the caret where the user would expect it.

Offsets are character positions, the same space cursor_position and select_range use. The inserted text inherits the character format at start, so correcting a word inside italic prose stays italic.

Reaching through TextDocument::cursor instead would mutate the document behind the widget’s back, leaving the caret decoupled from the edit — use this.

Source

pub fn replace_range_from( &self, start: usize, end: usize, text: &str, source: EditSource, )

As replace_range, saying which channel the text came through for on_text_inserted.

replace_range itself reports EditSource::Programmatic, which is what a handle-driven edit is by default: a toolbar, a menu command, a substitution the application made. An application that knows better should say so here rather than let the default stand. The distinction that matters most is an edit which merely puts back what the person typed — undoing an autocorrect, say. Those characters were typed, they are being typed again, and reporting them as the application’s own work would credit the application with the writer’s words.

One call rather than an insert plus a separate report, so the two cannot drift apart at a call site that later grows a second early return.

Source

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

Insert plain text at the caret, replacing any selection. The EditorHandle counterpart of RichTextEditor::insert_text, for callers that hold only a handle — a toolbar button or a global menu command.

Source

pub fn add_image_resource( &self, name: &str, mime_type: &str, bytes: &[u8], ) -> bool

Register an image’s bytes on this editor’s document, under name.

An inline image stores only a name; the paint pass resolves it to pixels through the document’s resource table. So an image inserted without this lays out and stays blank — and the name is also what a reload resolves against, which is why a host restoring a document has to register its images before the first paint rather than at insertion time only.

On the handle rather than only on the widget because commands operate on whichever editor has focus, including ones a list or card grid built that the host never mounted itself.

Source

pub fn image_resource_size(&self, name: &str) -> Option<(u32, u32)>

The natural pixel size of a registered image, decoded from its bytes.

What the file actually is, not what the document asks it to be shown at — so a host offering “reset to the original size” restores the picture’s own dimensions rather than a number remembered from when it was inserted, which is wrong the moment the file behind the name is replaced.

Decodes on call. That is deliberate: this answers an explicit, rare request, and caching it would mean holding a second copy of every image in the document for a question almost nobody asks.

Source

pub fn has_image_resource(&self, name: &str) -> bool

Whether this editor’s document already has an image under name.

Registering the same name twice appends a second resource row, so a host re-registering on every paint would grow the document without bound.

Source

pub fn insert_djot(&self, djot: &str)

Insert a fragment parsed from djot at the caret, replacing any selection.

Unlike insert_text, which drops its bytes into the current block verbatim (a \n becomes literal content, not a new paragraph), this parses block-level djot into a DocumentFragment, so inserting a standalone paragraph really does create one.

Source

pub fn insert_block(&self)

Split the current block at the caret, as pressing Enter does.

Source

pub fn insert_paragraph(&self, text: &str) -> bool

Insert text as a paragraph of its own at the caret: split here, fill the new block, split again, so whatever followed the caret continues in a third block.

Deliberately one call rather than three. Composing insert_block + insert_text + insert_block from outside re-enters the widget three times, and an application that rebuilds its editor in response to the first change notification is left driving a handle that no longer points at the mounted widget — the split lands and the text silently does not. Doing the whole edit under a single borrow, with one signal sync at the end, makes it atomic from the caller’s side. Returns false if any step failed, leaving the document as far as it got. Steps are not attempted after a failure: filling and re-splitting on top of a split that did not happen produces a mangled paragraph rather than a partial one, and the caller has no way to tell.

Source

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

The live selection as (anchor, position), unordered — anchor is where the selection started, position is where the caret is, so a backwards drag reports anchor > position. Equal values mean no selection.

Both ends are read under a single borrow, so the pair cannot tear. That is the reason to prefer this over pairing cursor_position with cursor_anchor_signal: the former is a live read of the cursor while the latter is a mirror refreshed on sync, so combining them mixes two different moments in time and can invent — or miss — a selection if the mirror lags. A caller deciding “is there a selection, and over what” wants one consistent answer.

Source

pub fn selected_text(&self) -> String

The selected text, or an empty string when nothing is selected.

O(selection), not O(document). Pairs with selection for a caller that needs the range and what is in it — a link dialog pre-filling its display name from what the writer highlighted, say.

Source

pub fn range_rect(&self, start: usize, end: usize) -> Option<Rect>

The window-space rectangle enclosing the character range [start, end).

The inverse of offset_at_point: that maps a point to an offset, this maps offsets back to a point. It is what a decoration drawn outside the editor — a margin annotation, a connector leader, a bracket spanning a paragraph — needs in order to line itself up with the text it refers to.

Coordinates match what the arena stores (viewport_origin + engine-local − scroll), so the result can be compared with any other widget’s bounds directly, and it tracks scrolling for free.

None before the first full layout. Focus is not required — a margin annotation must stay aligned whether or not the writer is typing.

Source

pub fn offset_rect(&self, offset: usize) -> Option<Rect>

The window-space caret rectangle at one offset — a zero-width range_rect, and the anchor point for a marker drawn at one end of a span (the triangle at a comment’s tail).

Source

pub fn range_content_rect(&self, start: usize, end: usize) -> Option<Rect>

The content-space rectangle enclosing [start, end) — y = 0 at the top of the laid-out text, unaffected by scrolling and by where the editor sits in the window.

The scroll-free counterpart to range_rect, and the one to reach for when the question is what proportion of the document is this rather than where is this on screen. Divided by content_height it gives a fraction an overview strip can draw against, for offsets the writer has long scrolled past — which window space cannot express at all, since it reports those relative to a viewport they are nowhere near.

None before the first full layout. Focus is not required.

Source

pub fn offset_content_rect(&self, offset: usize) -> Option<Rect>

The content-space caret rectangle at one offset — a zero-width range_content_rect.

Source

pub fn document_version(&self) -> Signal<u64>

Reactive counter that bumps on every document change — the handle mirror of RichTextEditor::document_version.

The change token a decoration drawn outside the editor binds, so it re-derives when the text moves under it. Without it such a widget has only the scroll metrics to go on, and those move on a reflow but not on an edit that leaves the height alone — which is most edits, and exactly the ones that shift the offsets a mark is anchored to.

Source

pub fn content_height(&self) -> Option<f32>

Height of the laid-out text, in the same space range_content_rect reports.

The denominator that turns a content rect into a fraction of the document. None before the first full layout — the same gate the rect queries use, so a caller that has one has the other and the division is never against a stale height.

This is the text’s height, not the widget’s: an editor laid out taller than its content (a short scene in a tall pane) reports the text.

Source

pub fn offset_at_point(&self, window_point: Point) -> Option<usize>

Hit-test a point — in window coordinates, as a context_menu factory receives it — to a document character offset. None when the point resolves to no text (past the last glyph on an empty line, outside the body, etc.).

Lets a custom context-menu factory resolve “the word under the pointer” from the right-click position, since a bare right-click does not move the caret on its own.

Source

pub fn reposition_caret_for_context_menu(&self, window_point: Point)

Reposition the caret to a right-click point (window coordinates) unless the click lands inside the current selection (then the selection is preserved). Call this at the top of a custom context_menu factory so the menu’s Paste — and any caret-relative action — operates where the user clicked, exactly as the built-in menu and the single-line field do.

Source

pub fn reveal_range( &self, ctx: &mut EventContext<'_>, start: usize, end: usize, ) -> bool

Scroll the character range [start, end) into view, reporting whether this editor could — it has a layout to locate the range in, and is on screen rather than parked dormant. See RichTextEditor::reveal_range.

When it answers false because there is no layout yet, the coarser reveal_widget is the way to get one.

Source

pub fn reveal_widget(&self, ctx: &mut EventContext<'_>) -> bool

Scroll the editor itself into view — the coarse fallback for the one case reveal_range cannot serve at all. Reports whether this editor could: it has been built, so the arena knows a widget to scroll to, and it is on screen rather than parked dormant.

A row of a stream that has never been painted has no full layout, so there is no rect to locate an offset in and reveal_range answers false — for ever, because the row only gets a layout when it is painted and it is only painted when it comes on screen. That is a deadlock a range reveal has no way out of: a match found in row 31 of a Book leaves the page exactly where it was, with the counter cheerfully reading 1 of 40.

Revealing by widget breaks it, because the arena knows where row 31 is laid out whether or not its text has been shaped. The row comes on screen, the next paint gives it a layout, and a later reveal_range can then put the match itself where the caller wants it. Coarser on purpose: this reveals the row, not the offset inside it.

Source

pub fn focus(&self, ctx: &mut EventContext<'_>)

Move keyboard focus onto the editor. Lets a control built above the editor — a find banner returning focus to the prose on Escape — put the caret back where the user expects. A no-op until the editor has built at least once (its wrapper id is stashed then).

Source

pub fn caret_char_format(&self) -> TextFormat

Read the current character format at the caret. When a selection is active, reads from selection_start() rather than position() so toolbar bistate stays stable across selection extension (same rule as RichTextEditor::caret_char_format).

Source

pub fn set_bold(&self, enabled: bool)

Apply bold to the current selection.

Source

pub fn set_italic(&self, enabled: bool)

Apply italic to the current selection.

Source

pub fn set_underline(&self, enabled: bool)

Apply underline to the current selection.

Source

pub fn set_strikethrough(&self, enabled: bool)

Apply strikethrough to the current selection.

Source

pub fn set_font_family(&self, family: impl Into<String>)

Set the font family for the current selection (a character-format change applied over the selected range). Like the other char-format setters (set_bold, …), this is a no-op when there is no selection — the document model has no typing/pending format, so a bare caret has no range to format. family must be a name resolvable by the shared typesetter’s font registrar — e.g. a value chosen from a FontPicker.

Source

pub fn set_font_size(&self, size: u32)

Set the font size (in points) for the current selection.

Source

pub fn set_typography_defaults(&self, defaults: EditorTypographyDefaults)

Set the non-destructive default typography (font family / line height / first-line indent) filled onto runs and blocks with no explicit override. Unlike set_font_family / set_font_size — which mutate the selected text — this is a display-time default: it never touches the document, undo stack, or modified flag. Schedules a relayout + repaint.

Source

pub fn get_typography_defaults(&self) -> EditorTypographyDefaults

Current default typography.

Source

pub fn set_font_size_scale(&self, scale: f32)

Set the per-editor logical font-size multiplier. See RichTextEditor::set_font_size_scale.

Source

pub fn get_font_size_scale(&self) -> f32

Current per-editor font-size scale (1.0 = 100 %).

Source

pub fn set_typewriter(&self, anchor: Option<f32>)

Set the typewriter-scrolling anchor — the EditorHandle counterpart of RichTextEditor::set_typewriter. None turns pinning off.

This is the door a host uses to keep the pin following a live setting, the same way set_typography_defaults keeps typography following one.

Source

pub fn get_typewriter(&self) -> Option<f32>

Current typewriter anchor.

Source

pub fn set_command_filter(&self, filter: CommandFilter)

Narrow (or restore) what the keyboard may do — the EditorHandle counterpart of RichTextEditor::set_command_filter, for hosts that drive a drafting mode from a settings or session effect after the editor is mounted.

Source

pub fn command_filter(&self) -> CommandFilter

The filter currently in force on this editor.

Source

pub fn set_caret_highlight(&self, highlight: Option<CaretHighlight>)

Draw an ambient band behind the caret’s sentence or paragraph — the EditorHandle counterpart of RichTextEditor::set_caret_highlight, for hosts that re-push it from a settings or theme effect after the editor is mounted.

Source

pub fn get_caret_highlight(&self) -> Option<CaretHighlight>

What this editor’s caret band is currently configured to draw.

Source

pub fn caret_window_rect(&self) -> Option<Rect>

The caret’s rectangle in absolute window (tree) coordinates — the EditorHandle counterpart of RichTextEditor::caret_window_rect. None when unfocused or not yet laid out.

Source

pub fn apply_text_format(&self, fmt: TextFormat)

Apply an arbitrary [TextFormat] (escape hatch for fields not covered by the dedicated setters: letter_spacing, foreground_color, …).

Source

pub fn toggle_bold(&self)

Toggle bold on the current selection.

Source

pub fn toggle_italic(&self)

Toggle italic on the current selection.

Source

pub fn toggle_underline(&self)

Toggle underline on the current selection.

Source

pub fn toggle_strikethrough(&self)

Toggle strikethrough on the current selection.

Source

pub fn is_bold(&self) -> bool

Whether the selection / typing position is bold.

Source

pub fn is_italic(&self) -> bool

Whether italic.

Point the selection at href.

Merges, so formatting already on the range is kept. A collapsed selection formats nothing (as everywhere else), so a caller linking existing text should select it first — see link_at_caret for the range of a link already there.

Take the link off the selection, leaving its text.

The link the caret is in, and how far it reaches.

Coalesced across the runs an inner mark splits a link into, so the range covers the whole link rather than the piece under the caret. None when the caret is not on a link.

Whether the caret / selection sits on a link.

Source

pub fn is_underline(&self) -> bool

Whether underline.

Source

pub fn is_strikethrough(&self) -> bool

Whether strikethrough.

Source

pub fn set_superscript(&self, enabled: bool)

Raise the selection to superscript, or return it to the baseline.

Source

pub fn set_subscript(&self, enabled: bool)

Lower the selection to subscript, or return it to the baseline.

Source

pub fn set_vertical_alignment(&self, alignment: CharVerticalAlignment)

Set the selection’s vertical alignment directly.

Source

pub fn get_vertical_alignment(&self) -> CharVerticalAlignment

The caret’s vertical alignment, Normal when unset.

Source

pub fn is_superscript(&self) -> bool

True while the caret sits in superscript text.

Source

pub fn is_subscript(&self) -> bool

True while the caret sits in subscript text.

Source

pub fn toggle_superscript(&self)

Flip superscript on the selection. Turning it on replaces subscript.

Source

pub fn toggle_subscript(&self)

Flip subscript on the selection. Turning it on replaces superscript.

Source

pub fn apply_block_format(&self, fmt: BlockFormat)

Apply an arbitrary [BlockFormat] to the caret’s block.

Source

pub fn set_alignment(&self, alignment: Alignment)

Set paragraph alignment for the caret’s block.

Source

pub fn clear_direction(&self)

Unset the block’s direction, handing the paragraph back to automatic detection.

Not the same as setting left-to-right. An explicit direction pins the paragraph and overrides the bidi algorithm, so “clearing” a direction by writing LeftToRight would force Arabic and Hebrew prose to lay out backwards. Only an unset direction lets the text speak for itself.

Source

pub fn set_direction(&self, direction: TextDirection)

Set the base reading direction of the caret’s block. See RichTextEditor::set_direction.

Source

pub fn set_heading_level(&self, level: u8)

Set heading level for the caret’s block. 0 = plain paragraph, 1..=6 follow the HTML <h1>..<h6> convention.

Source

pub fn get_alignment(&self) -> Alignment

Current block alignment.

Source

pub fn get_direction(&self) -> Option<TextDirection>

The block’s explicitly-set reading direction, if it has one.

None means the writer never chose — the bidi algorithm decides from the text. That is a genuinely different state from an explicit left-to-right, so it is reported rather than defaulted: a toggle needs to show “auto” as its own setting.

Source

pub fn get_heading_level(&self) -> u8

Current heading level (0 = plain paragraph).

Source

pub fn insert_list(&self, ordered: bool)

Wrap the caret’s block in a list. ordered = true uses decimal numbering, false uses bullet discs.

Source

pub fn create_list(&self, style: ListStyle)

Wrap the caret’s block in a list with an explicit [ListStyle].

Source

pub fn indent(&self)

Indent the caret’s current list item by one nesting level. No-op when the caret is not inside a list. Equivalent to Tab.

Source

pub fn outdent(&self)

Outdent the caret’s current list item by one nesting level. No-op at depth 0. Equivalent to Shift+Tab.

Source

pub fn remove_from_list(&self)

Take the caret’s block out of its list entirely, leaving a plain paragraph. No-op when the caret is not inside a list.

See RichTextEditor::remove_from_list for why this is separate from outdent, which stops at depth 0 by design.

Source

pub fn is_in_blockquote(&self) -> bool

True iff the caret currently sits inside a blockquote frame at any nesting depth.

Source

pub fn selection_spans_multiple_frames(&self) -> bool

True iff the selection spans more than one frame — the “Toggle blockquote” affordance should be disabled in this case.

Source

pub fn toggle_blockquote(&self)

Wrap the current block/selection in a blockquote, or unwrap the innermost enclosing blockquote if already inside one. Toolbar counterpart for a Ctrl+Shift+Q-style toggle.

Source

pub fn increase_blockquote_depth(&self)

Wrap the current block in a deeper nested quote. Equivalent to Tab inside a blockquote.

Source

pub fn decrease_blockquote_depth(&self)

Pop the caret out of one blockquote nesting level. Equivalent to Shift+Tab inside a blockquote.

Source

pub fn insert_table(&self, rows: usize, columns: usize)

Insert a fresh rows × columns table at the caret.

Source

pub fn remove_current_table(&self)

Remove the table containing the caret. No-op outside a table.

Source

pub fn insert_row_above(&self)

Insert a row above the caret’s current table row.

Source

pub fn insert_row_below(&self)

Insert a row below the caret’s current table row.

Source

pub fn insert_column_before(&self)

Insert a column before the caret’s current table column.

Source

pub fn insert_column_after(&self)

Insert a column after the caret’s current table column.

Source

pub fn remove_current_row(&self)

Remove the caret’s current table row.

Source

pub fn remove_current_column(&self)

Remove the caret’s current table column.

Source

pub fn is_in_table(&self) -> bool

Whether the caret is currently inside a table cell.

Source

pub fn undo(&self)

Undo the most recent edit. No-op when the undo stack is empty.

Source

pub fn break_undo_merge(&self)

Close the current undo entry, so the next edit starts a new one.

Typing coalesces into word-sized undo steps by looking only at the shape of two edits — adjacent, moments apart. It cannot see that the user did something else in between, somewhere else in the application, that they would remember as a dividing line. A host that knows one was crossed says so here, and the burst before it stops merging with the burst after.

Source

pub fn redo(&self)

Redo the most recently undone edit. No-op when the redo stack is empty.

Source

pub fn begin_edit_block(&self)

Begin grouping subsequent edits into a single undo entry. Pair with end_edit_block, or prefer the scoped edit_block.

Source

pub fn end_edit_block(&self)

Close the group opened by begin_edit_block.

Source

pub fn edit_block<R>(&self, edits: impl FnOnce() -> R) -> R

Run edits as one undo entry — the pairing-safe form.

Source

pub fn copy(&self, ctx: &EventContext<'_>)

Copy the current selection to the system clipboard (plain + HTML payloads). No-op when there is no selection. See RichTextEditor::copy.

Source

pub fn cut(&self, ctx: &EventContext<'_>)

Cut the current selection: copy first, then remove. See RichTextEditor::cut.

Source

pub fn paste(&self, ctx: &EventContext<'_>)

Paste from the system clipboard. Prefers an in-process fragment over HTML over plain text. See RichTextEditor::paste.

Source

pub fn paste_unformatted(&self, ctx: &EventContext<'_>)

Paste plain text only, stripping any rich payload. See RichTextEditor::paste_unformatted.

Source

pub fn can_paste(&self, ctx: &EventContext<'_>) -> bool

Whether a paste would insert anything — true iff the system clipboard carries text or an HTML payload. A point-in-time query (clipboard contents are not reactively observable), taking the active EventContext. Use it to drive a context-menu / toolbar Paste enable-state, re-querying on menu-open. Mirrors RichTextEditor::can_paste.

Source

pub fn select_all(&self)

Select the entire document programmatically. Resets the Ctrl+A ladder so a subsequent Ctrl+A starts fresh at level 1. Mirrors RichTextEditor::select_all.

Source

pub fn delete_selection(&self)

Delete the current selection. No-op when nothing is selected. Mirrors RichTextEditor::delete_selection.

Source

pub fn format_version(&self) -> Signal<u64>

Bumps on every format-only document event (bold / italic / heading / alignment / list-style changes). See RichTextEditor::format_version.

Source

pub fn cursor_position(&self) -> usize

The live caret offset — reads cursor.position() directly, unbatched. Unlike cursor_position_signal, whose stored value lags one frame behind a just-typed printable character (the insert is deferred to the frame loop and the signal is only re-synced on the next caret event), this always reflects the true caret — what a host that recomputes highlights on a frame tick must read. Mirrors RichTextEditor::cursor_position.

Source

pub fn is_composing(&self) -> bool

true while an IME composition is actively in progress. Mirrors RichTextEditor::is_composing.

Source

pub fn cursor_position_signal(&self) -> Signal<usize>

Reactive caret position signal.

Source

pub fn cursor_anchor_signal(&self) -> Signal<usize>

Reactive selection anchor signal.

Source

pub fn has_selection(&self) -> Signal<bool>

Reactive selection-non-empty signal.

Source

pub fn can_undo(&self) -> Signal<bool>

Reactive undo-availability signal (toolbar enable-state source).

Source

pub fn can_redo(&self) -> Signal<bool>

Reactive redo-availability signal.

Trait Implementations§

Source§

impl Clone for EditorHandle

Source§

fn clone(&self) -> EditorHandle

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
Source§

impl Debug for EditorHandle

Source§

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

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

impl TextSurface for EditorHandle

Source§

fn history_frozen(&self) -> bool

The editor’s own CommandFilter is the authority: a host that has imposed ForwardOnly or ReadOnly on this editor must not be able to route around it from a menu.

Source§

fn can_undo(&self) -> bool

Is there anything in this surface’s own history to step back through?
Source§

fn can_redo(&self) -> bool

Is there anything to step forward into?
Source§

fn undo(&self)

Source§

fn redo(&self)

Source§

fn has_selection(&self) -> bool

Is any text selected right now?
Source§

fn is_read_only(&self) -> bool

Does this surface refuse edits? Cut and Paste are meaningless when it does.
Source§

fn allows_copy(&self) -> bool

May its contents be copied at all? A password field says no.
Source§

fn cut(&self, ctx: &EventContext<'_>)

Source§

fn copy(&self, ctx: &EventContext<'_>)

Source§

fn paste(&self, ctx: &EventContext<'_>)

Source§

fn paste_plain(&self, ctx: &EventContext<'_>)

Paste stripped of formatting. A surface with no formatting to strip should do a plain paste rather than nothing.
Source§

fn select_all(&self)

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
§

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

§

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
§

impl<T> Downcast for T
where T: 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.
§

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.
§

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.
§

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.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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