pub enum InsertionOrigin {
Unspecified,
Typed,
Composed,
Pasted,
Dropped,
Imported,
Replayed,
Programmatic,
Assistive,
}Expand description
Events emitted by a TextDocument.
Subscribe via TextDocument::on_change (callback-based)
or poll via TextDocument::poll_events (frame-loop).
These events carry enough information for a UI to do incremental updates — repaint only the affected region, not the entire document. Which channel some text arrived through.
A fact about how the characters reached the document, and nothing more. It says who typed, pasted or dictated nothing at all: an application can only report the channel it was called through, and the inference from a channel to an author is not one any of this can make.
§Why the default is Unspecified and not Programmatic
Every insertion method has a plain form and a _with_origin sibling. The
plain form reports Unspecified, which means the
caller did not say — deliberately not Programmatic,
which would assert that the application inserted the text itself. Those are
different claims, and a consumer counting them apart is entitled to know
which one it has.
The same distinction as an absent field versus a zero: an unspecified origin is missing information, and a wrong one is a wrong fact.
Variants§
Unspecified
The caller did not say. The default for every plain insertion method.
Typed
Entered a key at a time.
Composed
Committed by an input method — the multi-keystroke path that produces
one character. Kept apart from Typed because a consumer
counting keystrokes and one counting characters disagree here, and both
are right.
Pasted
Pasted from a clipboard.
Dropped
Dropped in from elsewhere.
Imported
Brought in by a document import.
Replayed
Re-applied by undo or redo.
Hard-coded at those two paths, which never re-enter the insertion API — they snapshot and diff instead — so a replayed edit can never be counted twice under its original origin.
Programmatic
Inserted by the application: a template, an expansion, a substitution.
Assistive
Arrived through an accessibility channel: dictation, a braille display.
Never folded into Typed. Some people write this way,
and a record that erased the distinction would be reporting them as
something they are not.
Implementations§
Source§impl InsertionOrigin
impl InsertionOrigin
Sourcepub const ALL: [InsertionOrigin; 9]
pub const ALL: [InsertionOrigin; 9]
Every variant, for a consumer building a table over them.
Trait Implementations§
Source§impl Clone for InsertionOrigin
impl Clone for InsertionOrigin
Source§fn clone(&self) -> InsertionOrigin
fn clone(&self) -> InsertionOrigin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InsertionOrigin
Source§impl Debug for InsertionOrigin
impl Debug for InsertionOrigin
Source§impl Default for InsertionOrigin
impl Default for InsertionOrigin
Source§fn default() -> InsertionOrigin
fn default() -> InsertionOrigin
impl Eq for InsertionOrigin
Source§impl Hash for InsertionOrigin
impl Hash for InsertionOrigin
Source§impl PartialEq for InsertionOrigin
impl PartialEq for InsertionOrigin
impl StructuralPartialEq for InsertionOrigin
Auto Trait Implementations§
impl Freeze for InsertionOrigin
impl RefUnwindSafe for InsertionOrigin
impl Send for InsertionOrigin
impl Sync for InsertionOrigin
impl Unpin for InsertionOrigin
impl UnsafeUnpin for InsertionOrigin
impl UnwindSafe for InsertionOrigin
Blanket Implementations§
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.