diff options
Diffstat (limited to 'src/library/boxed.rs')
| -rw-r--r-- | src/library/boxed.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs index a2df45e3..ef5ae24e 100644 --- a/src/library/boxed.rs +++ b/src/library/boxed.rs @@ -1,18 +1,19 @@ use crate::func::prelude::*; +use super::keys::*; function! { /// `box`: Layouts content into a box. #[derive(Debug, PartialEq)] pub struct Boxed { body: SyntaxTree, - map: ArgMap<AxisKey, Size>, + map: ConsistentMap<AxisKey, Size>, } parse(args, body, ctx) { - let mut map = ArgMap::new(); + let mut map = ConsistentMap::new(); for arg in args.keys() { - let key = match arg.val.0.val { + let key = match arg.v.key.v.0.as_str() { "width" | "w" => AxisKey::Horizontal, "height" | "h" => AxisKey::Vertical, "primary-size" => AxisKey::Primary, @@ -20,8 +21,8 @@ function! { _ => error!(unexpected_argument), }; - let size = ArgParser::convert::<ArgSize>(arg.val.1.val)?; - map.add(key, size); + let size = Size::from_expr(arg.v.value)?; + map.add(key, size)?; } Boxed { @@ -31,13 +32,11 @@ function! { } layout(self, mut ctx) { - let map = self.map.dedup(|key, val| { - Ok((key.specific(ctx.axes), val)) - }); + let map = self.map.dedup(|key, val| Ok((key.specific(ctx.axes), val)))?; - let mut dimensions = &mut ctx.spaces[0].dimensions; - map.with(AxisKey::Horizontal, |val| dimensions.x = val); - map.with(AxisKey::Vertical, |val| dimensions.y = val); + let dimensions = &mut ctx.spaces[0].dimensions; + map.with(SpecificAxisKind::Horizontal, |&val| dimensions.x = val); + map.with(SpecificAxisKind::Vertical, |&val| dimensions.y = val); vec![AddMultiple(layout_tree(&self.body, ctx)?)] } |
