summaryrefslogtreecommitdiff
path: root/src/library/boxed.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-11-22 20:15:00 +0100
committerLaurenz <laurmaedje@gmail.com>2019-11-22 20:15:00 +0100
commit6ff60bc3688d8ae2caa3ea18bc23963d25ab5daa (patch)
tree51f4abdee9bfdda98f8d865d45a30c94556d004b /src/library/boxed.rs
parent4ab7ec6a9a1159bdf1e22eccb56d6d827aaf5b23 (diff)
Fix secondary non-origin alignment 🚧
Diffstat (limited to 'src/library/boxed.rs')
-rw-r--r--src/library/boxed.rs20
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)?)])
}
}