summaryrefslogtreecommitdiff
path: root/src/library/text/repeat.rs
blob: 68036be7e1b7052830a6f7e421ea45a3cdc5a891 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
    }
}