[][src]Struct druid::text::selection::Selection

pub struct Selection {
    pub start: usize,
    pub end: usize,
    pub h_pos: Option<f64>,
}

A Selection type for EditableText.

Fields

start: usize

The inactive edge of a selection, as a byte offset. When equal to end, the selection range acts as a caret.

end: usize

The active edge of a selection, as a byte offset.

h_pos: Option<f64>

The saved horizontal position, during vertical movement.

Implementations

impl Selection[src]

pub fn new(start: usize, end: usize) -> Self[src]

Create a selection that begins at start and goes to end. Like dragging a mouse from start to end.

#[must_use = "constrained constructs a new Selection"]pub fn constrained(self, s: &impl EditableText) -> Self[src]

Create a new selection that is guaranteed to be valid for the provided text.

pub fn caret(pos: usize) -> Self[src]

Create a caret, which is just a selection with the same and start and end.

pub fn with_h_pos(self, h_pos: Option<f64>) -> Self[src]

Construct a new selection from this selection, with the provided h_pos.

pub fn is_caret(self) -> bool[src]

If start == end, it's a caret

pub fn min(self) -> usize[src]

Return the smallest index (left, in left-to-right languages)

pub fn max(self) -> usize[src]

Return the largest index (right, in left-to-right languages)

pub fn range(self) -> Range<usize>[src]

Return a range from smallest to largest index

Trait Implementations

impl Clone for Selection[src]

impl Copy for Selection[src]

impl Debug for Selection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.