diff --git a/src/io/mod.rs b/src/io/mod.rs index 377ddeb..7fcbb58 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -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 diff --git a/src/main.rs b/src/main.rs index e48219e..db08adb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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()))?); } } }