summaryrefslogtreecommitdiff
path: root/src/library/structure
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/structure')
-rw-r--r--src/library/structure/doc.rs4
-rw-r--r--src/library/structure/heading.rs12
-rw-r--r--src/library/structure/list.rs12
-rw-r--r--src/library/structure/reference.rs4
-rw-r--r--src/library/structure/table.rs12
5 files changed, 22 insertions, 22 deletions
diff --git a/src/library/structure/doc.rs b/src/library/structure/doc.rs
index 80472e24..cabdb4dc 100644
--- a/src/library/structure/doc.rs
+++ b/src/library/structure/doc.rs
@@ -7,11 +7,11 @@ pub struct DocNode(pub StyleVec<PageNode>);
impl DocNode {
/// Layout the document into a sequence of frames, one per page.
- pub fn layout(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Vec<Frame>> {
+ pub fn layout(&self, world: &dyn World, styles: StyleChain) -> TypResult<Vec<Frame>> {
let mut frames = vec![];
for (page, map) in self.0.iter() {
let number = 1 + frames.len();
- frames.extend(page.layout(ctx, number, map.chain(&styles))?);
+ frames.extend(page.layout(world, number, map.chain(&styles))?);
}
Ok(frames)
}
diff --git a/src/library/structure/heading.rs b/src/library/structure/heading.rs
index 24054f81..c177481f 100644
--- a/src/library/structure/heading.rs
+++ b/src/library/structure/heading.rs
@@ -60,7 +60,7 @@ impl HeadingNode {
/// Whether the heading is numbered.
pub const NUMBERED: bool = true;
- fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
+ fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self {
body: args.expect("body")?,
level: args.named("level")?.unwrap_or(NonZeroUsize::new(1).unwrap()),
@@ -82,19 +82,19 @@ impl Show for HeadingNode {
}
}
- fn realize(&self, _: &mut Context, _: StyleChain) -> TypResult<Content> {
+ fn realize(&self, _: &dyn World, _: StyleChain) -> TypResult<Content> {
Ok(Content::block(self.body.clone()))
}
fn finalize(
&self,
- ctx: &mut Context,
+ world: &dyn World,
styles: StyleChain,
mut realized: Content,
) -> TypResult<Content> {
macro_rules! resolve {
($key:expr) => {
- styles.get($key).resolve(ctx, self.level)?
+ styles.get($key).resolve(world, self.level)?
};
}
@@ -149,13 +149,13 @@ pub enum Leveled<T> {
impl<T: Cast + Clone> Leveled<T> {
/// Resolve the value based on the level.
- pub fn resolve(&self, ctx: &mut Context, level: NonZeroUsize) -> TypResult<T> {
+ pub fn resolve(&self, world: &dyn World, level: NonZeroUsize) -> TypResult<T> {
Ok(match self {
Self::Value(value) => value.clone(),
Self::Mapping(mapping) => mapping(level),
Self::Func(func, span) => {
let args = Args::new(*span, [Value::Int(level.get() as i64)]);
- func.call_detached(ctx, args)?.cast().at(*span)?
+ func.call_detached(world, args)?.cast().at(*span)?
}
})
}
diff --git a/src/library/structure/list.rs b/src/library/structure/list.rs
index c4167cf9..e9365cd6 100644
--- a/src/library/structure/list.rs
+++ b/src/library/structure/list.rs
@@ -56,7 +56,7 @@ impl<const L: ListKind> ListNode<L> {
#[property(resolve)]
pub const SPACING: BlockSpacing = Ratio::one().into();
- fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
+ fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self {
start: args.named("start")?.unwrap_or(1),
tight: args.named("tight")?.unwrap_or(true),
@@ -100,7 +100,7 @@ impl<const L: ListKind> Show for ListNode<L> {
}
}
- fn realize(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
+ fn realize(&self, world: &dyn World, styles: StyleChain) -> TypResult<Content> {
let mut cells = vec![];
let mut number = self.start;
@@ -112,7 +112,7 @@ impl<const L: ListKind> Show for ListNode<L> {
cells.push(LayoutNode::default());
cells.push(
label
- .resolve(ctx, L, number)?
+ .resolve(world, L, number)?
.styled_with_map(map.clone())
.role(Role::ListLabel)
.pack(),
@@ -145,7 +145,7 @@ impl<const L: ListKind> Show for ListNode<L> {
fn finalize(
&self,
- _: &mut Context,
+ _: &dyn World,
styles: StyleChain,
realized: Content,
) -> TypResult<Content> {
@@ -208,7 +208,7 @@ impl Label {
/// Resolve the value based on the level.
pub fn resolve(
&self,
- ctx: &mut Context,
+ world: &dyn World,
kind: ListKind,
number: usize,
) -> TypResult<Content> {
@@ -225,7 +225,7 @@ impl Label {
Self::Content(content) => content.clone(),
Self::Func(func, span) => {
let args = Args::new(*span, [Value::Int(number as i64)]);
- func.call_detached(ctx, args)?.display()
+ func.call_detached(world, args)?.display()
}
})
}
diff --git a/src/library/structure/reference.rs b/src/library/structure/reference.rs
index 0eeb4bf5..22dbec01 100644
--- a/src/library/structure/reference.rs
+++ b/src/library/structure/reference.rs
@@ -6,7 +6,7 @@ pub struct RefNode(pub EcoString);
#[node(showable)]
impl RefNode {
- fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
+ fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> {
Ok(Content::show(Self(args.expect("label")?)))
}
}
@@ -22,7 +22,7 @@ impl Show for RefNode {
}
}
- fn realize(&self, _: &mut Context, _: StyleChain) -> TypResult<Content> {
+ fn realize(&self, _: &dyn World, _: StyleChain) -> TypResult<Content> {
Ok(Content::Text(format_eco!("@{}", self.0)))
}
}
diff --git a/src/library/structure/table.rs b/src/library/structure/table.rs
index 0f74fc96..08fa5386 100644
--- a/src/library/structure/table.rs
+++ b/src/library/structure/table.rs
@@ -30,7 +30,7 @@ impl TableNode {
#[property(resolve, shorthand(around))]
pub const BELOW: Option<BlockSpacing> = Some(Ratio::one().into());
- fn construct(_: &mut Machine, args: &mut Args) -> TypResult<Content> {
+ fn construct(_: &mut Vm, args: &mut Args) -> TypResult<Content> {
let columns = args.named("columns")?.unwrap_or_default();
let rows = args.named("rows")?.unwrap_or_default();
let base_gutter: Vec<TrackSizing> = args.named("gutter")?.unwrap_or_default();
@@ -72,7 +72,7 @@ impl Show for TableNode {
}
}
- fn realize(&self, ctx: &mut Context, styles: StyleChain) -> TypResult<Content> {
+ fn realize(&self, world: &dyn World, styles: StyleChain) -> TypResult<Content> {
let fill = styles.get(Self::FILL);
let stroke = styles.get(Self::STROKE).map(RawStroke::unwrap_or_default);
let padding = styles.get(Self::PADDING);
@@ -92,7 +92,7 @@ impl Show for TableNode {
let x = i % cols;
let y = i / cols;
- if let Some(fill) = fill.resolve(ctx, x, y)? {
+ if let Some(fill) = fill.resolve(world, x, y)? {
child = child.filled(fill);
}
@@ -110,7 +110,7 @@ impl Show for TableNode {
fn finalize(
&self,
- _: &mut Context,
+ _: &dyn World,
styles: StyleChain,
realized: Content,
) -> TypResult<Content> {
@@ -129,12 +129,12 @@ pub enum Celled<T> {
impl<T: Cast + Clone> Celled<T> {
/// Resolve the value based on the cell position.
- pub fn resolve(&self, ctx: &mut Context, x: usize, y: usize) -> TypResult<T> {
+ pub fn resolve(&self, world: &dyn World, x: usize, y: usize) -> TypResult<T> {
Ok(match self {
Self::Value(value) => value.clone(),
Self::Func(func, span) => {
let args = Args::new(*span, [Value::Int(x as i64), Value::Int(y as i64)]);
- func.call_detached(ctx, args)?.cast().at(*span)?
+ func.call_detached(world, args)?.cast().at(*span)?
}
})
}