Files
k-frame/crates/adapters/display-terminal/src/lib.rs

43 lines
991 B
Rust

use client_domain::{BoundingBox, Color, DisplayPort, FontSize};
#[derive(Default)]
pub struct TerminalDisplay;
impl TerminalDisplay {
pub fn new() -> Self {
Self
}
}
impl DisplayPort for TerminalDisplay {
type Error = std::io::Error;
fn draw_text_span(
&mut self,
text: &str,
x: u16,
y: u16,
color: Color,
font: FontSize,
) -> Result<(), Self::Error> {
println!(
"[TEXT] ({x}, {y}) {:?} #{:02X}{:02X}{:02X}: \"{text}\"",
font, color.0, color.1, color.2
);
Ok(())
}
fn fill_rect(&mut self, bounds: BoundingBox, color: Color) -> Result<(), Self::Error> {
println!(
"[FILL] ({}, {}) {}x{} #{:02X}{:02X}{:02X}",
bounds.x, bounds.y, bounds.width, bounds.height, color.0, color.1, color.2
);
Ok(())
}
fn flush(&mut self) -> Result<(), Self::Error> {
println!("[FLUSH]");
Ok(())
}
}