Add ANSI coloring
This commit is contained in:
parent
e528c09623
commit
fad8d97212
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -161,6 +161,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -921,6 +930,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
|||||||
name = "dust-lang"
|
name = "dust-lang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ansi_term",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"comfy-table",
|
"comfy-table",
|
||||||
|
@ -35,3 +35,4 @@ reqwest = { version = "0.11.18", features = ["blocking", "json"] }
|
|||||||
serde_json = "1.0.104"
|
serde_json = "1.0.104"
|
||||||
egui_extras = "0.22.0"
|
egui_extras = "0.22.0"
|
||||||
rustyline = { version = "12.0.0", features = ["with-file-history", "derive"] }
|
rustyline = { version = "12.0.0", features = ["with-file-history", "derive"] }
|
||||||
|
ansi_term = "0.12.1"
|
||||||
|
@ -62,9 +62,6 @@ struct DustReadline {
|
|||||||
|
|
||||||
tool_hints: Vec<ToolHint>,
|
tool_hints: Vec<ToolHint>,
|
||||||
|
|
||||||
#[rustyline(Validator)]
|
|
||||||
validator: MatchingBracketValidator,
|
|
||||||
|
|
||||||
#[rustyline(Hinter)]
|
#[rustyline(Hinter)]
|
||||||
hinter: HistoryHinter,
|
hinter: HistoryHinter,
|
||||||
}
|
}
|
||||||
@ -73,7 +70,6 @@ impl DustReadline {
|
|||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
completer: FilenameCompleter::new(),
|
completer: FilenameCompleter::new(),
|
||||||
validator: MatchingBracketValidator::new(),
|
|
||||||
hinter: HistoryHinter {},
|
hinter: HistoryHinter {},
|
||||||
tool_hints: TOOL_LIST
|
tool_hints: TOOL_LIST
|
||||||
.iter()
|
.iter()
|
||||||
@ -133,36 +129,10 @@ impl Hinter for DustReadline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Highlighter for DustReadline {
|
impl Highlighter for DustReadline {
|
||||||
fn highlight<'l>(&self, line: &'l str, pos: usize) -> std::borrow::Cow<'l, str> {
|
|
||||||
let _ = pos;
|
|
||||||
Cow::Borrowed(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
|
|
||||||
&'s self,
|
|
||||||
prompt: &'p str,
|
|
||||||
default: bool,
|
|
||||||
) -> std::borrow::Cow<'b, str> {
|
|
||||||
let _ = default;
|
|
||||||
Cow::Borrowed(prompt)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> {
|
fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> {
|
||||||
Cow::Borrowed(hint)
|
let highlighted = ansi_term::Colour::Red.paint(hint).to_string();
|
||||||
}
|
|
||||||
|
|
||||||
fn highlight_candidate<'c>(
|
Cow::Owned(highlighted)
|
||||||
&self,
|
|
||||||
candidate: &'c str, // FIXME should be Completer::Candidate
|
|
||||||
completion: rustyline::CompletionType,
|
|
||||||
) -> std::borrow::Cow<'c, str> {
|
|
||||||
let _ = completion;
|
|
||||||
Cow::Borrowed(candidate)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn highlight_char(&self, line: &str, pos: usize) -> bool {
|
|
||||||
let _ = (line, pos);
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user