summaryrefslogtreecommitdiff
path: root/src/library/boxed.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-10-23 00:14:43 +0200
committerLaurenz <laurmaedje@gmail.com>2019-10-23 00:21:40 +0200
commitecf0ff4d054f11c79ec0ddbbdf45f3dfcf9fc8d7 (patch)
treeefdc76915e5c7f43629aa3aa5d5aa3998d7f5367 /src/library/boxed.rs
parentcff325b520727ac0eec46a3757831afaa0916cc1 (diff)
Introduce a set of macros for writing functions more concisely 🎁
Diffstat (limited to 'src/library/boxed.rs')
-rw-r--r--src/library/boxed.rs51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs
deleted file mode 100644
index 71a184a6..00000000
--- a/src/library/boxed.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-use super::prelude::*;
-use crate::layout::Flow;
-
-/// Wraps content into a box.
-#[derive(Debug, PartialEq)]
-pub struct BoxFunc {
- body: SyntaxTree,
- flow: Flow,
-}
-
-impl Function for BoxFunc {
- fn parse(header: &FuncHeader, body: Option<&str>, ctx: ParseContext) -> ParseResult<Self>
- where Self: Sized {
- let flow = if header.args.is_empty() {
- Flow::Vertical
- } else if header.args.len() == 1 {
- if let Expression::Ident(ident) = &header.args[0] {
- match ident.as_str() {
- "vertical" => Flow::Vertical,
- "horizontal" => Flow::Horizontal,
- f => return err(format!("invalid flow specifier: '{}'", f)),
- }
- } else {
- return err(format!(
- "expected alignment specifier, found: '{}'",
- header.args[0]
- ));
- }
- } else {
- return err("box: expected flow specifier or no arguments");
- };
-
- if let Some(body) = body {
- Ok(BoxFunc {
- body: parse(body, ctx)?,
- flow,
- })
- } else {
- err("box: expected body")
- }
- }
-
- fn layout(&self, ctx: LayoutContext) -> LayoutResult<CommandList> {
- let layout = layout_tree(&self.body, LayoutContext {
- flow: self.flow,
- .. ctx
- })?;
-
- Ok(commands![Command::AddMany(layout)])
- }
-}