pub struct Selection {
pub anchor: Caret,
pub focus: Caret,
}Expand description
An ordered selection range.
anchor is where the drag started and focus where it is now;
either may be the earlier one in document order, which is what makes
dragging upwards work.
Fields§
§anchor: Caret§focus: CaretImplementations§
Source§impl Selection
impl Selection
pub fn new(anchor: Caret, focus: Caret) -> Selection
pub fn is_empty(&self) -> bool
Sourcepub fn ordered(
&self,
row_of: impl Fn(MessageId) -> Option<usize>,
) -> (Caret, Caret)
pub fn ordered( &self, row_of: impl Fn(MessageId) -> Option<usize>, ) -> (Caret, Caret)
(earlier, later) in document order, given a row resolver.
Ordering is on (row, source rank, offset), in that order, and
all three parts matter:
- row, not
MessageId: ids are allocated in creation order, but a chat-history batch inserts older messages with higher ids, so comparing ids inverts the selection after a backfill. - source rank before offset: within a row the gutter precedes the body, and their offsets index unrelated strings, so comparing offsets across sources is meaningless. Skipping this is what made a same-row gutter→body drag select the whole row.
- offset last, within one source.
Trait Implementations§
impl Copy for Selection
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Freeze for Selection
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnsafeUnpin for Selection
impl UnwindSafe for Selection
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
Mutably borrows from an owned value. Read more