diff options
| author | Jonas Maier <> | 2026-03-05 11:02:23 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-05 11:02:23 +0100 |
| commit | 6c4ce3ce96f0e1f20408c8399e4908f463ea840e (patch) | |
| tree | 7be1be6d74ce9663d85548558cea2f3b9f0fba85 | |
| parent | 50fc850f165482a8304681e85a70ffb41dba731d (diff) | |
| download | pish-6c4ce3ce96f0e1f20408c8399e4908f463ea840e.tar.gz | |
panic catcher
| -rw-r--r-- | src/main.rs | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 4e3bb23..fe66eba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -148,17 +148,10 @@ fn run_command(raw: &ScopedRawMode, line: Vec<u8>) { print!("\r{status_string}{PROMPT}"); } -fn main() { - crate::panic::hook(); - +fn event_loop() { let stdin = io::stdin(); let stdout = io::stdout(); - if !stdin.is_terminal() { - println!("need to run in a tty"); - return; - } - let fd = stdin.as_raw_fd(); let raw = ScopedRawMode::on_fd(fd); raw.enable(); @@ -206,6 +199,10 @@ fn main() { } } + b'\t' => { + todo!() + } + // Escape sequence 27 => { let mut seq = [0u8; 2]; @@ -250,5 +247,23 @@ fn main() { } raw.disable(); +} + +fn main() { + if !io::stdin().is_terminal() { + println!("need to run in a tty"); + return; + } + + crate::panic::hook(); + + loop { + let res = std::panic::catch_unwind(event_loop); + match res { + Ok(_) => break, + Err(_) => println!("sorry about that, let's continue with the shell"), + } + } + println!("bye"); } |
