aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs43
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();
+ }
+}