diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-02 13:17:07 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-02 13:21:36 +0100 |
| commit | 5110a41de1ca2236739ace2d37a1af912bb029f1 (patch) | |
| tree | 22cc223140052bd7ec10798f5ecbffaae7c934a8 /library/src/basics | |
| parent | 33ab1fdbdda4e95e48b767a3f7f8f66413b6de0e (diff) | |
Introduce virtual typesetter
Diffstat (limited to 'library/src/basics')
| -rw-r--r-- | library/src/basics/heading.rs | 2 | ||||
| -rw-r--r-- | library/src/basics/list.rs | 10 | ||||
| -rw-r--r-- | library/src/basics/table.rs | 15 |
3 files changed, 11 insertions, 16 deletions
diff --git a/library/src/basics/heading.rs b/library/src/basics/heading.rs index b251f27b..d1ea9da6 100644 --- a/library/src/basics/heading.rs +++ b/library/src/basics/heading.rs @@ -34,7 +34,7 @@ impl HeadingNode { } impl Show for HeadingNode { - fn show(&self, _: Tracked<dyn World>, _: StyleChain) -> Content { + fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> Content { BlockNode(self.body.clone()).pack() } } diff --git a/library/src/basics/list.rs b/library/src/basics/list.rs index c73ffea6..e35fe9fa 100644 --- a/library/src/basics/list.rs +++ b/library/src/basics/list.rs @@ -78,7 +78,7 @@ impl<const L: ListKind> ListNode<L> { impl<const L: ListKind> Layout for ListNode<L> { fn layout( &self, - world: Tracked<dyn World>, + vt: &mut Vt, styles: StyleChain, regions: &Regions, ) -> SourceResult<Fragment> { @@ -104,7 +104,7 @@ impl<const L: ListKind> Layout for ListNode<L> { cells.push(Content::empty()); let label = if L == LIST || L == ENUM { - label.resolve(world, L, number)?.styled_with_map(map.clone()) + label.resolve(vt, L, number)?.styled_with_map(map.clone()) } else { Content::empty() }; @@ -137,7 +137,7 @@ impl<const L: ListKind> Layout for ListNode<L> { gutter: Axes::with_y(vec![gutter.into()]), cells, } - .layout(world, styles, regions) + .layout(vt, styles, regions) } } @@ -232,7 +232,7 @@ impl Label { /// Resolve the label based on the level. pub fn resolve( &self, - world: Tracked<dyn World>, + vt: &Vt, kind: ListKind, number: usize, ) -> SourceResult<Content> { @@ -246,7 +246,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(world, args)?.display() + func.call_detached(vt.world(), args)?.display() } }) } diff --git a/library/src/basics/table.rs b/library/src/basics/table.rs index bb900f3d..38ee57a0 100644 --- a/library/src/basics/table.rs +++ b/library/src/basics/table.rs @@ -53,7 +53,7 @@ impl TableNode { impl Layout for TableNode { fn layout( &self, - world: Tracked<dyn World>, + vt: &mut Vt, styles: StyleChain, regions: &Regions, ) -> SourceResult<Fragment> { @@ -76,7 +76,7 @@ impl Layout for TableNode { let x = i % cols; let y = i / cols; - if let Some(fill) = fill.resolve(world, x, y)? { + if let Some(fill) = fill.resolve(vt, x, y)? { child = child.filled(fill); } @@ -89,7 +89,7 @@ impl Layout for TableNode { gutter: self.gutter.clone(), cells, } - .layout(world, styles, regions) + .layout(vt, styles, regions) } } @@ -104,17 +104,12 @@ pub enum Celled<T> { impl<T: Cast + Clone> Celled<T> { /// Resolve the value based on the cell position. - pub fn resolve( - &self, - world: Tracked<dyn World>, - x: usize, - y: usize, - ) -> SourceResult<T> { + pub fn resolve(&self, vt: &Vt, x: usize, y: usize) -> SourceResult<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(world, args)?.cast().at(*span)? + func.call_detached(vt.world(), args)?.cast().at(*span)? } }) } |
