cl-repl: Fix menu behavior
This commit is contained in:
@@ -22,8 +22,8 @@ type ReplMode = (&'static str, &'static str, &'static str, ReplCallback);
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
const MODES: &[ReplMode] = &[
|
const MODES: &[ReplMode] = &[
|
||||||
(ansi::CYAN, " .>", " >", mode_run),
|
(ansi::CYAN, " .>", " >", mode_run),
|
||||||
(ansi::BRIGHT_BLUE, "l>", " >", mode_lex),
|
(ansi::BRIGHT_BLUE, " .>", " >", mode_lex),
|
||||||
(ansi::BRIGHT_MAGENTA, "f>", " >", mode_fmt),
|
(ansi::BRIGHT_MAGENTA, " .>", " >", mode_fmt),
|
||||||
];
|
];
|
||||||
|
|
||||||
const fn get_mode(mode: Mode) -> ReplMode {
|
const fn get_mode(mode: Mode) -> ReplMode {
|
||||||
@@ -70,14 +70,17 @@ pub fn main_menu(mode: Mode, ctx: &mut ctx::Context) -> ReplResult<()> {
|
|||||||
mode run : Evaluate some expressions"
|
mode run : Evaluate some expressions"
|
||||||
),
|
),
|
||||||
_ => match mode.3(ctx, &line) {
|
_ => match mode.3(ctx, &line) {
|
||||||
|
Ok(Response::Continue) => continue,
|
||||||
|
Ok(Response::Break) => return Ok(()),
|
||||||
|
Ok(Response::Deny) => {}
|
||||||
Ok(Response::Accept) => {
|
Ok(Response::Accept) => {
|
||||||
rl.accept();
|
rl.accept();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Ok(Response::Deny) => {}
|
Err(e) => {
|
||||||
Ok(Response::Break) => return Ok(()),
|
rl.print_inline(format_args!("\t\x1b[31m{e}\x1b[0m"))?;
|
||||||
Ok(Response::Continue) => continue,
|
continue;
|
||||||
Err(e) => rl.print_inline(format_args!("\t\x1b[91m{e}\x1b[0m"))?,
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rl.deny();
|
rl.deny();
|
||||||
|
|||||||
Reference in New Issue
Block a user