mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
parameterize render! macro
This commit is contained in:
parent
914b569839
commit
3e4d75ea40
17 changed files with 176 additions and 65 deletions
|
|
@ -27,19 +27,6 @@ mod port_select; pub(crate) use port_select::*;
|
|||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#[macro_export] macro_rules! render {
|
||||
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? Render<Tui> for $Struct $(<$($L),*$($T),*>)? {
|
||||
fn min_size (&$self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
$cb.min_size(to)
|
||||
}
|
||||
fn render (&$self, to: &mut TuiOutput) -> Usually<()> {
|
||||
$cb.render(to)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render <F: Fn(&mut TuiOutput)->Usually<()>+Send+Sync> (render: F) -> impl Render<Tui> {
|
||||
Widget::new(|_|Ok(Some([0u16,0u16].into())), render)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue