pub enum EditorPatch {
SetDocument(StyledText),
SetAttributes(StyledText),
SetSelection(Range<usize>),
SetTypingStyle(RunStyle),
SetEditable(bool),
Insert {
at: usize,
text: String,
},
}Variants§
SetDocument(StyledText)
Replace both the text and its attributes. Moves the caret, so it is sent only when the text itself changed under the app’s hand.
SetAttributes(StyledText)
Restyle text the native view already holds, preserving the selection and the undo stack.
The patch a live syntax highlighter sends on every keystroke: re-tokenizing produces fresh runs for the same characters, and pushing them as a document would move the caret back to wherever the app last set it.
It carries the whole document even though only the attributes are new. The text is what an arm converts byte ranges against, and the four whose toolkit cannot hand back its own string cheaply (Qt, Android, HarmonyOS, XAML) would otherwise each need a cache that a keystroke could leave one edit stale.
SetSelection(Range<usize>)
SetTypingStyle(RunStyle)
What the next typed character takes. Native where the toolkit has the concept, emulated on GTK and the web, which do not.
SetEditable(bool)
Insert
Insert text at byte offset at through the view’s own insertion, so the platform’s
undo stack records it like typing and the caret lands after it. The view reports the
result as a TextChanged, which is how the model learns of it; nothing is written to the
document here. What the piece’s code mode sends for a Tab, an auto-indent and a closing
bracket.
Trait Implementations§
Source§impl Clone for EditorPatch
impl Clone for EditorPatch
Source§fn clone(&self) -> EditorPatch
fn clone(&self) -> EditorPatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EditorPatch
impl Debug for EditorPatch
Source§impl PartialEq for EditorPatch
impl PartialEq for EditorPatch
impl StructuralPartialEq for EditorPatch
Auto Trait Implementations§
impl Freeze for EditorPatch
impl RefUnwindSafe for EditorPatch
impl Send for EditorPatch
impl Sync for EditorPatch
impl Unpin for EditorPatch
impl UnsafeUnpin for EditorPatch
impl UnwindSafe for EditorPatch
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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