Skip to main content

TextEditHistory

Struct TextEditHistory 

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

Production UTF-8 text editing buffer with coalesced Undo/Redo history, word navigation, selection ops, and IME preedit state.

Implementations§

Source§

impl TextEditHistory

Coalesced Undo/Redo, UTF-8 word navigation, selection manipulation, and IME preedit operations for TextEditHistory.

Source

pub fn with_limits(max_history: usize, coalesce_window_ms: u64) -> Self

Creates an empty TextEditHistory with explicit history capacity and coalesce window.

§Arguments
  • usize - Maximum number of Undo snapshots retained (clamped to >= 1).
  • u64 - Coalescing time window in milliseconds (0 disables coalescing).
§Returns
  • Self - Configured empty TextEditHistory.
Source

pub fn from_text<TextType>(initial_text: TextType) -> Self
where TextType: Into<String>,

Creates a TextEditHistory initialized with initial_text and caret positioned at the end.

§Arguments
  • TextType - Initial UTF-8 text content.
§Returns
  • Self - Initialized text editor history.
Source

pub fn break_coalesce(&mut self)

Breaks the current Undo coalescing run so the next edit always records a fresh Undo point.

Source

pub fn insert_text(&mut self, inserted: &str, timestamp_ms: u64)

Inserts inserted at the active caret or replaces the active selection, coalescing rapid non-whitespace typing.

§Arguments
  • &str - UTF-8 text to insert.
  • u64 - Monotonic edit timestamp in milliseconds.
Source

pub fn replace_selection(&mut self, replacement: &str, timestamp_ms: u64)

Replaces the current selection (or inserts at caret) as an uncoalesced Undo step.

§Arguments
  • &str - Replacement UTF-8 text.
  • u64 - Monotonic edit timestamp in milliseconds.
Source

pub fn delete_backward(&mut self, timestamp_ms: u64) -> bool

Deletes the active selection or the single UTF-8 character preceding the caret (Backspace).

§Arguments
  • u64 - Monotonic edit timestamp in milliseconds.
§Returns
  • bool - true when the text buffer changed.
Source

pub fn delete_forward(&mut self, timestamp_ms: u64) -> bool

Deletes the active selection or the single UTF-8 character following the caret (Forward Delete).

§Arguments
  • u64 - Monotonic edit timestamp in milliseconds.
§Returns
  • bool - true when the text buffer changed.
Source

pub fn delete_word_backward(&mut self, timestamp_ms: u64) -> bool

Deletes the active selection or the word preceding the caret (Option/Ctrl+Backspace).

§Arguments
  • u64 - Monotonic edit timestamp in milliseconds.
§Returns
  • bool - true when at least one byte was deleted.
Source

pub fn delete_word_forward(&mut self, timestamp_ms: u64) -> bool

Deletes the active selection or the word following the caret (Option/Ctrl+Delete).

§Arguments
  • u64 - Monotonic edit timestamp in milliseconds.
§Returns
  • bool - true when at least one byte was deleted.
Source

pub fn selected_text(&self) -> &str

Returns the currently selected UTF-8 slice (empty when the selection is collapsed).

§Returns
  • &str - Borrowed selected text slice.
Source

pub fn select_all(&mut self)

Selects the entire committed text buffer (0..text.len()).

Source

pub fn set_cursor(&mut self, byte_offset: usize, extend_selection: bool)

Moves the caret to byte_offset (clamped to UTF-8 boundaries), optionally extending the selection anchor.

§Arguments
  • usize - Target UTF-8 byte offset.
  • bool - When true, preserves the existing anchor to extend or shrink the selection.
Source

pub fn move_left(&mut self, extend_selection: bool)

Moves the caret one UTF-8 character left, or collapses to selection start when not extending.

§Arguments
  • bool - When true, extends the active selection.
Source

pub fn move_right(&mut self, extend_selection: bool)

Moves the caret one UTF-8 character right, or collapses to selection end when not extending.

§Arguments
  • bool - When true, extends the active selection.
Source

pub fn move_word_left(&mut self, extend_selection: bool)

Moves the caret one word boundary left, optionally extending the selection.

§Arguments
  • bool - When true, extends the active selection.
Source

pub fn move_word_right(&mut self, extend_selection: bool)

Moves the caret one word boundary right, optionally extending the selection.

