Trait add_ed::buffer::Buffer[][src]

pub trait Buffer {
Show 19 methods fn len(&self) -> usize;
fn get_tag(&self, tag: char) -> Result<usize, &'static str>;
fn get_matching(
        &self,
        pattern: &str,
        curr_line: usize,
        backwards: bool
    ) -> Result<usize, &'static str>;
fn mark_matching(
        &mut self,
        pattern: &str,
        selection: (usize, usize),
        inverse: bool
    ) -> Result<(), &'static str>;
fn get_marked(&mut self) -> Result<Option<usize>, &'static str>;
fn tag_line(&mut self, index: usize, tag: char) -> Result<(), &'static str>;
fn insert<'a>(
        &mut self,
        data: &mut dyn Iterator<Item = &'a str>,
        index: usize
    ) -> Result<(), &'static str>;
fn cut(&mut self, selection: (usize, usize)) -> Result<(), &'static str>;
fn change<'a>(
        &mut self,
        data: &mut dyn Iterator<Item = &'a str>,
        selection: (usize, usize)
    ) -> Result<(), &'static str>;
fn mov(
        &mut self,
        selection: (usize, usize),
        index: usize
    ) -> Result<(), &'static str>;
fn mov_copy(
        &mut self,
        selection: (usize, usize),
        index: usize
    ) -> Result<(), &'static str>;
fn join(&mut self, selection: (usize, usize)) -> Result<(), &'static str>;
fn copy(&mut self, selection: (usize, usize)) -> Result<(), &'static str>;
fn paste(&mut self, index: usize) -> Result<usize, &'static str>;
fn search_replace(
        &mut self,
        pattern: (&str, &str),
        selection: (usize, usize),
        global: bool
    ) -> Result<(usize, usize), &'static str>;
fn read_from(
        &mut self,
        path: &str,
        index: Option<usize>,
        must_exist: bool
    ) -> Result<usize, &'static str>;
fn write_to(
        &mut self,
        selection: Option<(usize, usize)>,
        path: &str,
        append: bool
    ) -> Result<(), &'static str>;
fn saved(&self) -> bool;
fn get_selection<'a>(
        &'a self,
        selection: (usize, usize)
    ) -> Result<Box<dyn Iterator<Item = &'a str> + 'a>, &'static str>;
}
Expand description

Trait that defines a buffer supporting ’ed’s base commands

Required methods

Return the number of lines stored in the buffer

Get line tagged with given letter. Not found is error

Return the nearest previous/following index in the selection that contains the regex pattern

Set the matched flag on all lines matching given pattern

Get a line with the matched flag set, clearing that line’s flag

Mark a line with a letter, non letter chars should error

Takes a iterator over lines in strings and inserts at given index

Cut the selection from the buffer, into the clipboard

Equal to cut of selection and insert at start of selection.

Move selection to index

Moves a copy of the selection to index

Join all lines in selection into one line

Copy selected lines into clipboard

Paste the clipboard contents to given index Leave clipboard unchanged

Perform regex search and replace on the selection changing pattern.0 to pattern.1 If pattern is empty, should re-use stored pattern from previous s command Returns selection, since it may delete or add lines

Read to the buffer from given path If index is None replaces current buffer with read lines Return number of lines read

Write the buffer to given path

Returns true if no changes have been made since last saving

Return the given selection without any formatting

Implementors