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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! A collection of plugins for building terminal-based applications with [Bevy] and [Ratatui].
//!
//! # Example
//!
//! ```rust,no_run
//! use std::time::Duration;
//!
//! use bevy::{
//! app::{AppExit, ScheduleRunnerPlugin},
//! prelude::*,
//! };
//! use bevy_ratatui::{event::KeyEvent, terminal::RatatuiContext, RatatuiPlugins};
//! use crossterm::event::KeyCode;
//! use ratatui::text::Text;
//!
//! fn main() {
//! let frame_time = Duration::from_secs_f32(1. / 60.);
//!
//! App::new()
//! .add_plugins((
//! MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(frame_time)),
//! RatatuiPlugins::default(),
//! ))
//! .add_systems(PreUpdate, input_system)
//! .add_systems(Update, draw_system)
//! .run();
//! }
//!
//! fn draw_system(mut context: ResMut<RatatuiContext>) -> Result {
//! context.draw(|frame| {
//! let text = Text::raw("hello world\npress 'q' to quit");
//! frame.render_widget(text, frame.area());
//! })?;
//!
//! Ok(())
//! }
//!
//! fn input_system(mut events: EventReader<KeyEvent>, mut exit: EventWriter<AppExit>) {
//! for event in events.read() {
//! if let KeyCode::Char('q') = event.code {
//! exit.send_default();
//! }
//! }
//! }
//! ```
//!
//! See the [examples] directory for more examples.
//!
//! # Input Forwarding
//!
//! The terminal input can be forwarded to the bevy input system. See the
//! [input_forwarding] module documentation for details.
//!
//! [Bevy]: https://bevyengine.org
//! [Ratatui]: https://ratatui.rs
//! [examples]: https://github.com/cxreiff/bevy_ratatui/tree/main/examples
pub use RatatuiPlugins;