pub struct Selection { /* private fields */ }Expand description
A cursor in the text buffer. 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: &Area,
opts: PrintOpts,
) -> i32
pub fn move_ver( &mut self, by: i32, text: &Text, area: &Area, opts: PrintOpts, ) -> i32
Internal vertical movement function.
Returns the distance moved in lines.
Sourcepub fn move_ver_wrapped(
&mut self,
by: i32,
text: &Text,
area: &Area,
opts: PrintOpts,
) -> i32
pub fn move_ver_wrapped( &mut self, by: i32, text: &Text, area: &Area, opts: PrintOpts, ) -> 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 buffer
The anchor and current act as a range of text on the
buffer.
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 buffer) of the caret. Indexed at 0
Sourcepub fn char(&self) -> usize
pub fn char(&self) -> usize
The char (relative to the beginning of the buffer) of the caret. Indexed at 0
Sourcepub fn byte_range(&self, bytes: &Bytes) -> Range<usize>
pub fn byte_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) -> Range<Point>
pub fn point_range(&self, bytes: &Bytes) -> Range<Point>
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) -> Range<Point>
pub fn point_range_excl(&self) -> Range<Point>
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
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Selection
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Selection
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Auto Trait Implementations§
impl !Freeze for Selection
impl !RefUnwindSafe for Selection
impl Send for Selection
impl !Sync for Selection
impl Unpin for Selection
impl UnwindSafe for Selection
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§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.