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.
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
pub fn anchor_vcol(&self) -> Option<usize>
pub fn desired_vcol(&self) -> usize
pub fn desired_anchor_vcol(&self) -> Option<usize>
Sourcepub fn range(&self, is_inclusive: bool, text: &Text) -> Range<usize>
pub fn range(&self, is_inclusive: bool, text: &Text) -> Range<usize>
Returns the range between target and anchor.
If anchor isn’t set, returns an empty range on target.
A Cursor’s range will also never include the last
character in a Text, which must be a newline.
§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.
like Cursor::range, this function will not include
beyond the last character’s Point.
If anchor isn’t set, returns an empty range on target.
Sourcepub fn set_desired_v_col(&mut self, x: usize)
pub fn set_desired_v_col(&mut self, x: usize)
Sets the desired visual column
The desired visual column determines at what point in a line the caret will be placed when moving up and down through lines of varying lengths.
Sourcepub fn set_desired_wrapped_v_col(&mut self, x: usize)
pub fn set_desired_wrapped_v_col(&mut self, x: usize)
Sets the desired wrapped visual column
The desired wrapped visual column determines at what point in a line the caret will be placed when moving up and down through wrapped lines of varying lengths.