Struct liner::Buffer

source ·
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

source

pub fn new() -> Self

source

pub fn clear_actions(&mut self)

source

pub fn start_undo_group(&mut self)

source

pub fn end_undo_group(&mut self)

source

pub fn undo(&mut self) -> bool

source

pub fn redo(&mut self) -> bool

source

pub fn revert(&mut self) -> bool

source

pub fn last_arg(&self) -> Option<&[char]>

source

pub fn num_chars(&self) -> usize

source

pub fn num_bytes(&self) -> usize

source

pub fn char_before(&self, cursor: usize) -> Option<char>

source

pub fn char_after(&self, cursor: usize) -> Option<char>

source

pub fn remove(&mut self, start: usize, end: usize) -> usize

Returns the number of characters removed.

source

pub fn insert(&mut self, start: usize, text: &[char])

source

pub fn insert_from_buffer(&mut self, other: &Buffer)

source

pub fn copy_buffer(&mut self, other: &Buffer)

source

pub fn range(&self, start: usize, end: usize) -> String

source

pub fn range_chars(&self, start: usize, end: usize) -> Vec<char>

source

pub fn width(&self) -> Vec<usize>

source

pub fn range_width(&self, start: usize, end: usize) -> Vec<usize>

source

pub fn lines(&self) -> Vec<String>

source

pub fn chars(&self) -> Iter<'_, char>

source

pub fn truncate(&mut self, num: usize)

source

pub fn print<W>(&self, out: &mut W) -> Result<()>
where W: Write,

source

pub fn as_bytes(&self) -> Vec<u8>

source

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.

source

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.

source

pub fn contains(&self, pattern: &Buffer) -> bool

Check if the buffer contains pattern. Used to implement history search.

source

pub fn is_empty(&self) -> bool

Return true if the buffer is empty.

Trait Implementations§

source§

impl Clone for Buffer

source§

fn clone(&self) -> Buffer

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Buffer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Buffer

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Buffer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a str> for Buffer

source§

fn from(s: &'a str) -> Self

Converts to this type from the input type.
source§

impl From<Buffer> for String

source§

fn from(buf: Buffer) -> Self

Converts to this type from the input type.
source§

impl From<String> for Buffer

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl FromIterator<char> for Buffer

source§

fn from_iter<T: IntoIterator<Item = char>>(t: T) -> Self

Creates a value from an iterator. Read more
source§

impl PartialEq for Buffer

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Buffer

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.