#[non_exhaustive]pub struct TextPosition {
pub offset: u32,
pub affinity: Affinity,
}Expand description
A caret position in a text: a UTF-16 offset and the side it is on.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.offset: u32The offset (UTF-16 units).
affinity: AffinityWhich line it is on where it ends one and starts the next.
Implementations§
Source§impl TextPosition
impl TextPosition
Sourcepub const fn new(offset: u32, affinity: Affinity) -> Self
pub const fn new(offset: u32, affinity: Affinity) -> Self
The position at offset on the side affinity says.
Sourcepub fn line(self, lines: &[TextLine]) -> Option<usize>
pub fn line(self, lines: &[TextLine]) -> Option<usize>
The index of the line of lines (a final layout’s, in order) the
caret at this position is on: the line holding the offset, the
earlier of two for Affinity::Upstream at a line’s end; past every
line (the text’s end, an empty last line), the last line starting at
or before it. None when there are no lines.
Sourcepub fn line_in<I>(self, ranges: I) -> Option<usize>
pub fn line_in<I>(self, ranges: I) -> Option<usize>
TextPosition::line over the UTF-16 ranges of the lines, for
engines that keep their lines in a type of their own.
Trait Implementations§
Source§impl Clone for TextPosition
impl Clone for TextPosition
impl Copy for TextPosition
Source§impl Debug for TextPosition
impl Debug for TextPosition
Source§impl Default for TextPosition
impl Default for TextPosition
impl Eq for TextPosition
Source§impl Hash for TextPosition
impl Hash for TextPosition
Source§impl PartialEq for TextPosition
impl PartialEq for TextPosition
impl StructuralPartialEq for TextPosition
Auto Trait Implementations§
impl Forget for TextPosition
impl Freeze for TextPosition
impl Move for TextPosition
impl RefUnwindSafe for TextPosition
impl Send for TextPosition
impl Sync for TextPosition
impl Unpin for TextPosition
impl UnsafeUnpin for TextPosition
impl UnwindSafe for TextPosition
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