From c2d89772336c52cce0b629f6ffc506eb1f221867 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Thu, 21 Nov 2024 12:33:58 -0500 Subject: Thu Nov 21 12:33:58 PM EST 2024 --- src/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 09134f9..e17f271 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! Bevy plugin which allows a camera to render to a terminal window. use std::{ - fs::OpenOptions, io::stdout, path::PathBuf, sync::{Arc, Mutex} + fs::OpenOptions, io::{stdout, Write}, path::PathBuf, sync::{Arc, Mutex} }; use bevy::{ @@ -79,6 +79,7 @@ impl Plugin for TerminalDisplayPlugin { std::panic::set_hook(Box::new(move |info| { let _ = restore_terminal(); + error!("{info}"); panic(info); })); @@ -94,19 +95,21 @@ impl Plugin for TerminalDisplayPlugin { display::systems::resize_handling, display::systems::print_to_terminal, widgets::systems::widget_input_handling, + widgets::systems::update_widgets, ), ) .insert_resource(display::resources::Terminal::default()) .insert_resource(input::resources::EventQueue::default()) - .insert_resource(input::resources::TerminalInput::default()) .add_event::(); } } -fn restore_terminal() { +fn restore_terminal() -> Result<(), Box>{ + disable_raw_mode()?; let mut stdout = stdout(); - let _ = stdout.execute(PopKeyboardEnhancementFlags); - let _ = stdout.execute(DisableMouseCapture); - let _ = stdout.execute(LeaveAlternateScreen); - let _ = disable_raw_mode(); + stdout.execute(PopKeyboardEnhancementFlags)? + .execute(DisableMouseCapture)? + .execute(LeaveAlternateScreen)? + .flush()?; + Ok(()) } -- cgit v1.2.3