output: refactor Content and Render traits

This commit is contained in:
🪞👃🪞 2025-09-06 08:46:52 +03:00
parent 74b3af2212
commit 1c21a85f27
24 changed files with 346 additions and 613 deletions

View file

@ -12,24 +12,24 @@ impl<T> Phat<T> {
pub const LO: &'static str = "";
pub const HI: &'static str = "";
/// A phat line
pub fn lo (fg: Color, bg: Color) -> impl Content<TuiOut> {
pub fn lo (fg: Color, bg: Color) -> impl Render<TuiOut> {
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(Self::LO)))
}
/// A phat line
pub fn hi (fg: Color, bg: Color) -> impl Content<TuiOut> {
pub fn hi (fg: Color, bg: Color) -> impl Render<TuiOut> {
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(Self::HI)))
}
}
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
fn content (&self) -> impl Render<TuiOut> {
impl<T: Render<TuiOut>> Content<TuiOut> for Phat<T> {
fn content (&self) -> Option<impl Render<TuiOut> + '_> {
let [fg, bg, hi, lo] = self.colors;
let top = Fixed::y(1, Self::lo(bg, hi));
let low = Fixed::y(1, Self::hi(bg, lo));
let content = Tui::fg_bg(fg, bg, &self.content);
Min::xy(
Some(Min::xy(
self.width,
self.height,
Bsp::s(top, Bsp::n(low, Fill::xy(content)))
)
))
}
}