summaryrefslogtreecommitdiff
path: root/src/exec/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-29 13:21:25 +0200
committerLaurenz <laurmaedje@gmail.com>2021-07-29 13:28:19 +0200
commit2c6127dea611944abb09a0d38375ad7cf9baced0 (patch)
tree6572d169d4ce26edc38a880860ebae2f49639fb8 /src/exec/mod.rs
parent7d15dc634b3be1b6e284bb6b2450e3736d3e6e8d (diff)
Refactor state
Diffstat (limited to 'src/exec/mod.rs')
-rw-r--r--src/exec/mod.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/exec/mod.rs b/src/exec/mod.rs
index ff4faa22..8bac76e8 100644
--- a/src/exec/mod.rs
+++ b/src/exec/mod.rs
@@ -9,12 +9,12 @@ pub use state::*;
use std::fmt::Write;
use crate::diag::Pass;
-use crate::util::EcoString;
use crate::eval::{ExprMap, Template, TemplateFunc, TemplateNode, TemplateTree, Value};
-use crate::geom::{Dir, Gen};
+use crate::geom::Gen;
use crate::layout::{LayoutTree, StackChild, StackNode};
use crate::pretty::pretty;
use crate::syntax::*;
+use crate::util::EcoString;
use crate::Context;
/// Execute a template to produce a layout tree.
@@ -57,8 +57,8 @@ impl ExecWithMap for SyntaxNode {
Self::Space => ctx.push_word_space(),
Self::Linebreak(_) => ctx.linebreak(),
Self::Parbreak(_) => ctx.parbreak(),
- Self::Strong(_) => ctx.state.text_mut().strong ^= true,
- Self::Emph(_) => ctx.state.text_mut().emph ^= true,
+ Self::Strong(_) => ctx.state.font_mut().strong ^= true,
+ Self::Emph(_) => ctx.state.font_mut().emph ^= true,
Self::Raw(n) => n.exec(ctx),
Self::Heading(n) => n.exec_with_map(ctx, map),
Self::List(n) => n.exec_with_map(ctx, map),
@@ -87,10 +87,10 @@ impl ExecWithMap for HeadingNode {
ctx.parbreak();
let snapshot = ctx.state.clone();
- let text = ctx.state.text_mut();
+ let font = ctx.state.font_mut();
let upscale = 1.6 - 0.1 * self.level as f64;
- text.size *= upscale;
- text.strong = true;
+ font.size *= upscale;
+ font.strong = true;
self.body.exec_with_map(ctx, map);
ctx.state = snapshot;
@@ -118,11 +118,11 @@ fn exec_item(ctx: &mut ExecContext, label: EcoString, body: &SyntaxTree, map: &E
let label = ctx.exec_stack(|ctx| ctx.push_text(label));
let body = ctx.exec_tree_stack(body, map);
let stack = StackNode {
- dirs: Gen::new(Dir::TTB, ctx.state.dir),
+ dirs: Gen::new(ctx.state.dirs.main, ctx.state.dirs.cross),
aspect: None,
children: vec![
StackChild::Any(label.into(), Gen::default()),
- StackChild::Spacing(ctx.state.text.size / 2.0),
+ StackChild::Spacing(ctx.state.font.size / 2.0),
StackChild::Any(body.into(), Gen::default()),
],
};