~jaro/balkon

ref: 0bee8136697d2c892cbb567c2780cfa35cb8d01b balkon/test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs -rw-r--r-- 1.3 KiB
0bee8136Jaro Test Rich layout. 1 year, 14 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Data.Text.ParagraphLayout.Rich.ParagraphData (nestedBoxesParagraph)
where

import Data.Text (pack)
import Data.Text.Glyphize (Font)

import Data.Text.ParagraphLayout.Internal.BoxOptions
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Rich.Paragraph
import Data.Text.ParagraphLayout.Internal.TextOptions
import Data.Text.ParagraphLayout.Internal.TreeOfTexts

t_ :: TextOptions
t_ = defaultTextOptions

b_ :: BoxOptions
b_ = defaultBoxOptions

rootBox :: TextOptions -> [InnerNode d] -> RootNode d
rootBox opts nodes = RootBox (Box nodes opts)

box :: d -> BoxOptions -> TextOptions -> [InnerNode d] -> InnerNode d
box label boxOpts textOpts nodes = InlineBox label (Box nodes textOpts) boxOpts

text :: d -> String -> InnerNode d
text label contents = TextSequence label (pack contents)

nestedBoxesParagraph :: Font -> ParagraphOptions -> Paragraph String
nestedBoxesParagraph font = constructParagraph
    (pack "prefix")
    (rootBox t
        [ text "text1" "this paragraph has "
        , box "box2" b_ t
            [ box "box3" b_ t
                [ text "text2" "nested "
                ]
            , text "text3" "boxes"
            ]
        ]
    )
    (pack "suffix")
    where
        t = t_ { textFont = font, textLanguage = "en" }