use crate::func::prelude::*; /// `box`: Layouts content into a box. #[derive(Debug, PartialEq)] pub struct Boxed { body: SyntaxTree, width: Option, height: Option, } function! { data: Boxed, parse(args, body, ctx) { let width = args.get_key_opt::("width")?.map(|a| a.val); let height = args.get_key_opt::("height")?.map(|a| a.val); args.done()?; let body = parse!(required: body, ctx); Ok(Boxed { body, width, height, }) } 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)?)]) } }