add iteration versions of row and col macros

This commit is contained in:
🪞👃🪞 2024-09-30 00:15:39 +03:00
parent ad39376659
commit fd2e8f83f6
3 changed files with 57 additions and 50 deletions

View file

@ -833,10 +833,22 @@ where
($($expr:expr),* $(,)?) => { Layers::new(move|add|{ $(add(&$expr)?;)* Ok(()) }) }
}
#[macro_export] macro_rules! col {
($($expr:expr),* $(,)?) => { Stack::down(move|add|{ $(add(&$expr)?;)* Ok(()) }) }
($($expr:expr),* $(,)?) => { Stack::down(move|add|{ $(add(&$expr)?;)* Ok(()) }) };
($pat:pat in $collection:expr => $item:expr) => {
Stack::down(move |add|{
for $pat in $collection { add(&$item)?; }
Ok(())
})
}
}
#[macro_export] macro_rules! row {
($($expr:expr),* $(,)?) => { Stack::right(move|add|{ $(add(&$expr)?;)* Ok(()) }) }
($($expr:expr),* $(,)?) => { Stack::right(move|add|{ $(add(&$expr)?;)* Ok(()) }) };
($pat:pat in $collection:expr => $item:expr) => {
Stack::right(move |add|{
for $pat in $collection { add(&$item)?; }
Ok(())
})
}
}
/// A binary split with fixed proportion

View file

@ -466,8 +466,9 @@ impl<S: BorderStyle, W: Widget<Engine = Tui>> Content for Bordered<S, W> {
fn content (&self) -> impl Widget<Engine = Tui> {
let style = self.0;
Layers::new(move|add|{
add(&Inset::XY(1, 1, &self.1 as &dyn Widget<Engine = Tui>))?;
add(&Border(style))?;
add(&Inset::XY(1, 1, &self.1 as &dyn Widget<Engine = Tui>))
Ok(())
}).fill_xy()
}
}