pub struct CursorRange {
pub primary: Cursor,
pub secondary: Cursor,
}
Expand description
A selected text range (could be a range of length zero).
Fields§
§primary: Cursor
When selecting with a mouse, this is where the mouse was released. When moving with e.g. shift+arrows, this is what moves. Note that the two ends can come in any order, and also be equal (no selection).
secondary: Cursor
When selecting with a mouse, this is where the mouse was first pressed. This part of the cursor does not move when shift is down.
Implementations§
Source§impl CursorRange
impl CursorRange
pub fn two(min: Cursor, max: Cursor) -> Self
Sourcepub fn select_all(galley: &Galley) -> Self
pub fn select_all(galley: &Galley) -> Self
Select all the text in a galley
pub fn as_ccursor_range(&self) -> CCursorRange
Sourcepub fn as_sorted_char_range(&self) -> Range<usize>
pub fn as_sorted_char_range(&self) -> Range<usize>
The range of selected character indices.
Sourcepub fn single(&self) -> Option<Cursor>
pub fn single(&self) -> Option<Cursor>
If there is a selection, None is returned. If the two ends are the same, that is returned.
pub fn is_sorted(&self) -> bool
pub fn sorted(self) -> Self
Sourcepub fn sorted_cursors(&self) -> [Cursor; 2]
pub fn sorted_cursors(&self) -> [Cursor; 2]
Returns the two ends ordered.
pub fn slice_str<'s>(&self, text: &'s str) -> &'s str
Sourcepub fn on_key_press(
&mut self,
os: OperatingSystem,
galley: &Galley,
modifiers: &Modifiers,
key: Key,
) -> bool
pub fn on_key_press( &mut self, os: OperatingSystem, galley: &Galley, modifiers: &Modifiers, key: Key, ) -> bool
Check for key presses that are moving the cursor.
Returns true
if we did mutate self
.
Trait Implementations§
Source§impl Clone for CursorRange
impl Clone for CursorRange
Source§fn clone(&self) -> CursorRange
fn clone(&self) -> CursorRange
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CursorRange
impl Debug for CursorRange
Source§impl Default for CursorRange
impl Default for CursorRange
Source§fn default() -> CursorRange
fn default() -> CursorRange
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CursorRange
impl<'de> Deserialize<'de> for CursorRange
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<CursorRange> for TextCursorState
impl From<CursorRange> for TextCursorState
Source§fn from(cursor_range: CursorRange) -> Self
fn from(cursor_range: CursorRange) -> Self
Converts to this type from the input type.
Source§impl PartialEq for CursorRange
impl PartialEq for CursorRange
Source§impl Serialize for CursorRange
impl Serialize for CursorRange
impl Copy for CursorRange
impl StructuralPartialEq for CursorRange
Auto Trait Implementations§
impl Freeze for CursorRange
impl RefUnwindSafe for CursorRange
impl Send for CursorRange
impl Sync for CursorRange
impl Unpin for CursorRange
impl UnwindSafe for CursorRange
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