REPL: inline output on same line as input (traditional Forth style)

Move cursor back to end of input line so output appears inline:
  > 2 2 + . 4  ok
instead of on a separate line.
This commit is contained in:
2026-04-12 17:28:06 +02:00
parent 2994486191
commit 6118ddc53c
+8 -4
View File
@@ -311,11 +311,15 @@ fn cmd_eval_or_repl(file: Option<&str>) -> anyhow::Result<()> {
match vm.evaluate(&line) {
Ok(()) => {
let output = vm.take_output();
if !output.is_empty() {
print!("{output}");
}
if !vm.is_compiling() {
println!(" ok");
// Move cursor back up to end of input line so
// output appears inline, like traditional Forth:
// > 2 2 + . 4 ok
let col = prompt.len() + line.len() + 1;
print!("\x1b[A\x1b[{col}G {output} ok");
println!();
} else if !output.is_empty() {
print!("{output}");
}
}
Err(e) => {