use crate::*; #[derive(Default)] pub struct TuiOut { pub buffer: Buffer, pub area: [u16;4] } impl Output for TuiOut { type Unit = u16; type Size = [Self::Unit;2]; type Area = [Self::Unit;4]; #[inline] fn area (&self) -> [u16;4] { self.area } #[inline] fn area_mut (&mut self) -> &mut [u16;4] { &mut self.area } #[inline] fn place (&mut self, area: [u16;4], content: &impl Render) { let last = self.area(); *self.area_mut() = area; content.render(self); *self.area_mut() = last; } } impl TuiOut { pub fn buffer_update (&mut self, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) { buffer_update(&mut self.buffer, area, callback); } pub fn fill_bold (&mut self, area: [u16;4], on: bool) { if on { self.buffer_update(area, &|cell,_,_|cell.modifier.insert(Modifier::BOLD)) } else { self.buffer_update(area, &|cell,_,_|cell.modifier.remove(Modifier::BOLD)) } } pub fn fill_bg (&mut self, area: [u16;4], color: Color) { self.buffer_update(area, &|cell,_,_|{cell.set_bg(color);}) } pub fn fill_fg (&mut self, area: [u16;4], color: Color) { self.buffer_update(area, &|cell,_,_|{cell.set_fg(color);}) } pub fn fill_ul (&mut self, area: [u16;4], color: Color) { self.buffer_update(area, &|cell,_,_|{ cell.modifier = ratatui::prelude::Modifier::UNDERLINED; cell.underline_color = color; }) } pub fn fill_char (&mut self, area: [u16;4], c: char) { self.buffer_update(area, &|cell,_,_|{cell.set_char(c);}) } pub fn make_dim (&mut self) { for cell in self.buffer.content.iter_mut() { cell.bg = ratatui::style::Color::Rgb(30,30,30); cell.fg = ratatui::style::Color::Rgb(100,100,100); cell.modifier = ratatui::style::Modifier::DIM; } } pub fn blit ( &mut self, text: &impl AsRef, x: u16, y: u16, style: Option