1pub mod buffer;
5pub mod context;
6pub mod primitives;
7pub mod style;
8
9pub mod prelude {
10 pub use anyhow::Result;
11 pub use crate::{
12 buffer::{Buffer, Cell},
13 primitives::Rect,
14 style::{Color, ColorMode, Modifier, Style},
15 context::{Context, Input, Scancode},
16 Frame,
17 Platform,
18 Program,
19 run_program,
20 };
21}
22
23use prelude::*;
24
25
26
27pub fn run_program(program: impl Program, platform: impl Platform) -> Result<()> {
28 platform.run(program)?;
29 Ok(())
30}
31
32
33
34pub trait Program {
35 fn update(&mut self, frame: Frame);
36 fn should_exit(&self) -> bool;
37}
38
39pub trait Platform {
40 fn run(self, program: impl Program) -> Result<()>;
41}
42
43pub struct Frame<'a> {
44 pub context: &'a mut Context,
45 pub area: Rect,
46 pub buffer: &'a mut Buffer,
47}