chore: use rustyline@4.1.0 for now (#128)

* switch to rustyline 4.1.0

* adapt highlight_prompt to 4.1.0 format

* fix rust fmt
This commit is contained in:
Lars-Magnus Skog
2019-06-06 13:02:40 +02:00
committed by dignifiedquire
parent 05e097baaa
commit 9a0a451999
3 changed files with 8 additions and 17 deletions

View File

@@ -31,7 +31,7 @@ serde_json = "1.0"
chrono = "0.4.6"
failure = "0.1.5"
# TODO: make optional
rustyline = { git = "https://github.com/kkawakam/rustyline/" }
rustyline = "4.1.0"
lazy_static = "1.3.0"
[dev-dependencies]

View File

@@ -83,12 +83,7 @@ pub unsafe fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
info!(context, 0, "(8) Rest but server config reset.");
}
(context.cb)(
context,
Event::MSGS_CHANGED,
0 as uintptr_t,
0 as uintptr_t,
);
(context.cb)(context, Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t);
1
}

View File

@@ -243,7 +243,6 @@ struct DcHelper {
completer: FilenameCompleter,
highlighter: MatchingBracketHighlighter,
hinter: HistoryHinter,
colored_prompt: String,
}
impl Completer for DcHelper {
@@ -358,14 +357,13 @@ impl Hinter for DcHelper {
}
}
static COLORED_PROMPT: &'static str = "\x1b[1;32m> \x1b[0m";
static PROMPT: &'static str = "> ";
impl Highlighter for DcHelper {
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
&'s self,
prompt: &'p str,
default: bool,
) -> Cow<'b, str> {
if default {
Borrowed(&self.colored_prompt)
fn highlight_prompt<'p>(&self, prompt: &'p str) -> Cow<'p, str> {
if prompt == PROMPT {
Borrowed(COLORED_PROMPT)
} else {
Borrowed(prompt)
}
@@ -423,7 +421,6 @@ fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
completer: FilenameCompleter::new(),
highlighter: MatchingBracketHighlighter::new(),
hinter: HistoryHinter {},
colored_prompt: "".to_owned(),
};
let mut rl = Editor::with_config(config);
rl.set_helper(Some(h));
@@ -435,7 +432,6 @@ fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
loop {
let p = "> ";
rl.helper_mut().unwrap().colored_prompt = format!("\x1b[1;32m{}\x1b[0m", p);
let readline = rl.readline(&p);
match readline {
Ok(line) => {