diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-17 12:11:00 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-17 12:11:00 +0200 |
| commit | db820ae9aa095cf47d4ae3a582467b01613c3711 (patch) | |
| tree | 93712ec28190dd754a89e7a9266c9855f2a0bd2c /src/library/text/repeat.rs | |
| parent | 4494b443bb34fed2208ee3fc87e9a18e7d14b2ab (diff) | |
Repeat function
Diffstat (limited to 'src/library/text/repeat.rs')
| -rw-r--r-- | src/library/text/repeat.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/library/text/repeat.rs b/src/library/text/repeat.rs new file mode 100644 index 00000000..68036be7 --- /dev/null +++ b/src/library/text/repeat.rs @@ -0,0 +1,24 @@ +use crate::library::prelude::*; + +/// Fill space by repeating something horizontally. +#[derive(Debug, Hash)] +pub struct RepeatNode(pub LayoutNode); + +#[node] +impl RepeatNode { + fn construct(_: &mut Context, args: &mut Args) -> TypResult<Content> { + Ok(Content::inline(Self(args.expect("body")?))) + } +} + +impl Layout for RepeatNode { + fn layout( + &self, + ctx: &mut Context, + regions: &Regions, + styles: StyleChain, + ) -> TypResult<Vec<Arc<Frame>>> { + // The actual repeating happens directly in the paragraph. + self.0.layout(ctx, regions, styles) + } +} |
