diff --git a/crates/tek_core/src/tui.rs b/crates/tek_core/src/tui.rs index 3fd8b8c1..524a5da5 100644 --- a/crates/tek_core/src/tui.rs +++ b/crates/tek_core/src/tui.rs @@ -453,12 +453,11 @@ where Ok(Some([w, h])) } fn render (&self, to: &mut TuiOutput) -> Usually<()> { - self.layout(to.area().wh())? - .map(|size|(self.0)(&mut |layer|{ - to.render_in(to.area().clip(size), &layer).map(|_|()) - }) - .map(|_|to.area())) - .transpose() + if let Some(size) = self.layout(to.area().wh())? { + (self.0)(&mut |layer|to.render_in(to.area().clip(size), &layer)) + } else { + Ok(()) + } } } @@ -472,20 +471,20 @@ impl Widget for Border { fn render (&self, to: &mut TuiOutput) -> Usually<()> { let area = to.area(); if area.w() > 2 && area.y() > 2 { - to.blit(&self.0.nw(), area.x(), area.y(), self.0.style())?; - to.blit(&self.0.ne(), area.x() + area.w() - 1, area.y(), self.0.style())?; - to.blit(&self.0.sw(), area.x(), area.y() + area.h() - 1, self.0.style())?; - to.blit(&self.0.se(), area.x() + area.w() - 1, area.y() + area.h() - 1, self.0.style())?; + to.blit(&self.0.nw(), area.x(), area.y(), self.0.style()); + to.blit(&self.0.ne(), area.x() + area.w() - 1, area.y(), self.0.style()); + to.blit(&self.0.sw(), area.x(), area.y() + area.h() - 1, self.0.style()); + to.blit(&self.0.se(), area.x() + area.w() - 1, area.y() + area.h() - 1, self.0.style()); for x in area.x()+1..area.x()+area.w()-1 { - to.blit(&self.0.n(), x, area.y(), self.0.style())?; - to.blit(&self.0.s(), x, area.y() + area.h() - 1, self.0.style())?; + to.blit(&self.0.n(), x, area.y(), self.0.style()); + to.blit(&self.0.s(), x, area.y() + area.h() - 1, self.0.style()); } for y in area.y()+1..area.y()+area.h()-1 { - to.blit(&self.0.w(), area.x(), y, self.0.style())?; - to.blit(&self.0.e(), area.x() + area.w() - 1, y, self.0.style())?; + to.blit(&self.0.w(), area.x(), y, self.0.style()); + to.blit(&self.0.e(), area.x() + area.w() - 1, y, self.0.style()); } } - Ok(Some(area)) + Ok(()) } } @@ -529,7 +528,7 @@ pub trait BorderStyle: Send + Sync { self.draw_horizontal(to, None)?; self.draw_vertical(to, None)?; self.draw_corners(to, None)?; - Ok(Some(to.area)) + Ok(()) } #[inline] @@ -538,17 +537,17 @@ pub trait BorderStyle: Send + Sync { let style = style.or_else(||self.style_horizontal()); let [x, x2, y, y2] = area.lrtb(); for x in x..x2.saturating_sub(1) { - self.draw_north(to, x, y, style)?; - self.draw_south(to, x, y2.saturating_sub(1), style)?; + self.draw_north(to, x, y, style); + self.draw_south(to, x, y2.saturating_sub(1), style); } Ok(area) } #[inline] - fn draw_north (&self, to: &mut TuiOutput, x: u16, y: u16, style: Option