### Basic Bevy Ratatui Setup Source: https://docs.rs/crate/bevy_ratatui/latest/source/README.md Set up a Ratatui application using Bevy for the update loop, input events, and drawing. Add `RatatuiPlugins` and a system to draw content to the context. ```rust use bevy::prelude::*; use bevy::app::ScheduleRunnerPlugin; use bevy_ratatui::{RatatuiContext, RatatuiPlugins}; fn main() { let frame_time = std::time::Duration::from_secs_f32(1. / 60.); App::new() .add_plugins(( MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(frame_time)), RatatuiPlugins::default(), )) .add_systems(Update, draw_system) .run(); } fn draw_system(mut context: ResMut) -> Result { context.draw(|frame| { let text = ratatui::text::Text::raw("hello world"); frame.render_widget(text, frame.area()); })?; Ok(()) } ``` -------------------------------- ### Handling User Input in Bevy Ratatui Source: https://docs.rs/crate/bevy_ratatui/latest/source/README.md Listen for crossterm input messages forwarded by the crate to handle user input. This example shows how to exit the application when 'q' is pressed. ```rust use bevy::app::AppExit; use bevy_ratatui::event::KeyMessage; use crossterm::event::KeyCode; fn input_system(mut messages: MessageReader, mut exit: MessageWriter) { for message in messages.read() { if let KeyCode::Char('q') = message.code { exit.send_default(); } } } ``` -------------------------------- ### Handle User Input with KeyMessage Source: https://docs.rs/crate/bevy_ratatui/latest A system that reads KeyMessage events forwarded by bevy_ratatui to handle user input. This example shows how to exit the application when the 'q' key is pressed. ```rust use bevy::app::AppExit; use bevy_ratatui::event::KeyMessage; use crossterm::event::KeyCode; fn input_system(mut messages: MessageReader, mut exit: MessageWriter) { for message in messages.read() { if let KeyCode::Char('q') = message.code { exit.send_default(); } } } ``` -------------------------------- ### Initialize Bevy App with Ratatui Source: https://docs.rs/crate/bevy_ratatui/latest Sets up a Bevy application with the necessary plugins for Ratatui integration. This includes the minimal Bevy plugins and the RatatuiPlugins. A system for drawing is also added. ```rust use bevy::prelude::*; use bevy::app::ScheduleRunnerPlugin; use bevy_ratatui::{RatatuiContext, RatatuiPlugins}; fn main() { let frame_time = std::time::Duration::from_secs_f32(1. / 60.); App::new() .add_plugins(( MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(frame_time)), RatatuiPlugins::default(), )) .add_systems(Update, draw_system) .run(); } fn draw_system(mut context: ResMut) -> Result { context.draw(|frame| { let text = ratatui::text::Text::raw("hello world"); frame.render_widget(text, frame.area()); })?; Ok(()) } ``` -------------------------------- ### VCS Info JSON Source: https://docs.rs/crate/bevy_ratatui/latest/source/.cargo_vcs_info.json This JSON object contains version control system information, including the Git SHA and path within the VCS. It is typically generated by tools like cargo-vcs-info. ```json { "git": { "sha1": "2208556a2995eab71e9825ce891f4fd9208646b8" }, "path_in_vcs": "" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.