cl-repl: Fix menu behavior

This commit is contained in:
2025-10-26 00:02:02 -04:00
parent 55e02fd919
commit 91025fccb0

View File

@@ -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();