pub struct TextSelection { /* private fields */ }Expand description
A TextLayout-owned selection value.
This wraps Parley’s selection type for APIs that depend on TextLayout’s
selection-geometry invariants and cache lifecycle.
Methods from Deref<Target = Selection>§
pub fn is_collapsed(&self) -> bool
pub fn is_collapsed(&self) -> bool
Returns true if the anchor and focus of the selection are the same.
This means that the selection represents a single position rather than a range.
pub fn anchor(&self) -> Cursor
pub fn anchor(&self) -> Cursor
Returns the anchor of the selection.
In a non-collapsed selection, this indicates where the selection was initiated.
pub fn focus(&self) -> Cursor
pub fn focus(&self) -> Cursor
Returns the focus of the selection.
In a non-collapsed selection, this indicates the current position.
pub fn collapse(&self) -> Selection
pub fn collapse(&self) -> Selection
Returns a new collapsed selection at the position of the current focus.
pub fn refresh<B>(&self, layout: &Layout<B>) -> Selectionwhere
B: Brush,
pub fn refresh<B>(&self, layout: &Layout<B>) -> Selectionwhere
B: Brush,
Returns a new selection that is guaranteed to be within the bounds of the given layout.
pub fn text_range(&self) -> Range<usize>
pub fn text_range(&self) -> Range<usize>
Returns the underlying text range of the selection.
pub fn next_visual<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn next_visual<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus at the next cluster in visual order.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn previous_visual<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn previous_visual<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus at the previous cluster in visual order.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn next_visual_word<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn next_visual_word<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the next word in visual order.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn previous_visual_word<B>(
&self,
layout: &Layout<B>,
extend: bool,
) -> Selectionwhere
B: Brush,
pub fn previous_visual_word<B>(
&self,
layout: &Layout<B>,
extend: bool,
) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the previous word in visual order.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn next_line<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn next_line<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the next line. The current horizontal position will be maintained.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn previous_line<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn previous_line<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the previous line. The current horizontal position will be maintained.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn move_lines<B>(
&self,
layout: &Layout<B>,
delta: isize,
extend: bool,
) -> Selectionwhere
B: Brush,
pub fn move_lines<B>(
&self,
layout: &Layout<B>,
delta: isize,
extend: bool,
) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved the specified number of lines.
The sign of the delta parameter determines the direction to move with
negative values moving toward previous lines and positive ones moving
toward next lines.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn line_start<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn line_start<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the start of the current line.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn hard_line_start<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn hard_line_start<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to just after the previous hard line break.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn line_end<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn line_end<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to the end of the current line.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn hard_line_end<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
pub fn hard_line_end<B>(&self, layout: &Layout<B>, extend: bool) -> Selectionwhere
B: Brush,
Returns a new selection with the focus moved to just before the next hard line break.
If extend is true then the current anchor will be retained,
otherwise the new selection will be collapsed.
pub fn extend_to_point<B>(
&self,
layout: &Layout<B>,
x: f32,
y: f32,
) -> Selectionwhere
B: Brush,
pub fn extend_to_point<B>(
&self,
layout: &Layout<B>,
x: f32,
y: f32,
) -> Selectionwhere
B: Brush,
Returns a new selection with the focus extended to the given point.
If the initial selection was created from a word or line, then the new selection will be extended at the same granularity.
pub fn shift_click_extension<B>(
&self,
layout: &Layout<B>,
x: f32,
y: f32,
) -> Selectionwhere
B: Brush,
pub fn shift_click_extension<B>(
&self,
layout: &Layout<B>,
x: f32,
y: f32,
) -> Selectionwhere
B: Brush,
Returns a new selection with the focus extended to the given point.
pub fn extend(&self, focus: Cursor) -> Selection
pub fn extend(&self, focus: Cursor) -> Selection
Returns a new selection with the current anchor and the focus set to the given value.
pub fn geometry<B>(&self, layout: &Layout<B>) -> Vec<(BoundingBox, usize)>where
B: Brush,
pub fn geometry<B>(&self, layout: &Layout<B>) -> Vec<(BoundingBox, usize)>where
B: Brush,
Returns a vector containing the rectangles which represent the visual geometry of this selection for the given layout, and the indices of the lines to which they belong.
This is a convenience method built on geometry_with.
pub fn geometry_with<B>(
&self,
layout: &Layout<B>,
f: impl FnMut(BoundingBox, usize),
)where
B: Brush,
pub fn geometry_with<B>(
&self,
layout: &Layout<B>,
f: impl FnMut(BoundingBox, usize),
)where
B: Brush,
Invokes f with the sequence of rectangles which represent the visual
geometry of this selection for the given layout, and the indices of the
lines to which they belong.
This avoids allocation if the intent is to render the rectangles immediately.
Trait Implementations§
Source§impl Clone for TextSelection
impl Clone for TextSelection
Source§fn clone(&self) -> TextSelection
fn clone(&self) -> TextSelection
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 TextSelection
Source§impl Debug for TextSelection
impl Debug for TextSelection
Source§impl Deref for TextSelection
impl Deref for TextSelection
Source§impl DerefMut for TextSelection
impl DerefMut for TextSelection
impl Eq for TextSelection
Source§impl PartialEq for TextSelection
impl PartialEq for TextSelection
Source§fn eq(&self, other: &TextSelection) -> bool
fn eq(&self, other: &TextSelection) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TextSelection
Auto Trait Implementations§
impl Freeze for TextSelection
impl RefUnwindSafe for TextSelection
impl Send for TextSelection
impl Sync for TextSelection
impl Unpin for TextSelection
impl UnsafeUnpin for TextSelection
impl UnwindSafe for TextSelection
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more