cl-repl: Usability improvements

- Don't print empty
- Don't needlessly append newline to cleared screen
This commit is contained in:
John 2025-02-18 21:48:36 -06:00
parent edabbe1655
commit 01cf9d93e2

View File

@ -6,7 +6,7 @@ use cl_parser::Parser;
use repline::{error::ReplResult, prebaked::*};
pub fn clear() {
println!("{}", ansi::CLEAR_ALL);
print!("{}", ansi::CLEAR_ALL);
banner()
}
@ -44,6 +44,9 @@ pub fn run(ctx: &mut ctx::Context) -> ReplResult<()> {
use cl_parser::inliner::ModuleInliner;
read_and(ansi::CYAN, "cl>", " ?>", |line| {
if line.trim().is_empty() {
return Ok(Response::Deny);
}
let code = Parser::new(Lexer::new(line)).parse::<Stmt>()?;
let code = ModuleInliner::new(".").fold_stmt(code);