diff options
Diffstat (limited to 'src/library/boxed.rs')
| -rw-r--r-- | src/library/boxed.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs index e8debca4..1cc4e020 100644 --- a/src/library/boxed.rs +++ b/src/library/boxed.rs @@ -4,18 +4,34 @@ use crate::func::prelude::*; #[derive(Debug, PartialEq)] pub struct Boxed { body: SyntaxTree, + width: Option<Size>, + height: Option<Size>, } function! { data: Boxed, parse(args, body, ctx) { + let width = args.get_key_opt::<ArgSize>("width")?.map(|a| a.val); + let height = args.get_key_opt::<ArgSize>("height")?.map(|a| a.val); args.done()?; + let body = parse!(required: body, ctx); - Ok(Boxed { body }) + Ok(Boxed { + body, + width, + height, + }) } - layout(this, ctx) { + layout(this, mut ctx) { + if let Some(width) = this.width { + ctx.spaces[0].dimensions.x = width; + } + if let Some(height) = this.height { + ctx.spaces[0].dimensions.y = height; + } + Ok(commands![AddMultiple(layout_tree(&this.body, ctx)?)]) } } |
