diff options
author | Silas Bartha <[email protected]> | 2024-04-26 01:27:13 -0400 |
---|---|---|
committer | Silas Bartha <[email protected]> | 2024-04-26 01:27:13 -0400 |
commit | 646db8328611f21a5850cc9834b6c72bfdf0c829 (patch) | |
tree | 0d65f0c20b70da007aab141cfe6b123119e8c909 /src/lib.rs |
Initial Commitv0.1.0
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3ad98f4 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,43 @@ +use std::io::stdout; + +use bevy::prelude::*; +use crossterm::{ + event::PopKeyboardEnhancementFlags, terminal::disable_raw_mode, ExecutableCommand, +}; +use grex_dither_post_process::DitherPostProcessPlugin; +use grex_framebuffer_extract::FramebufferExtractPlugin; + +pub use crossterm::event::KeyCode; + +pub mod components; +pub mod events; +pub mod resources; +mod systems; + +pub struct TerminalDisplayPlugin; + +impl Plugin for TerminalDisplayPlugin { + fn build(&self, app: &mut App) { + app.add_plugins((DitherPostProcessPlugin, FramebufferExtractPlugin)) + .add_systems(Startup, systems::setup) + .add_systems( + Update, + ( + systems::input_handling, + systems::resize_handling, + systems::print_to_terminal, + ), + ) + .insert_resource(resources::EventQueue::default()) + .insert_resource(resources::TerminalInput::default()) + .add_event::<events::TerminalInputEvent>(); + } +} + +impl Drop for TerminalDisplayPlugin { + fn drop(&mut self) { + let mut stdout = stdout(); + stdout.execute(PopKeyboardEnhancementFlags).unwrap(); + disable_raw_mode().unwrap(); + } +} |