mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FEATURE: Show line numbers for ucg statements in the repl.
This commit is contained in:
parent
f81eb95e9a
commit
fc9595ab38
@ -24,6 +24,10 @@ impl StatementAccumulator {
|
||||
Self { acc: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn next_line(&self) -> usize {
|
||||
self.acc.len() + 1
|
||||
}
|
||||
|
||||
/// Tells you if the latest line ends in the statement terminator.
|
||||
///
|
||||
/// Returns None if it wasn't a terminated statement and leaves the
|
||||
|
@ -551,9 +551,11 @@ fn do_repl(
|
||||
let mut builder = build::FileBuilder::new(std::env::current_dir()?, import_paths, cache);
|
||||
// loop
|
||||
let mut lines = ucglib::io::StatementAccumulator::new();
|
||||
println!("Welcome to the UCG repl. Ctrl-D to exit");
|
||||
println!("");
|
||||
loop {
|
||||
// print prompt
|
||||
lines.push(editor.readline("ucg> ")?);
|
||||
lines.push(editor.readline(&format!("{}> ", lines.next_line()))?);
|
||||
// check to see if that line is a statement
|
||||
loop {
|
||||
// read a statement
|
||||
@ -573,7 +575,7 @@ fn do_repl(
|
||||
break;
|
||||
}
|
||||
// if not then keep accumulating lines without a prompt
|
||||
lines.push(editor.readline(">> ")?);
|
||||
lines.push(editor.readline(&format!("{}> ", lines.next_line()))?);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user