Give rustyline non-ansi to begin with. Fixes Windows

This commit is contained in:
Jonathan Turner
2019-11-17 09:02:26 +13:00
parent 17e8a5ce38
commit db218e06dc
4 changed files with 60 additions and 8 deletions

View File

@ -14,11 +14,12 @@ use std::borrow::Cow::{self, Owned};
pub(crate) struct Helper {
context: Context,
pub colored_prompt: String,
}
impl Helper {
pub(crate) fn new(context: Context) -> Helper {
Helper { context }
Helper { context, colored_prompt: String::new() }
}
}
@ -41,8 +42,14 @@ impl Hinter for Helper {
}
impl Highlighter for Helper {
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(&'s self, prompt: &'p str, _: bool) -> Cow<'b, str> {
Owned("\x1b[32m".to_owned() + &prompt + "\x1b[m")
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(&'s self, prompt: &'p str, default: bool) -> Cow<'b, str> {
use std::borrow::Cow::Borrowed;
if default {
Borrowed(&self.colored_prompt)
} else {
Borrowed(prompt)
}
}
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {