refactor: separate Render from Handle

This commit is contained in:
🪞👃🪞 2024-06-22 10:15:14 +03:00
parent d9b3bd150e
commit 72ead536be
12 changed files with 255 additions and 212 deletions

View file

@ -26,12 +26,15 @@ pub fn handle_focus <T: Focus> (
pub struct FocusColumn(pub Option<usize>, pub Column);
impl Device for FocusColumn {
impl Handle for FocusColumn {
fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
handle_focus(self, event, KEYMAP_FOCUS_COLUMN)
}
}
impl Render for FocusColumn {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let (rect, rects) = draw_column(self.1.0.as_ref(), buf, area, 0)?;
let (rect, rects) = Column::draw(buf, area, self.1.0.as_ref(), 0)?;
//if i == self.focus {
//if self.focused {
//draw_box_styled(buf, result, Some(Style::default().white().not_dim()))
@ -108,12 +111,15 @@ impl Focus for FocusColumn {
pub struct FocusRow(pub Option<usize>, pub Row);
impl Device for FocusRow {
impl Handle for FocusRow {
fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
handle_focus(self, event, KEYMAP_FOCUS_ROW)
}
}
impl Render for FocusRow {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let (rect, rects) = draw_row(&self.1.0, buf, area, 0)?;
let (rect, rects) = Row::draw(buf, area, &self.1.0, 0)?;
Ok(rect)
}
}