summaryrefslogtreecommitdiff
path: root/src/library/boxed.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-01-24 12:44:04 +0100
committerLaurenz <laurmaedje@gmail.com>2020-01-24 12:44:04 +0100
commit03fddaf3aea778057aedd74dbcb27bae971ec22f (patch)
tree37e3136e29e0e5d69ec8f56e43d156739d2931ab /src/library/boxed.rs
parent78da2bdd5d77d1b8572e5e9da119bfa68127a3fa (diff)
Non-fatal argument parsing 🌋
Diffstat (limited to 'src/library/boxed.rs')
-rw-r--r--src/library/boxed.rs57
1 files changed, 0 insertions, 57 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs
deleted file mode 100644
index af236da4..00000000
--- a/src/library/boxed.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-use smallvec::smallvec;
-
-use crate::func::prelude::*;
-use super::maps::ExtentMap;
-
-
-function! {
- /// `box`: Layouts content into a box.
- #[derive(Debug, PartialEq)]
- pub struct BoxFunc {
- body: SyntaxTree,
- map: ExtentMap<PSize>,
- debug: Option<bool>,
- }
-
- parse(header, body, ctx) {
- BoxFunc {
- body: parse!(optional: body, ctx).unwrap_or(SyntaxTree::new()),
- map: ExtentMap::new(&mut header.args, false)?,
- debug: header.args.get_key_opt::<bool>("debug")?,
- }
- }
-
- layout(self, mut ctx) {
- ctx.repeat = false;
-
- if let Some(debug) = self.debug {
- ctx.debug = debug;
- }
-
- let map = self.map.dedup(ctx.axes)?;
-
- // Try to layout this box in all spaces until it fits into some space.
- let mut error = None;
- for &(mut space) in &ctx.spaces {
- let mut ctx = ctx.clone();
-
- for &axis in &[Horizontal, Vertical] {
- if let Some(psize) = map.get(axis) {
- let size = psize.scaled(ctx.base.get(axis));
- *ctx.base.get_mut(axis) = size;
- *space.dimensions.get_mut(axis) = size;
- *space.expansion.get_mut(axis) = true;
- }
- }
-
- ctx.spaces = smallvec![space];
-
- match layout(&self.body, ctx).await {
- Ok(layouts) => return Ok(vec![AddMultiple(layouts)]),
- Err(err) => error = Some(err),
- }
- }
-
- return Err(error.expect("expected at least one space"));
- }
-}