#[macro_export]
macro_rules! vstack {
(gap: $gap:expr; $($child:expr),* $(,)?) => {{
$crate::widget::vstack()
.gap($gap)
$(.child($child))*
}};
($($child:expr),* $(,)?) => {{
$crate::widget::vstack()
$(.child($child))*
}};
}
#[macro_export]
macro_rules! hstack {
(gap: $gap:expr; $($child:expr),* $(,)?) => {{
$crate::widget::hstack()
.gap($gap)
$(.child($child))*
}};
($($child:expr),* $(,)?) => {{
$crate::widget::hstack()
$(.child($child))*
}};
}
#[macro_export]
macro_rules! bordered {
($border_type:ident, $title:expr; $child:expr) => {{
$crate::widget::Border::$border_type()
.title($title)
.child($child)
}};
($title:expr; $child:expr) => {{
$crate::widget::Border::single().title($title).child($child)
}};
($child:expr) => {{
$crate::widget::Border::single().child($child)
}};
}
#[macro_export]
macro_rules! text {
($content:expr, $color:ident, bold) => {{
$crate::widget::Text::new($content)
.fg($crate::style::Color::$color)
.bold()
}};
($content:expr, $color:ident, italic) => {{
$crate::widget::Text::new($content)
.fg($crate::style::Color::$color)
.italic()
}};
($content:expr, red) => {{
$crate::widget::Text::error($content)
}};
($content:expr, green) => {{
$crate::widget::Text::success($content)
}};
($content:expr, yellow) => {{
$crate::widget::Text::warning($content)
}};
($content:expr, cyan) => {{
$crate::widget::Text::info($content)
}};
($content:expr, $color:ident) => {{
$crate::widget::Text::new($content).fg($crate::style::Color::$color)
}};
($content:expr) => {{
$crate::widget::Text::new($content)
}};
}
#[macro_export]
macro_rules! ui {
(vstack(gap: $gap:expr) { $($child:tt)* }) => {{
$crate::widget::vstack()
.gap($gap)
$(.child($crate::ui!(@child $child)))*
}};
(vstack { $($child:tt)* }) => {{
$crate::widget::vstack()
$(.child($crate::ui!(@child $child)))*
}};
(hstack(gap: $gap:expr) { $($child:tt)* }) => {{
$crate::widget::hstack()
.gap($gap)
$(.child($crate::ui!(@child $child)))*
}};
(hstack { $($child:tt)* }) => {{
$crate::widget::hstack()
$(.child($crate::ui!(@child $child)))*
}};
(@child vstack $($rest:tt)*) => {{
$crate::ui!(vstack $($rest)*)
}};
(@child hstack $($rest:tt)*) => {{
$crate::ui!(hstack $($rest)*)
}};
(@child $expr:expr) => {{
$expr
}};
}