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 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: i32,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_hor( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Internal horizontal movement function.
Sourcepub fn move_ver(
&mut self,
by: i32,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_ver( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Internal vertical movement function.
Sourcepub fn move_ver_wrapped(
&mut self,
by: i32,
text: &Text,
area: &impl Area,
cfg: &PrintCfg,
)
pub fn move_ver_wrapped( &mut self, by: i32, text: &Text, area: &impl Area, cfg: &PrintCfg, )
Internal vertical movement function.
pub fn shift_by( &mut self, shift: (i32, i32, i32), text: &Text, area: &impl Area, cfg: &PrintCfg, )
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) -> u32
pub fn byte(&self) -> u32
The byte (relative to the beginning of the file) of the caret. Indexed at 0.
Sourcepub fn char(&self) -> u32
pub fn char(&self) -> u32
The char (relative to the beginning of the file) of the caret. Indexed at 0.
Sourcepub fn range(&self, inclusive: bool) -> Range<u32>
pub fn range(&self, inclusive: bool) -> Range<u32>
Returns the range between target and anchor.
If anchor isn’t set, returns an empty range on target.
§Warning
This function will return the range that is supposed
to be replaced, if self.is_inclusive(), this means that
it will return one more byte at the end, i.e. start..=end.
Sourcepub fn point_range(&self, is_incl: bool, text: &Text) -> (Point, Point)
pub fn point_range(&self, is_incl: bool, text: &Text) -> (Point, Point)
Returns the range between target and anchor.
If anchor isn’t set, returns an empty range on target.
§Warning
Unlike Self::range(), this function ignores the
“inclusiveness” of the range.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cursor
impl<'de> Deserialize<'de> for Cursor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)