blizz-ui 3.0.0-dev.2

Self-rendering terminal UI components for the blizz wizard
Documentation
#![allow(unexpected_cfgs)]

use std::io;
use std::io::Write;
use std::time::Duration;

use rand::rngs::ThreadRng;

pub mod components;
pub mod decode;
pub mod input_buffer;
pub mod layout;
pub mod style;

pub use layout::Size;

/// Terminal dimensions and timing context shared across all components.
pub struct RenderContext {
  pub terminal_size: Size,
  pub elapsed: Duration,
}

/// A self-rendering UI element.
///
/// Each component owns its visual state (positions, reveal progress, etc.)
/// and knows how to draw itself into a terminal writer. The wizard loop
/// acts as a thin compositor, calling `render` on each component in
/// z-order.
pub trait Component {
  fn render<W: Write>(
    &self,
    writer: &mut W,
    ctx: &RenderContext,
    rng: &mut ThreadRng,
  ) -> io::Result<()>;
}