pub struct PhantomTextLine {
pub text: SmallVec<[PhantomText; 6]>,
}Expand description
Information about the phantom text on a specific line.
This has various utility functions for transforming a coordinate (typically a column) into the resulting coordinate after the phantom text is combined with the line’s real content.
Fields§
§text: SmallVec<[PhantomText; 6]>This uses a smallvec because most lines rarely have more than a couple phantom texts
Implementations§
Source§impl PhantomTextLine
impl PhantomTextLine
Sourcepub fn col_at(&self, pre_col: usize) -> usize
pub fn col_at(&self, pre_col: usize) -> usize
Translate a column position into the text into what it would be after combining
Sourcepub fn col_after(&self, pre_col: usize, before_cursor: bool) -> usize
pub fn col_after(&self, pre_col: usize, before_cursor: bool) -> usize
Translate a column position into the text into what it would be after combining
If before_cursor is false and the cursor is right at the start then it will stay there
(Think ‘is the phantom text before the cursor’)
Sourcepub fn col_after_force(&self, pre_col: usize, before_cursor: bool) -> usize
pub fn col_after_force(&self, pre_col: usize, before_cursor: bool) -> usize
Translate a column position into the text into what it would be after combining
it only takes before_cursor in the params without considering the
cursor affinity in phantom text
Sourcepub fn col_after_ignore(
&self,
pre_col: usize,
before_cursor: bool,
skip: impl Fn(&PhantomText) -> bool,
) -> usize
pub fn col_after_ignore( &self, pre_col: usize, before_cursor: bool, skip: impl Fn(&PhantomText) -> bool, ) -> usize
Translate a column position into the text into what it would be after combining
If before_cursor is false and the cursor is right at the start then it will stay there
(Think ‘is the phantom text before the cursor’)
This accepts a PhantomTextKind to ignore. Primarily for IME due to it needing to put the
cursor in the middle.
Sourcepub fn before_col(&self, col: usize) -> usize
pub fn before_col(&self, col: usize) -> usize
Translate a column position into the position it would be before combining
Sourcepub fn combine_with_text<'a>(&self, text: &'a str) -> Cow<'a, str>
pub fn combine_with_text<'a>(&self, text: &'a str) -> Cow<'a, str>
Insert the hints at their positions in the text
Sourcepub fn offset_size_iter(
&self,
) -> impl Iterator<Item = (usize, usize, usize, &PhantomText)> + '_
pub fn offset_size_iter( &self, ) -> impl Iterator<Item = (usize, usize, usize, &PhantomText)> + '_
Iterator over (col_shift, size, hint, pre_column)
Note that this only iterates over the ordered text, since those depend on the text for where
they’ll be positioned
pub fn apply_attr_styles(&self, default: Attrs<'_>, attrs_list: &mut AttrsList)
Trait Implementations§
Source§impl Clone for PhantomTextLine
impl Clone for PhantomTextLine
Source§fn clone(&self) -> PhantomTextLine
fn clone(&self) -> PhantomTextLine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhantomTextLine
impl Debug for PhantomTextLine
Source§impl Default for PhantomTextLine
impl Default for PhantomTextLine
Source§fn default() -> PhantomTextLine
fn default() -> PhantomTextLine
Auto Trait Implementations§
impl Freeze for PhantomTextLine
impl RefUnwindSafe for PhantomTextLine
impl Send for PhantomTextLine
impl Sync for PhantomTextLine
impl Unpin for PhantomTextLine
impl UnwindSafe for PhantomTextLine
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> 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