Struct egui::text_selection::cursor_range::CursorRange
source · 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 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
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)