pub struct Cursor { /* private fields */ }Expand description
Cursor position and shape.
Implementations§
Source§impl Cursor
impl Cursor
pub fn new(shape: CursorShape, column: usize, row: usize) -> Self
pub fn shape(&self) -> CursorShape
pub fn set(&mut self, col: usize, row: usize)
pub fn set_col(&mut self, col: usize)
pub fn col(&self) -> usize
pub fn inc_col(&mut self, value: usize)
pub fn dec_col(&mut self, value: usize)
pub fn row(&self) -> usize
pub fn set_row(&mut self, row: usize)
pub fn inc_row(&mut self, value: usize)
pub fn dec_row(&mut self, value: usize)
Sourcepub fn offset(&self, column_offset: isize, row_offset: isize) -> (usize, usize)
pub fn offset(&self, column_offset: isize, row_offset: isize) -> (usize, usize)
Calculates the cursor position after applying specified offsets.
Sourcepub fn is_under_score(&self) -> bool
pub fn is_under_score(&self) -> bool
Returns true when the current cursor shape is an underscore (_).
Sourcepub fn insert_mode(&self) -> bool
pub fn insert_mode(&self) -> bool
Returns true when the cursor is signaling the inserting mode.
Sourcepub fn override_mode(&self) -> bool
pub fn override_mode(&self) -> bool
Returns true when the cursor is signaling the overriding mode.
Sourcepub fn toggle_caret_block(&mut self) -> CursorShape
pub fn toggle_caret_block(&mut self) -> CursorShape
Toggles the cursor shape between caret and block.
Returns the cursor shape after toggling.
§Examples
use dtee::{Cursor, CursorShape};
let mut cursor = Cursor::new(CursorShape::Caret, 1, 1);
assert_eq!(true, cursor.is_caret());
assert_eq!(CursorShape::Block, cursor.toggle_caret_block());
assert_eq!(CursorShape::Caret, cursor.toggle_caret_block());
let mut cursor = Cursor::new(CursorShape::UnderScore, 1, 1);
assert_eq!(true, cursor.is_under_score());
assert_eq!(CursorShape::Block, cursor.toggle_caret_block());
assert_eq!(CursorShape::Caret, cursor.toggle_caret_block());Sourcepub fn toggle_caret_under_score(&mut self) -> CursorShape
pub fn toggle_caret_under_score(&mut self) -> CursorShape
Toggles the cursor shape between caret and underscore.
Returns the cursor shape after toggling.
§Examples
use dtee::{Cursor, CursorShape};
let mut cursor = Cursor::new(CursorShape::Caret, 1, 1);
assert_eq!(true, cursor.is_caret());
assert_eq!(CursorShape::UnderScore, cursor.toggle_caret_under_score());
assert_eq!(CursorShape::Caret, cursor.toggle_caret_under_score());
let mut cursor = Cursor::new(CursorShape::Block, 1, 1);
assert_eq!(true, cursor.is_block());
assert_eq!(CursorShape::UnderScore, cursor.toggle_caret_under_score());
assert_eq!(CursorShape::Caret, cursor.toggle_caret_under_score());Trait Implementations§
impl Copy for Cursor
impl Eq for Cursor
impl StructuralPartialEq for Cursor
Auto Trait Implementations§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnwindSafe for Cursor
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