pub struct CCursorRange {
pub primary: CCursor,
pub secondary: CCursor,
pub h_pos: Option<f32>,
}egui only.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
Sourcepub fn one(ccursor: CCursor) -> CCursorRange
pub fn one(ccursor: CCursor) -> CCursorRange
The empty range.
pub fn two(min: impl Into<CCursor>, max: impl Into<CCursor>) -> CCursorRange
Sourcepub fn select_all(galley: &Galley) -> CCursorRange
pub fn select_all(galley: &Galley) -> CCursorRange
Select all the text in a galley
Sourcepub fn select_all_str(text: &str) -> CCursorRange
pub fn select_all_str(text: &str) -> CCursorRange
Select all of text, i.e. from the start to after its last character.
Sourcepub fn as_sorted_char_range(&self) -> Range<CharIndex> ⓘ
pub fn as_sorted_char_range(&self) -> Range<CharIndex> ⓘ
The range of selected character indices.
Sourcepub fn contains(&self, other: CCursorRange) -> bool
pub fn contains(&self, other: CCursorRange) -> bool
Is self a super-set of the other range?
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 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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CCursorRange
Source§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 From<CCursorRange> for TextCursorState
impl From<CCursorRange> for TextCursorState
Source§fn from(ccursor_range: CCursorRange) -> TextCursorState
fn from(ccursor_range: CCursorRange) -> TextCursorState
Source§impl PartialEq for CCursorRange
impl PartialEq for CCursorRange
impl StructuralPartialEq for CCursorRange
Auto Trait Implementations§
impl Forget for CCursorRange
impl Freeze for CCursorRange
impl Move for CCursorRange
impl RefUnwindSafe for CCursorRange
impl Send for CCursorRange
impl Sync for CCursorRange
impl Unpin for CCursorRange
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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