Trait add_ed::ui::UI[][src]

pub trait UI {
    fn print(&mut self, ed: EdState<'_>, data: &str) -> Result<(), &'static str>;
fn get_command(
        &mut self,
        ed: EdState<'_>,
        prefix: Option<char>
    ) -> Result<String, &'static str>;
fn get_input(
        &mut self,
        ed: EdState<'_>,
        terminator: char
    ) -> Result<Vec<String>, &'static str>;
fn print_selection(
        &mut self,
        ed: EdState<'_>,
        selection: (usize, usize),
        numbered: bool,
        literal: bool
    ) -> Result<(), &'static str>; }
Expand description

The UI trait used to abstract all common UI operations

Required methods

A basic print for output of commands

  • EdState passed in for interactive viewing and status printouts. Ignore if unused.

Get a command for parsing and execution

  • EdState passed in for interactive viewing and status printouts. Ignore if unused.
  • Prefix is printed at start of the line if given. Ignore if unsuited for your UI.
  • Must return a single line to be parsed, trimming optional

Get input lines until given character is entered alone on a line

  • EdState passed in for interactive viewing and status printouts. Ignore if unused.
  • Must return a vector newline terminated strings and not return the terminating line

Print the given selection with the given options

Depending on UI this may mean changing viewport settings and moving to given selection.

  • EdState passed in for path based highlighting and status printouts. Ignore if unused.
  • Separate selection passed in since the selection to print isn’t saved to state until after printing.

Implementors