Trait rustyline::highlight::Highlighter
source · pub trait Highlighter {
// Provided methods
fn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str> { ... }
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
&'s self,
prompt: &'p str,
default: bool,
) -> Cow<'b, str> { ... }
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> { ... }
fn highlight_candidate<'c>(
&self,
candidate: &'c str,
completion: CompletionType,
) -> Cow<'c, str> { ... }
fn highlight_char(&self, line: &str, pos: usize, kind: CmdKind) -> bool { ... }
}
Expand description
Syntax highlighter with ANSI color.
Currently, the highlighted version must have the same display width as the original input.
Provided Methods§
sourcefn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str>
fn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str>
Takes the currently edited line
with the cursor pos
ition and
returns the highlighted version (with ANSI color).
For example, you can implement blink-matching-paren.
sourcefn highlight_prompt<'b, 's: 'b, 'p: 'b>(
&'s self,
prompt: &'p str,
default: bool,
) -> Cow<'b, str>
fn highlight_prompt<'b, 's: 'b, 'p: 'b>( &'s self, prompt: &'p str, default: bool, ) -> Cow<'b, str>
Takes the prompt
and
returns the highlighted version (with ANSI color).
sourcefn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str>
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str>
Takes the hint
and
returns the highlighted version (with ANSI color).
sourcefn highlight_candidate<'c>(
&self,
candidate: &'c str,
completion: CompletionType,
) -> Cow<'c, str>
fn highlight_candidate<'c>( &self, candidate: &'c str, completion: CompletionType, ) -> Cow<'c, str>
Takes the completion candidate
and
returns the highlighted version (with ANSI color).
Currently, used only with CompletionType::List
.