blizz_ui/lib.rs
1use std::io;
2use std::io::Write;
3use std::time::Duration;
4
5use rand::rngs::ThreadRng;
6
7pub mod components;
8
9/// Terminal dimensions and timing context shared across all components.
10pub struct RenderContext {
11 pub terminal_size: Size,
12 pub elapsed: Duration,
13}
14
15/// A self-rendering UI element.
16///
17/// Each component owns its visual state (positions, reveal progress, etc.)
18/// and knows how to draw itself into a terminal writer. The wizard loop
19/// acts as a thin compositor, calling `render` on each component in
20/// z-order.
21pub trait Component {
22 fn render<W: Write>(
23 &self,
24 writer: &mut W,
25 ctx: &RenderContext,
26 rng: &mut ThreadRng,
27 ) -> io::Result<()>;
28}
29
30// Re-exported once utility modules land here in BLIZZ-10.
31// For now, pull Size from a local stub so the crate compiles.
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq)]
34pub struct Size {
35 pub width: u16,
36 pub height: u16,
37}