Skip to main content

SnippetSession

Struct SnippetSession 

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

A live snippet session: one tracked range per stop, the active stop AlwaysGrows and the rest NeverGrows. It never touches the document or history — the caller inserts the snippet text (one sealed transaction), selects the range this reports, and the session only registers / swaps / unregisters ranges. Cancellation is never a transaction: text stays, ranges unregister, nothing enters history.

Implementations§

Source§

impl SnippetSession

Source

pub fn start( snippet: &Snippet, base: u32, store: &mut DecorationStore, ) -> Option<(Self, Range<u32>)>

Start a session from a just-inserted snippet whose stop ranges are offset by base (the insert position). Registers one SnippetStop per stop (the first AlwaysGrows, the rest NeverGrows) and returns the session plus the first stop’s content for the caller to select. None — no session — when the snippet has no stop besides the final.

Source

pub fn active_index(&self) -> usize

The ordinal (visit-order) index of the active stop.

Source

pub fn active_range(&self, store: &DecorationStore) -> Option<Range<u32>>

The active stop’s current content range (post-edit), or None if it was dropped.

Source

pub fn tab(&mut self, forward: bool, store: &mut DecorationStore) -> TabOutcome

Tab (forward) / Shift+Tab (!forward) between stops. Swaps stickiness on a move; Tab past the last non-final stop ends the session at the final stop (TabOutcome::Finish, ranges already unregistered).

Source

pub fn on_caret( &mut self, offset: u32, store: &mut DecorationStore, ) -> CaretOutcome

A caret landed at offset (a click): re-activate a different stop it lands in, stay if it’s the active stop, or report that it left every stop (the caller then cancels).

Source

pub fn edit_escapes(&self, range: &Range<u32>, store: &DecorationStore) -> bool

Whether an edit spanning range lands wholly outside every stop (→ the caller cancels). An edit touching any stop keeps the session.

Source

pub fn cancel(&mut self, store: &mut DecorationStore)

Unregister every stop range. Cancellation is never a transaction.

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