~jaro/balkon

ref: 65d952e2f615751db54267097c706545be5e6be6 balkon/src/Data/Text/ParagraphLayout/Internal/Span.hs -rw-r--r-- 1.0 KiB
65d952e2Jaro Slightly decompose the Plain module. 1 year, 2 months 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
module Data.Text.ParagraphLayout.Internal.Span
    (Span(..)
    ,SpanLayout(..)
    ,spanRects
    )
where

import Data.Int (Int32)

import Data.Text.ParagraphLayout.Internal.Fragment
import Data.Text.ParagraphLayout.Internal.Rect

-- | A paragraph is broken into spans by the caller.
--
-- Each span could have a different font family, size, style, text decoration,
-- colour, language, etc.
data Span = Span
-- TODO: Add all relevant attributes.

    { spanLength :: Int
    -- ^ Byte offset to the next span or the end of the paragraph text.

    , spanLanguage :: String
    -- ^ Used for selecting the appropriate glyphs and line breaking rules.

    }
    deriving (Eq, Read, Show)

-- | The resulting layout of each span, which may include multiple fragments if
-- broken over multiple lines.
data SpanLayout = SpanLayout [Fragment]
    -- TODO: Consider merging. fragments created by script changes.
    deriving (Eq, Read, Show)

spanRects :: SpanLayout -> [Rect Int32]
spanRects (SpanLayout frags) = map fragmentRect frags