blob: 3ad98f49577dcba71b3b7fc1bdb5eb61aaed65a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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();
}
}
|