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) -> bool
pub fn redo(&mut self) -> bool
pub fn revert(&mut self) -> bool
pub fn last_arg(&self) -> Option<&[char]>
pub fn num_chars(&self) -> usize
pub fn num_bytes(&self) -> usize
pub fn char_before(&self, cursor: usize) -> Option<char>
pub fn char_after(&self, cursor: usize) -> Option<char>
sourcepub fn remove(&mut self, start: usize, end: usize) -> usize
pub fn remove(&mut self, start: usize, end: usize) -> usize
Returns the number of characters removed.
pub fn insert(&mut self, start: usize, text: &[char])
pub fn insert_from_buffer(&mut self, other: &Buffer)
pub fn copy_buffer(&mut self, other: &Buffer)
pub fn range(&self, start: usize, end: usize) -> String
pub fn range_chars(&self, start: usize, end: usize) -> Vec<char>
pub fn width(&self) -> Vec<usize>
pub fn range_width(&self, start: usize, end: usize) -> Vec<usize>
pub fn lines(&self) -> Vec<String>
pub fn chars(&self) -> Iter<'_, char>
pub fn truncate(&mut self, num: usize)
pub fn print<W>(&self, out: &mut W) -> Result<()>where
W: Write,
pub fn as_bytes(&self) -> Vec<u8>
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.
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
source§impl PartialEq for Buffer
impl PartialEq for Buffer
impl Eq for Buffer
Auto Trait Implementations§
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