From be347f26767b1a45cb77477307a1988ebdc3848c Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Thu, 5 Mar 2026 12:17:24 +0100 Subject: reloading, clearing --- src/main.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 44985fb..885e03d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,6 +73,15 @@ fn run_command(raw: &ScopedRawMode, line: Vec) { return; } + b"clear" => clear_screen(), + #[cfg(debug_assertions)] + b"re" => { + // restart shell + raw.disable(); + let _ = Command::new("cargo").arg("run").status(); + raw.disable(); + std::process::exit(0); + } b"from" => todo!("read from file"), b"to" | b"into" => todo!("write into file"), b"append" => todo!("append to file"), @@ -156,6 +165,15 @@ fn env_path() { } } +fn completely_clear_screen() { + print!("\x1B[2J\x1B[1;1H"); +} + +fn clear_screen() { + completely_clear_screen(); + print!("{PROMPT}") +} + fn event_loop() { env_path(); @@ -187,16 +205,10 @@ fn event_loop() { } // Ctrl+L - 12 => todo!(), + 12 => clear_screen(), // Ctrl+R - 18 => { - // restart shell - raw.disable(); - let _ = Command::new("cargo").arg("run").status(); - raw.disable(); - std::process::exit(0); - }, + 18 => {} // Enter b'\r' => { -- cgit v1.2.3