§Arguments
  • bool - When true, extends the active selection.
Source

pub fn undo(&mut self) -> bool

Restores the most recent Undo snapshot and pushes the current buffer state onto the Redo stack.

§Returns
  • bool - true when an Undo step was applied.
Source

pub fn redo(&mut self) -> bool

Re-applies the most recently undone snapshot from the Redo stack.

§Returns
  • bool - true when a Redo step was applied.
Source

pub fn can_undo(&self) -> bool

Returns true when at least one Undo step is available.

§Returns
  • bool - true if undo() will restore a prior state.
Source

pub fn can_redo(&self) -> bool

Returns true when at least one Redo step is available.

§Returns
  • bool - true if redo() will re-apply an undone state.
Source

pub fn update_ime_preedit( &mut self, composition: String, cursor_start_byte: usize, cursor_end_byte: usize, underlines: Vec<ImeUnderlineSpan>, anchor_rect: Rect, )

Updates the attached OS IME preedit composition state without mutating the committed text buffer.

§Arguments
  • String - Uncommitted IME composition string.
  • usize - Inclusive UTF-8 cursor start inside composition.
  • usize - Exclusive UTF-8 cursor end inside composition.
  • Vec<ImeUnderlineSpan> - Clause underline spans.
  • Rect - Screen-space candidate window anchor rectangle.
Source

pub fn commit_ime_preedit(&mut self, committed: &str, timestamp_ms: u64)

Clears active IME preedit state and commits committed as a discrete non-coalesced Undo step.

§Arguments
  • &str - Final UTF-8 string committed by the OS IME.
  • u64 - Monotonic commit timestamp in milliseconds.
Source

pub fn cancel_ime_preedit(&mut self)

Cancels any active IME preedit session without modifying committed text or Undo history.

Source

pub fn composed_display_text(&self) -> String

Produces the full display string with any active IME preedit composition spliced at the current selection range.

§Returns
  • String - Renderable text containing uncommitted IME composition inline.
Source§

impl TextEditHistory

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_text(&self) -> &String

Source

pub fn get_mut_text(&mut self) -> &mut String

Source

pub fn set_text(&mut self, val: String) -> &mut Self

Source

pub fn get_selection(&self) -> TextSelection

Source

pub fn get_mut_selection(&mut self) -> &mut TextSelection

Source

pub fn set_selection(&mut self, val: TextSelection) -> &mut Self

Source

pub fn get_max_history(&self) -> usize

Source

pub fn get_mut_max_history(&mut self) -> &mut usize

Source

pub fn set_max_history(&mut self, val: usize) -> &mut Self

Source

pub fn get_coalesce_window_ms(&self) -> u64

Source

pub fn get_mut_coalesce_window_ms(&mut self) -> &mut u64

Source

pub fn set_coalesce_window_ms(&mut self, val: u64) -> &mut Self

Source

pub fn get_last_edit_kind(&self) -> TextEditKind

Source

pub fn get_mut_last_edit_kind(&mut self) -> &mut TextEditKind

Source

pub fn set_last_edit_kind(&mut self, val: TextEditKind) -> &mut Self

Source

pub fn get_last_edit_timestamp_ms(&self) -> u64

Source

pub fn get_mut_last_edit_timestamp_ms(&mut self) -> &mut u64

Source

pub fn set_last_edit_timestamp_ms(&mut self, val: u64) -> &mut Self

Source

pub fn get_has_coalesce_anchor(&self) -> bool

Source

pub fn get_mut_has_coalesce_anchor(&mut self) -> &mut bool

Source

pub fn set_has_coalesce_anchor(&mut self, val: bool) -> &mut Self

Source

pub fn get_ime_preedit(&self) -> &ImePreeditState

Source

pub fn get_mut_ime_preedit(&mut self) -> &mut ImePreeditState

Source

pub fn set_ime_preedit(&mut self, val: ImePreeditState) -> &mut Self

Trait Implementations§

Source§

impl Clone for TextEditHistory

Source§

fn clone(&self) -> Self

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 TextEditHistory

Source§

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

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

impl Default for TextEditHistory

Default empty TextEditHistory configured with standard Undo limit and coalesce window.

Source§

fn default() -> Self

Creates an empty TextEditHistory.

§Returns
  • Self - Empty editor history buffer.

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.