pub struct Pos {
pub col: usize,
pub row: usize,
}
Expand description
A cursor position
Fields§
§col: usize
The virtual column of the cursor. This can be more than the line length. To get the realized column, use Pos::col()
.
row: usize
The row of the cursor.
Implementations§
Source§impl Pos
impl Pos
Sourcepub fn right(&mut self, text: &(impl Text + ?Sized))
pub fn right(&mut self, text: &(impl Text + ?Sized))
Moves the position right by one character.
Sourcepub fn move_row(&mut self, change: i32, text: &(impl Text + ?Sized))
pub fn move_row(&mut self, change: i32, text: &(impl Text + ?Sized))
Move the position’s row by the given amount. (positive is down, negative is up)
Sourcepub fn move_col(&mut self, change: i32, text: &(impl Text + ?Sized))
pub fn move_col(&mut self, change: i32, text: &(impl Text + ?Sized))
Move the position’s column by the given amount. (positive is right, negative is left)
Sourcepub fn col(&self, text: &(impl Text + ?Sized)) -> usize
pub fn col(&self, text: &(impl Text + ?Sized)) -> usize
Get the realized column of the position. This is the column, but capped at the line length.
Sourcepub fn idx(&self, text: &(impl Text + ?Sized)) -> usize
pub fn idx(&self, text: &(impl Text + ?Sized)) -> usize
Get the character index of the position.
Sourcepub fn realize_col(&mut self, text: &(impl Text + ?Sized))
pub fn realize_col(&mut self, text: &(impl Text + ?Sized))
If the column is more than the line length, cap it to the line length.
Trait Implementations§
Source§impl Ord for Pos
impl Ord for Pos
Source§impl PartialOrd for Pos
impl PartialOrd for Pos
impl Eq for Pos
impl StructuralPartialEq for Pos
Auto Trait Implementations§
impl Freeze for Pos
impl RefUnwindSafe for Pos
impl Send for Pos
impl Sync for Pos
impl Unpin for Pos
impl UnwindSafe for Pos
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