pub struct SelectionRange {
pub anchor: usize,
pub head: usize,
pub affinity: Affinity,
}Expand description
One selection range: anchor is where the selection started,
head is the live end (where the caret glyph renders). anchor == head is a plain collapsed caret — the overwhelmingly common case for
TextInput/TextArea today; multiple SelectionRanges (multi-cursor)
is a real, supported shape nothing here forbids, reserved for a future
code-editor-class widget (D116 — not built by this phase).
Fields§
§anchor: usize§head: usize§affinity: AffinityImplementations§
Source§impl SelectionRange
impl SelectionRange
pub fn collapsed_at(pos: usize) -> Self
pub fn collapsed(&self) -> bool
Sourcepub fn normalized(&self) -> (usize, usize)
pub fn normalized(&self) -> (usize, usize)
(start, end) with start <= end — the shape every string-slicing
call site wants, regardless of which direction the user selected in.
Trait Implementations§
Source§impl Clone for SelectionRange
impl Clone for SelectionRange
Source§fn clone(&self) -> SelectionRange
fn clone(&self) -> SelectionRange
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SelectionRange
Source§impl Debug for SelectionRange
impl Debug for SelectionRange
Source§impl PartialEq for SelectionRange
impl PartialEq for SelectionRange
impl StructuralPartialEq for SelectionRange
Auto Trait Implementations§
impl Freeze for SelectionRange
impl RefUnwindSafe for SelectionRange
impl Send for SelectionRange
impl Sync for SelectionRange
impl Unpin for SelectionRange
impl UnsafeUnpin for SelectionRange
impl UnwindSafe for SelectionRange
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