summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-12-30 22:28:56 +0100
committerLaurenz <laurmaedje@gmail.com>2019-12-30 22:28:56 +0100
commit269f069a4d721a986807293ef71be1348bfae3d4 (patch)
tree31b737c4ff2aead3eb5e2673828595bb26622032 /src/library
parentb8620121a692df6313eeb5ccf7baf89c1e364116 (diff)
Simple line layouter 🧾
Diffstat (limited to 'src/library')
-rw-r--r--src/library/boxed.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs
index ece8b20f..7333c50f 100644
--- a/src/library/boxed.rs
+++ b/src/library/boxed.rs
@@ -9,28 +9,30 @@ function! {
pub struct Boxed {
body: SyntaxTree,
map: ExtentMap<PSize>,
- debug: bool,
+ debug: Option<bool>,
}
parse(args, body, ctx) {
Boxed {
body: parse!(optional: body, ctx).unwrap_or(SyntaxTree::new()),
map: ExtentMap::new(&mut args, false)?,
- debug: args.get_key_opt::<bool>("debug")?.unwrap_or(true),
+ debug: args.get_key_opt::<bool>("debug")?,
}
}
layout(self, mut ctx) {
ctx.repeat = false;
- ctx.debug = self.debug;
+
+ if let Some(debug) = self.debug {
+ ctx.debug = debug;
+ }
let map = self.map.dedup(ctx.axes)?;
- // Try to layout this box in all spaces.
+ // Try to layout this box in all spaces until it fits into some space.
let mut error = None;
- for &space in &ctx.spaces {
+ for &(mut space) in &ctx.spaces {
let mut ctx = ctx.clone();
- let mut space = space;
for &axis in &[Horizontal, Vertical] {
if let Some(psize) = map.get(axis) {