Improve the repl mode 🥰

This commit is contained in:
Anas Elgarhy 2022-10-13 18:56:15 +02:00
parent d04c5973ea
commit 765d296f16
1 changed files with 3 additions and 3 deletions

View File

@ -43,7 +43,7 @@ impl Repl {
print!( print!(
"{}", "{}",
if self.loop_depth != 0 { if self.loop_depth != 0 {
"........ ".yellow() "............... ".yellow()
} else { } else {
PROMPT.to_string().truecolor(54, 76, 76) PROMPT.to_string().truecolor(54, 76, 76)
} }
@ -85,10 +85,10 @@ impl Repl {
self.term.write_str(&c.to_string())?; self.term.write_str(&c.to_string())?;
input.push(c); input.push(c);
} }
Key::Backspace => { Key::Backspace if !input.is_empty() => {
self.term.clear_line()?; self.term.clear_line()?;
self.print_prompt();
self.term.write_str(&input[0..input.len() - 1])?; self.term.write_str(&input[0..input.len() - 1])?;
self.term.move_cursor_left(1)?;
input.pop(); input.pop();
} }
Key::Enter => { Key::Enter => {