refactor: extract more tui_content modules

This commit is contained in:
🪞👃🪞 2025-04-04 20:59:17 +03:00
parent 86236b76cd
commit ea01deb854
6 changed files with 192 additions and 183 deletions

View file

@ -0,0 +1,29 @@
use crate::*;
/// A cell that takes up 3 rows on its own,
/// but stacks, giving (N+1)*2 rows per N cells.
pub struct Phat<T> {
pub width: u16,
pub height: u16,
pub content: T,
pub colors: [Color;4],
}
impl<T> Phat<T> {
/// A phat line
pub fn lo (fg: Color, bg: Color) -> impl Content<TuiOut> {
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(&"")))
}
/// A phat line
pub fn hi (fg: Color, bg: Color) -> impl Content<TuiOut> {
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(&"")))
}
}
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
fn content (&self) -> 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(self.width, self.height, Bsp::s(top, Bsp::n(low, Fill::xy(content))))
}
}