pub struct Buffer { /* private fields */ }
Expand description
A buffer for text in the line editor.
It keeps track of each action performed on it for use with undo/redo.
Implementations§
Source§impl Buffer
impl Buffer
pub fn new() -> Self
pub fn clear_actions(&mut self)
pub fn start_undo_group(&mut self)
pub fn end_undo_group(&mut self)
pub fn undo(&mut self) -> Option<usize>
pub fn redo(&mut self) -> Option<usize>
pub fn revert(&mut self) -> bool
pub fn is_last_arg_newline(&self) -> bool
pub fn last_arg(&self) -> Option<&str>
pub fn num_lines(&self) -> usize
pub fn num_graphemes(&self) -> usize
pub fn lines(&self) -> impl Iterator<Item = &str> + '_
pub fn num_bytes(&self) -> usize
pub fn grapheme_before(&self, cursor: usize) -> Option<&str>
pub fn grapheme_after(&self, cursor: usize) -> Option<&str>
Sourcepub fn remove_unrecorded(&mut self, start: usize, end: usize)
pub fn remove_unrecorded(&mut self, start: usize, end: usize)
Returns the graphemes removed. Does not register as an action in the undo/redo buffer or in the buffer’s register.
Sourcepub fn remove(&mut self, start: usize, end: usize) -> usize
pub fn remove(&mut self, start: usize, end: usize) -> usize
Returns the number of graphemes removed.
Sourcepub fn insert_register_around_idx(
&mut self,
idx: usize,
count: usize,
right: bool,
) -> usize
pub fn insert_register_around_idx( &mut self, idx: usize, count: usize, right: bool, ) -> usize
Insert contents of register to the right or to the left of the provided start index in the current buffer and return length of text inserted.
pub fn insert_str(&mut self, start: usize, text: &str) -> usize
pub fn insert<'a, I>(&mut self, start: usize, text: I) -> usize
pub fn insert_action(&mut self, act: Action)
pub fn append_buffer(&mut self, other: &Buffer) -> usize
pub fn copy_buffer(&mut self, other: &Buffer) -> usize
pub fn range_graphemes_all(&self) -> GraphemeIter<'_>
pub fn range_graphemes_until(&self, until: usize) -> GraphemeIter<'_>
pub fn range_graphemes_from(&self, start: usize) -> GraphemeIter<'_>
pub fn range(&self, start: usize, end: usize) -> &str
pub fn range_graphemes(&self, start: usize, end: usize) -> GraphemeIter<'_>
pub fn line_width_until(&self, until: usize) -> impl Iterator<Item = usize> + '_
pub fn line_widths(&self) -> impl Iterator<Item = usize> + '_
pub fn truncate(&mut self, num: usize)
pub fn print<W>(&self, out: &mut W) -> Result<()>where
W: Write,
Sourcepub fn print_rest<W>(&self, out: &mut W, after: usize) -> Result<usize>where
W: Write,
pub fn print_rest<W>(&self, out: &mut W, after: usize) -> Result<usize>where
W: Write,
Takes other buffer, measures its length and prints this buffer from the point where the other stopped. Used to implement autosuggestions.
pub fn yank(&mut self, start: usize, end: usize)
Sourcepub fn starts_with(&self, other: &Buffer) -> bool
pub fn starts_with(&self, other: &Buffer) -> bool
Check if the other buffer starts with the same content as this one. Used to implement autosuggestions.
Trait Implementations§
Source§impl FromIterator<char> for Buffer
impl FromIterator<char> for Buffer
impl Eq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
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
Mutably borrows from an owned value. Read more