~jaro/balkon

ref: ce4f4845a30de2bbcbce4c8c9eb2a0607b57588d balkon/src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs -rw-r--r-- 1.0 KiB
ce4f4845Jaro Generalise shiftFragment function. 1 year, 4 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
module Data.Text.ParagraphLayout.Internal.ResolvedSpan (ResolvedSpan (..))
where

import Data.Text (Text)
import qualified Data.Text.ICU as BreakStatus (Line)

import Data.Text.ParagraphLayout.Internal.BiDiLevels
import Data.Text.ParagraphLayout.Internal.ResolvedBox
import Data.Text.ParagraphLayout.Internal.TextContainer
import Data.Text.ParagraphLayout.Internal.TextOptions

-- | Internal structure containing resolved values that may be shared with
-- other spans across the paragraph.
data ResolvedSpan d = ResolvedSpan
    { spanUserData :: d
    , spanIndex :: Int
    , spanOffsetInParagraph :: Int
    , spanText :: Text
    , spanTextOptions :: TextOptions
    , spanBoxes :: [ResolvedBox d]
    , spanBiDiLevels :: TextLevels
    , spanLineBreaks :: [(Int, BreakStatus.Line)]
    -- TODO: Can be optimised by starting with the shortest line break.
    , spanCharacterBreaks :: [(Int, ())]
    }

instance Eq (ResolvedSpan d) where
    a == b = spanIndex a == spanIndex b

instance TextContainer (ResolvedSpan d) where
    getText = spanText