From 083ce8ba76bfe4bad3d2b63a6a664db1c2b091d7 Mon Sep 17 00:00:00 2001 From: facile pop culture reference Date: Mon, 3 Aug 2026 11:51:58 +0300 Subject: [PATCH] remove Screen::show --- src/layout/align.rs | 3 +++ src/layout/full.rs | 1 + src/lib.rs | 50 ++++++++++++++++++--------------------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/layout/align.rs b/src/layout/align.rs index b94788e..f7779fd 100644 --- a/src/layout/align.rs +++ b/src/layout/align.rs @@ -40,3 +40,6 @@ fn align ( } }) } + +#[cfg(test)] #[test] fn test_align () { +} diff --git a/src/layout/full.rs b/src/layout/full.rs index 7da3c3f..5c2a717 100644 --- a/src/layout/full.rs +++ b/src/layout/full.rs @@ -18,6 +18,7 @@ pub enum Full> { H(I), WH(I), } + impl_draw!(,>|self: Full, to: T|{ let XYWH(x0, y0, w0, h0) = to.area(); match self { diff --git a/src/lib.rs b/src/lib.rs index 6d92fe2..c706bc5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1359,10 +1359,6 @@ macro_rules! eval_xy ( /// } /// impl Screen for TestOut { /// type Unit = u16; - /// fn show (&mut self, _: impl Draw) -> Perhaps> { - /// println!("placed"); - /// Ok(None) - /// } /// fn area (&self) -> XYWH { /// Default::default() /// } @@ -1382,8 +1378,6 @@ macro_rules! eval_xy ( /// ``` pub trait Screen: Xy + Wh + Send + Sync + Sized { type Unit: Coord; - /// Render drawable in subarea specified by `area` - fn show (&mut self, content: impl Draw) -> Perhaps>; /// Get current clipping area fn area (&self) -> XYWH; /// Set clipping area @@ -2612,37 +2606,15 @@ macro_rules! eval_xy ( /// Get mutable reference to current clipping area fn area_mut (&mut self) -> &mut XYWH { - match self { - Self::Draw(_, area) => area, - Self::Layout(area) => area, - } + self.into() } } impl Screen for Tui { type Unit = u16; - /// Render drawable in subarea specified by `area` - fn show (&mut self, content: impl Draw) -> Perhaps> { - let previous_area = self.area(); - Ok(if let Some(area) = content.layout(self.area())? { - *self.area_mut() = area; - if let Some(result_area) = content.draw(self)? { - *self.area_mut() = previous_area; - Some(result_area) - } else { - None - } - } else { - None - }) - } - /// Get current clipping area fn area (&self) -> XYWH { - match self { - Self::Draw(_, area) => *area, - Self::Layout(area) => *area, - } + self.into() } fn clip ( @@ -2660,6 +2632,24 @@ macro_rules! eval_xy ( } } + impl From<&Tui> for XYWH { + fn from (screen: &Tui) -> XYWH { + match screen { + Tui::Draw(_, area) => *area, + Tui::Layout(area) => *area, + } + } + } + + impl<'a: 'b, 'b> From<&'a mut Tui> for &'b mut XYWH { + fn from (screen: &'a mut Tui) -> &'b mut XYWH { + match screen { + Tui::Draw(_, area) => area, + Tui::Layout(area) => area, + } + } + } + pub const fn fill_char (c: char) -> impl Draw { draw(move|to: &mut Tui|Ok(Some(to.update(&|cell,_,_|{ cell.set_char(c);