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.
impl TextEditHistory
Coalesced Undo/Redo, UTF-8 word navigation, selection manipulation, and IME preedit operations for TextEditHistory.
Sourcepub fn with_limits(max_history: usize, coalesce_window_ms: u64) -> Self
pub fn with_limits(max_history: usize, coalesce_window_ms: u64) -> Self
Sourcepub fn break_coalesce(&mut self)
pub fn break_coalesce(&mut self)
Breaks the current Undo coalescing run so the next edit always records a fresh Undo point.
Sourcepub fn insert_text(&mut self, inserted: &str, timestamp_ms: u64)
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.
Sourcepub fn replace_selection(&mut self, replacement: &str, timestamp_ms: u64)
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.
Sourcepub fn delete_backward(&mut self, timestamp_ms: u64) -> bool
pub fn delete_backward(&mut self, timestamp_ms: u64) -> bool
Sourcepub fn delete_forward(&mut self, timestamp_ms: u64) -> bool
pub fn delete_forward(&mut self, timestamp_ms: u64) -> bool
Sourcepub fn delete_word_backward(&mut self, timestamp_ms: u64) -> bool
pub fn delete_word_backward(&mut self, timestamp_ms: u64) -> bool
Sourcepub fn delete_word_forward(&mut self, timestamp_ms: u64) -> bool
pub fn delete_word_forward(&mut self, timestamp_ms: u64) -> bool
Sourcepub fn selected_text(&self) -> &str
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.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Selects the entire committed text buffer (0..text.len()).
Sourcepub fn set_cursor(&mut self, byte_offset: usize, extend_selection: bool)
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- Whentrue, preserves the existing anchor to extend or shrink the selection.
Sourcepub fn move_left(&mut self, extend_selection: bool)
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- Whentrue, extends the active selection.
Sourcepub fn move_right(&mut self, extend_selection: bool)
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- Whentrue, extends the active selection.
Sourcepub fn move_word_left(&mut self, extend_selection: bool)
pub fn move_word_left(&mut self, extend_selection: bool)
Moves the caret one word boundary left, optionally extending the selection.
§Arguments
bool- Whentrue, extends the active selection.
Sourcepub fn move_word_right(&mut self, extend_selection: bool)
pub fn move_word_right(&mut self, extend_selection: bool)
Moves the caret one word boundary right, optionally extending the selection.
§Arguments
bool- Whentrue, extends the active selection.
Sourcepub fn undo(&mut self) -> bool
pub fn undo(&mut self) -> bool
Restores the most recent Undo snapshot and pushes the current buffer state onto the Redo stack.
§Returns
bool-truewhen an Undo step was applied.
Sourcepub fn redo(&mut self) -> bool
pub fn redo(&mut self) -> bool
Re-applies the most recently undone snapshot from the Redo stack.
§Returns
bool-truewhen a Redo step was applied.
Sourcepub fn can_undo(&self) -> bool
pub fn can_undo(&self) -> bool
Returns true when at least one Undo step is available.
§Returns
bool-trueifundo()will restore a prior state.
Sourcepub fn can_redo(&self) -> bool
pub fn can_redo(&self) -> bool
Returns true when at least one Redo step is available.
§Returns
bool-trueifredo()will re-apply an undone state.
Sourcepub fn update_ime_preedit(
&mut self,
composition: String,
cursor_start_byte: usize,
cursor_end_byte: usize,
underlines: Vec<ImeUnderlineSpan>,
anchor_rect: Rect,
)
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 insidecomposition.usize- Exclusive UTF-8 cursor end insidecomposition.Vec<ImeUnderlineSpan>- Clause underline spans.Rect- Screen-space candidate window anchor rectangle.
Sourcepub fn commit_ime_preedit(&mut self, committed: &str, timestamp_ms: u64)
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.
Sourcepub fn cancel_ime_preedit(&mut self)
pub fn cancel_ime_preedit(&mut self)
Cancels any active IME preedit session without modifying committed text or Undo history.
Sourcepub fn composed_display_text(&self) -> String
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.