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: CCursorWhen 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: CCursorWhen 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 moreSource§impl Debug for CCursorRange
impl Debug for CCursorRange
Source§impl Default for CCursorRange
impl Default for CCursorRange
Source§fn default() -> CCursorRange
fn default() -> CCursorRange
Source§impl<'de> Deserialize<'de> for CCursorRange
impl<'de> Deserialize<'de> for CCursorRange
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>,
Source§impl From<CCursorRange> for TextCursorState
impl From<CCursorRange> for TextCursorState
Source§fn from(ccursor_range: CCursorRange) -> Self
fn from(ccursor_range: CCursorRange) -> Self
Source§impl PartialEq for CCursorRange
impl PartialEq for CCursorRange
Source§impl Serialize for CCursorRange
impl Serialize for CCursorRange
impl Copy for CCursorRange
impl StructuralPartialEq for CCursorRange
Auto Trait Implementations§
impl Freeze for CCursorRange
impl RefUnwindSafe for CCursorRange
impl Send for CCursorRange
impl Sync for CCursorRange
impl Unpin for CCursorRange
impl UnwindSafe for CCursorRange
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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