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

pub trait Buffer {
Show 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

fn len(&self) -> usize[src]

Return the number of lines stored in the buffer

fn get_tag(&self, tag: char) -> Result<usize, &'static str>[src]

Get line tagged with given letter. Not found is error

fn get_matching(
    &self,
    pattern: &str,
    curr_line: usize,
    backwards: bool
) -> Result<usize, &'static str>
[src]

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

fn mark_matching(
    &mut self,
    pattern: &str,
    selection: (usize, usize),
    inverse: bool
) -> Result<(), &'static str>
[src]

Set the matched flag on all lines matching given pattern

fn get_marked(&mut self) -> Result<Option<usize>, &'static str>[src]

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

fn tag_line(&mut self, index: usize, tag: char) -> Result<(), &'static str>[src]

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

fn insert<'a>(
    &mut self,
    data: &mut dyn Iterator<Item = &'a str>,
    index: usize
) -> Result<(), &'static str>
[src]

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

fn cut(&mut self, selection: (usize, usize)) -> Result<(), &'static str>[src]

Cut the selection from the buffer, into the clipboard

fn change<'a>(
    &mut self,
    data: &mut dyn Iterator<Item = &'a str>,
    selection: (usize, usize)
) -> Result<(), &'static str>
[src]

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

fn mov(
    &mut self,
    selection: (usize, usize),
    index: usize
) -> Result<(), &'static str>
[src]

Move selection to index

fn mov_copy(
    &mut self,
    selection: (usize, usize),
    index: usize
) -> Result<(), &'static str>
[src]

Moves a copy of the selection to index

fn join(&mut self, selection: (usize, usize)) -> Result<(), &'static str>[src]

Join all lines in selection into one line

fn copy(&mut self, selection: (usize, usize)) -> Result<(), &'static str>[src]

Copy selected lines into clipboard

fn paste(&mut self, index: usize) -> Result<usize, &'static str>[src]

Paste the clipboard contents to given index Leave clipboard unchanged

fn search_replace(
    &mut self,
    pattern: (&str, &str),
    selection: (usize, usize),
    global: bool
) -> Result<(usize, usize), &'static str>
[src]

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

fn read_from(
    &mut self,
    path: &str,
    index: Option<usize>,
    must_exist: bool
) -> Result<usize, &'static str>
[src]

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

fn write_to(
    &mut self,
    selection: Option<(usize, usize)>,
    path: &str,
    append: bool
) -> Result<(), &'static str>
[src]

Write the buffer to given path

fn saved(&self) -> bool[src]

Returns true if no changes have been made since last saving

fn get_selection<'a>(
    &'a self,
    selection: (usize, usize)
) -> Result<Box<dyn Iterator<Item = &'a str> + 'a>, &'static str>
[src]

Return the given selection without any formatting

Implementors