pub struct Selection { /* private fields */ }Expand description
A cursor in the text file. This is an editing cursor, -(not a printing cursor.
Implementations§
Source§impl Selection
impl Selection
Sourcepub fn move_hor(&mut self, by: i32, text: &Text) -> i32
pub fn move_hor(&mut self, by: i32, text: &Text) -> i32
Internal horizontal movement function.
Returns the number of distance moved through.
Sourcepub fn move_ver(
&mut self,
by: i32,
text: &Text,
area: &impl Area,
cfg: PrintCfg,
) -> i32
pub fn move_ver( &mut self, by: i32, text: &Text, area: &impl Area, cfg: PrintCfg, ) -> i32
Internal vertical movement function.
Returns the distance moved in lines.
Sourcepub fn move_ver_wrapped(
&mut self,
by: i32,
text: &Text,
area: &impl Area,
cfg: PrintCfg,
) -> i32
pub fn move_ver_wrapped( &mut self, by: i32, text: &Text, area: &impl Area, cfg: PrintCfg, ) -> i32
Internal vertical movement function.
Returns the distance moved in wrapped lines.
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.
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, bytes: &Bytes) -> Range<usize>
pub fn range(&self, bytes: &Bytes) -> Range<usize>
Returns the range between caret and anchor.
If anchor isn’t set, returns an empty range on caret.
A Selection’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, bytes: &Bytes) -> [Point; 2]
pub fn point_range(&self, bytes: &Bytes) -> [Point; 2]
Returns the range between caret and anchor.
If anchor isn’t set, returns a range that contains only
the caret’s current char.
Sourcepub fn point_range_excl(&self) -> [Point; 2]
pub fn point_range_excl(&self) -> [Point; 2]
Returns an exclusive range between caret and anchor
If anchor isn’t set, both Points will be the same.
Sourcepub fn set_desired_cols(&mut self, v: usize, w: usize)
pub fn set_desired_cols(&mut self, v: usize, w: usize)
Sets both the desired visual column, as well as the desired wrapped column