pub struct CCursorRange {
pub primary: CCursor,
pub secondary: CCursor,
pub h_pos: Option<f32>,
}
Expand description
A selected text range (could be a range of length zero).
The selection is based on character count (NOT byte count!).
Fields§
§primary: CCursor
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: CCursor
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.
h_pos: Option<f32>
Saved horizontal position of the cursor.
Implementations§
Source§impl CCursorRange
impl CCursorRange
pub fn two(min: impl Into<CCursor>, max: impl Into<CCursor>) -> Self
Sourcepub fn select_all(galley: &Galley) -> Self
pub fn select_all(galley: &Galley) -> Self
Select all the text in a galley
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<CCursor>
pub fn single(&self) -> Option<CCursor>
If there is a selection, None is returned. If the two ends are the same, that is returned.
pub fn is_sorted(&self) -> bool
Sourcepub fn sorted_cursors(&self) -> [CCursor; 2]
pub fn sorted_cursors(&self) -> [CCursor; 2]
returns the two ends ordered
pub fn sorted(&self) -> [CCursor; 2]
self.sorted_cursors
instead.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 CCursorRange
impl Clone for CCursorRange
Source§fn clone(&self) -> CCursorRange
fn clone(&self) -> CCursorRange
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more