too/renderer/
mod.rs

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
mod buffer;
use buffer::Buffer;

mod surface;
pub use surface::{Surface, SurfaceMut};

mod shape;
pub use shape::Shape;

mod pixel;
pub use pixel::{Attribute, Pixel, PixelColor};

mod rgba;
pub use rgba::Rgba;

mod gradient;
pub use gradient::Gradient;

pub mod shapes;

use crate::math;

/// Abstraction for rendering to a surface.
pub trait Renderer {
    fn begin(&mut self) -> std::io::Result<()>;
    fn end(&mut self) -> std::io::Result<()>;
    fn move_to(&mut self, pos: math::Pos2) -> std::io::Result<()>;
    fn write(&mut self, ch: char) -> std::io::Result<()>;
    fn set_fg(&mut self, rgb: Rgba) -> std::io::Result<()>;
    fn set_bg(&mut self, rgb: Rgba) -> std::io::Result<()>;
    fn set_attr(&mut self, attr: Attribute) -> std::io::Result<()>;
    fn reset_fg(&mut self) -> std::io::Result<()>;
    fn reset_bg(&mut self) -> std::io::Result<()>;
    fn reset_attr(&mut self) -> std::io::Result<()>;
    fn clear_screen(&mut self) -> std::io::Result<()>;

    fn set_title(&mut self, title: &str) -> std::io::Result<()> {
        _ = title;
        Ok(())
    }

    fn switch_to_alt_screen(&mut self) -> std::io::Result<()> {
        Ok(())
    }

    fn switch_to_main_screen(&mut self) -> std::io::Result<()> {
        Ok(())
    }
}

mod term_renderer;
pub use term_renderer::TermRenderer;

mod debug_renderer;
pub use debug_renderer::DebugRenderer;

// TODO TestRenderer