Struct shrs_utils::cursor_buffer::CursorBuffer
source · pub struct CursorBuffer { /* private fields */ }Expand description
Friendly wrapper around Rope data structure
Implementations§
source§impl CursorBuffer
impl CursorBuffer
sourcepub fn from_text(text: &str) -> Self
pub fn from_text(text: &str) -> Self
Create new CursorBuffer from string and sets cursor location to beginning
sourcepub fn move_cursor(&mut self, loc: Location) -> Result<()>
pub fn move_cursor(&mut self, loc: Location) -> Result<()>
Move the cursor using a location selector
sourcepub fn move_cursor_clamp(&mut self, _loc: Location)
pub fn move_cursor_clamp(&mut self, _loc: Location)
Move the cursor using a location selector, clamping the cursor if it were to move to invalid position
sourcepub fn insert(&mut self, loc: Location, text: &str) -> Result<()>
pub fn insert(&mut self, loc: Location, text: &str) -> Result<()>
Insert text and advance cursor to after the text inserted
sourcepub fn insert_inplace(&mut self, loc: Location, text: &str) -> Result<()>
pub fn insert_inplace(&mut self, loc: Location, text: &str) -> Result<()>
Insert text and offset cursor to point to same text
sourcepub fn delete(&mut self, start: Location, end: Location) -> Result<()>
pub fn delete(&mut self, start: Location, end: Location) -> Result<()>
Delete a length of text starting from location and move cursor to start of deleted text
pub fn location_slice( &mut self, start: Location, end: Location ) -> Result<RopeSlice<'_>>
sourcepub fn delete_inplace(&mut self, _loc: Location, _len: usize) -> Result<()>
pub fn delete_inplace(&mut self, _loc: Location, _len: usize) -> Result<()>
Delete a length of text starting from location and offset the cursor accordingly such that it points to the same text
In the case that cursor was pointing at deleted text, the behavior is the same as
delete
sourcepub fn delete_before(&mut self, start: Location, end: Location) -> Result<()>
pub fn delete_before(&mut self, start: Location, end: Location) -> Result<()>
Delete a length of text ending at location
sourcepub fn slice<R>(&self, char_range: R) -> RopeSlice<'_>where
R: RangeBounds<usize>,
pub fn slice<R>(&self, char_range: R) -> RopeSlice<'_>where
R: RangeBounds<usize>,
Get a slice of the text
sourcepub fn chars(&self, loc: Location) -> Result<Chars<'_>>
pub fn chars(&self, loc: Location) -> Result<Chars<'_>>
Create forward iterator of chars from a location
sourcepub fn to_absolute(&self, loc: Location) -> Result<usize>
pub fn to_absolute(&self, loc: Location) -> Result<usize>
Converts Location to an absolute index into the buffer. Performs bounds checking