pub struct Cursor { /* private fields */ }Expand description
A cursor in the text file. This is an editing cursor, not a printing cursor.
Implementations§
source§impl Cursor
impl Cursor
sourcepub fn new(
point: Point,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
) -> Cursor
pub fn new( point: Point, text: &Text, area: &impl Area, cfg: &PrintCfg, ) -> Cursor
Returns a new instance of Cursor.
sourcepub fn move_to(
&mut self,
point: Point,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_to( &mut self, point: Point, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Moves to specific, pre calculated Point.
sourcepub fn move_hor(
&mut self,
by: isize,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_hor( &mut self, by: isize, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Internal horizontal movement function.
sourcepub fn move_ver(
&mut self,
by: isize,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_ver( &mut self, by: isize, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Internal vertical movement function.
sourcepub fn move_ver_wrapped(
&mut self,
_by: isize,
_text: &Text,
_area: &impl Area,
_cfg: &PrintCfg,
)
pub fn move_ver_wrapped( &mut self, _by: isize, _text: &Text, _area: &impl Area, _cfg: &PrintCfg, )
Internal vertical movement function.
sourcepub fn set_anchor(&mut self)
pub fn set_anchor(&mut self)
Sets the position of the anchor to be the same as the current cursor position in the file.
The anchor and current act as a range of text on the file.
sourcepub fn unset_anchor(&mut self) -> Option<Point>
pub fn unset_anchor(&mut self) -> Option<Point>
Unsets the anchor.
This is done so the cursor no longer has a valid selection.
pub fn anchor(&self) -> Option<Point>
sourcepub fn byte(&self) -> usize
pub fn byte(&self) -> usize
The byte (relative to the beginning of the file) of the caret. Indexed at 0.
sourcepub fn char(&self) -> usize
pub fn char(&self) -> usize
The char (relative to the beginning of the file) of the caret. Indexed at 0.
sourcepub fn range(&self) -> Range<usize>
pub fn range(&self) -> Range<usize>
Returns the range between target and anchor.
If anchor isn’t set, returns an empty range on target.
sourcepub fn point_range(&self) -> (Point, Point)
pub fn point_range(&self) -> (Point, Point)
Returns the range between target and anchor.
If anchor isn’t set, returns an empty range on target.
Trait Implementations§
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)