From 646db8328611f21a5850cc9834b6c72bfdf0c829 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Fri, 26 Apr 2024 01:27:13 -0400 Subject: Initial Commit --- src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/lib.rs (limited to 'src/lib.rs') 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::(); + } +} + +impl Drop for TerminalDisplayPlugin { + fn drop(&mut self) { + let mut stdout = stdout(); + stdout.execute(PopKeyboardEnhancementFlags).unwrap(); + disable_raw_mode().unwrap(); + } +} -- cgit v1.2.3