use crate::*; pub trait TuiDraw = Draw; pub trait TuiLayout = Layout; pub trait TuiContent = Content; pub trait TuiHandle = Handle; pub trait TuiWidget = TuiDraw + TuiHandle; pub trait HasColor { fn color (&self) -> ItemColor; } pub trait BorderStyle: Content + Copy { fn enabled (&self) -> bool; fn enclose (self, w: impl Content) -> impl Content { Bsp::b(Fill::XY(Border(self.enabled(), self)), w) } fn enclose2 (self, w: impl Content) -> impl Content { Bsp::b(Pad::XY(1, 1, Fill::XY(Border(self.enabled(), self))), w) } fn enclose_bg (self, w: impl Content) -> impl Content { Tui::bg(self.style().unwrap().bg.unwrap_or(Color::Reset), Bsp::b(Fill::XY(Border(self.enabled(), self)), w)) } const NW: &'static str = ""; const N: &'static str = ""; const NE: &'static str = ""; const E: &'static str = ""; const SE: &'static str = ""; const S: &'static str = ""; const SW: &'static str = ""; const W: &'static str = ""; const N0: &'static str = ""; const S0: &'static str = ""; const W0: &'static str = ""; const E0: &'static str = ""; fn border_n (&self) -> &str { Self::N } fn border_s (&self) -> &str { Self::S } fn border_e (&self) -> &str { Self::E } fn border_w (&self) -> &str { Self::W } fn border_nw (&self) -> &str { Self::NW } fn border_ne (&self) -> &str { Self::NE } fn border_sw (&self) -> &str { Self::SW } fn border_se (&self) -> &str { Self::SE } #[inline] fn draw <'a> ( &self, to: &mut TuiOut ) -> Usually<()> { if self.enabled() { self.draw_horizontal(to, None)?; self.draw_vertical(to, None)?; self.draw_corners(to, None)?; } Ok(()) } #[inline] fn draw_horizontal ( &self, to: &mut TuiOut, style: Option