mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
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:
committed by
dignifiedquire
parent
05e097baaa
commit
9a0a451999
@@ -31,7 +31,7 @@ serde_json = "1.0"
|
|||||||
chrono = "0.4.6"
|
chrono = "0.4.6"
|
||||||
failure = "0.1.5"
|
failure = "0.1.5"
|
||||||
# TODO: make optional
|
# TODO: make optional
|
||||||
rustyline = { git = "https://github.com/kkawakam/rustyline/" }
|
rustyline = "4.1.0"
|
||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -83,12 +83,7 @@ pub unsafe fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
|
|||||||
info!(context, 0, "(8) Rest but server config reset.");
|
info!(context, 0, "(8) Rest but server config reset.");
|
||||||
}
|
}
|
||||||
|
|
||||||
(context.cb)(
|
(context.cb)(context, Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t);
|
||||||
context,
|
|
||||||
Event::MSGS_CHANGED,
|
|
||||||
0 as uintptr_t,
|
|
||||||
0 as uintptr_t,
|
|
||||||
);
|
|
||||||
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,6 @@ struct DcHelper {
|
|||||||
completer: FilenameCompleter,
|
completer: FilenameCompleter,
|
||||||
highlighter: MatchingBracketHighlighter,
|
highlighter: MatchingBracketHighlighter,
|
||||||
hinter: HistoryHinter,
|
hinter: HistoryHinter,
|
||||||
colored_prompt: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Completer for DcHelper {
|
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 {
|
impl Highlighter for DcHelper {
|
||||||
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
|
fn highlight_prompt<'p>(&self, prompt: &'p str) -> Cow<'p, str> {
|
||||||
&'s self,
|
if prompt == PROMPT {
|
||||||
prompt: &'p str,
|
Borrowed(COLORED_PROMPT)
|
||||||
default: bool,
|
|
||||||
) -> Cow<'b, str> {
|
|
||||||
if default {
|
|
||||||
Borrowed(&self.colored_prompt)
|
|
||||||
} else {
|
} else {
|
||||||
Borrowed(prompt)
|
Borrowed(prompt)
|
||||||
}
|
}
|
||||||
@@ -423,7 +421,6 @@ fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
|
|||||||
completer: FilenameCompleter::new(),
|
completer: FilenameCompleter::new(),
|
||||||
highlighter: MatchingBracketHighlighter::new(),
|
highlighter: MatchingBracketHighlighter::new(),
|
||||||
hinter: HistoryHinter {},
|
hinter: HistoryHinter {},
|
||||||
colored_prompt: "".to_owned(),
|
|
||||||
};
|
};
|
||||||
let mut rl = Editor::with_config(config);
|
let mut rl = Editor::with_config(config);
|
||||||
rl.set_helper(Some(h));
|
rl.set_helper(Some(h));
|
||||||
@@ -435,7 +432,6 @@ fn main_0(args: Vec<String>) -> Result<(), failure::Error> {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
let p = "> ";
|
let p = "> ";
|
||||||
rl.helper_mut().unwrap().colored_prompt = format!("\x1b[1;32m{}\x1b[0m", p);
|
|
||||||
let readline = rl.readline(&p);
|
let readline = rl.readline(&p);
|
||||||
match readline {
|
match readline {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user