[][src]Trait termwiz::lineedit::LineEditorHost

pub trait LineEditorHost {
    fn history(&mut self) -> &mut dyn History;

    fn render_prompt(&self, prompt: &str) -> Vec<OutputElement> { ... }
fn highlight_line(
        &self,
        line: &str,
        cursor_position: usize
    ) -> (Vec<OutputElement>, usize) { ... }
fn complete(
        &self,
        _line: &str,
        _cursor_position: usize
    ) -> Vec<CompletionCandidate> { ... } }

The LineEditorHost trait allows an embedding application to influence how the line editor functions. A concrete implementation of the host with neutral defaults is provided as NopLineEditorHost.

Required methods

fn history(&mut self) -> &mut dyn History

Returns the history implementation

Loading content...

Provided methods

fn render_prompt(&self, prompt: &str) -> Vec<OutputElement>

Given a prompt string, return the rendered form of the prompt as a sequence of OutputElement instances. The implementation is free to interpret the prompt string however it chooses; for instance, the application can opt to expand its own application specific escape sequences as it sees fit. The OutputElement type allows returning graphic attribute changes as well as textual output. The default implementation returns the prompt as-is with no coloring and no textual transformation.

fn highlight_line(
    &self,
    line: &str,
    cursor_position: usize
) -> (Vec<OutputElement>, usize)

Given a reference to the current line being edited and the position of the cursor, return the rendered form of the line as a sequence of OutputElement instances. While this interface technically allows returning arbitrary Text sequences, the application should preserve the column positions of the graphemes, otherwise the terminal cursor position won't match up to the correct location. The OutputElement type allows returning graphic attribute changes as well as textual output. The default implementation returns the line as-is with no coloring.

fn complete(
    &self,
    _line: &str,
    _cursor_position: usize
) -> Vec<CompletionCandidate>

Tab completion support. The line and current cursor position are provided and it is up to the embedding application to produce a list of completion candidates. The default implementation is an empty list.

Loading content...

Implementors

impl LineEditorHost for NopLineEditorHost[src]

Loading content...