Skip to main content

TextEditManager

Struct TextEditManager 

Source
pub struct TextEditManager {
    pub multi_cursor: Option<MultiCursorState>,
    pub blink: BlinkState,
    pub preedit_text: Option<String>,
    pub preedit_cursor_begin: i32,
    pub preedit_cursor_end: i32,
    pub display_list_dirty: bool,
}
Expand description

Unified text editing manager.

multi_cursor is the single source of truth for cursor/selection positions. blink manages the caret blink animation. SelectionManager (sibling module) handles non-editable text drag-select.

Fields§

§multi_cursor: Option<MultiCursorState>

Multi-cursor state for contenteditable elements (Sublime Text style). Some whenever a contenteditable element has focus. Source of truth for edit_text() and display list painting.

§blink: BlinkState

Cursor blink animation state.

§preedit_text: Option<String>

IME preedit (composition) text currently being composed. Applies to the primary cursor only.

§preedit_cursor_begin: i32

Byte offset of cursor within preedit text (from IME), or -1 if unset. Uses -1 sentinel (rather than Option) to match platform IME C API conventions.

§preedit_cursor_end: i32

Byte offset of cursor end within preedit text (from IME), or -1 if unset. Uses -1 sentinel (rather than Option) to match platform IME C API conventions.

§display_list_dirty: bool

Set to true by any mutation that changes visual output.

Implementations§

Source§

impl TextEditManager

Source

pub fn new() -> Self

Create a new text edit manager with no active editing state

Source

pub fn take_display_list_dirty(&mut self) -> bool

Check and clear the display_list_dirty flag.

Source

pub fn mark_dirty(&mut self)

Mark that the display list needs regeneration.

Source

pub fn has_active_editing(&self) -> bool

Whether a contenteditable element is currently being edited.

Source

pub fn get_editing_dom_id(&self) -> Option<DomId>

Get the DomId of the node being edited.

Source

pub fn get_editing_node_id(&self) -> Option<NodeId>

Get the NodeId of the node being edited.

Source

pub fn get_primary_cursor(&self) -> Option<TextCursor>

Get the primary cursor position (last-added cursor).

Source

pub fn should_draw_cursor(&self) -> bool

Whether the cursor should be drawn (editing active AND blink visible).

Source

pub fn initialize_editing( &mut self, cursor: TextCursor, dom_id: DomId, node_id: NodeId, contenteditable_key: u64, )

Initialize editing for a newly focused contenteditable element.

Creates a MultiCursorState with a single cursor, starts the blink, and sets preedit to None.

Source

pub fn clear_editing(&mut self)

End editing (focus left the contenteditable element).

Source

pub fn set_preedit(&mut self, text: String, cursor_begin: i32, cursor_end: i32)

Set the IME preedit (composition) text.

Source

pub fn clear_preedit(&mut self)

Clear the IME preedit text (composition ended or cancelled).

Source

pub fn build_cursor_locations(&self) -> Vec<(DomId, NodeId, TextCursor)>

Build the Vec of cursor locations for LayoutContext.

Returns all cursor positions from MultiCursorState, or empty if not editing.

Source

pub fn build_text_selections_map(&self) -> BTreeMap<DomId, TextSelection>

Build a TextSelection map for the display list’s paint_selections.

Extracts Range selections from MultiCursorState into the format that LayoutContext.text_selections expects: BTreeMap<DomId, TextSelection>. The affected_nodes map uses the editing node’s NodeId as key. NOTE: only one range per node is supported — if multiple cursors have range selections on the same node, later ranges overwrite earlier ones.

Trait Implementations§

Source§

impl Clone for TextEditManager

Source§

fn clone(&self) -> TextEditManager

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 TextEditManager

Source§

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

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

impl Default for TextEditManager

Source§

fn default() -> Self

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

impl PartialEq for TextEditManager

Only compares multi_cursor — blink state, preedit, and dirty flag are transient visual state that should not affect logical equality of the editing session.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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