~jaro/balkon

69e92e75ea01ea2631277c40c5b6fdc36e538337 — Jaro 1 year, 7 months ago 0e50058
Separate interface-independent constants.
M balkon.cabal => balkon.cabal +1 -0
@@ 121,6 121,7 @@ library balkon-internal

    -- Modules used purely internally and not in any tests.
    other-modules:
        Data.Text.ParagraphLayout.Internal.ParagraphExtents,
        Data.Text.ParagraphLayout.Internal.ParagraphLine,
        Data.Text.ParagraphLayout.Internal.ProtoFragment,
        Data.Text.ParagraphLayout.Internal.Script

A src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs +26 -0
@@ 0,0 1,26 @@
module Data.Text.ParagraphLayout.Internal.ParagraphExtents
    ( paragraphOriginX
    , paragraphOriginY
    , containRects
    , emptyRect
    )
where

import Data.Text.ParagraphLayout.Internal.Rect

paragraphOriginX :: (Num a) => a
paragraphOriginX = 0

paragraphOriginY :: (Num a) => a
paragraphOriginY = 0

emptyRect :: (Num a) => Rect a
emptyRect = Rect
    { x_origin = paragraphOriginX
    , y_origin = paragraphOriginY
    , x_size = 0
    , y_size = 0
    }

containRects :: (Ord a, Num a) => [Rect a] -> Rect a
containRects = foldr union emptyRect

M src/Data/Text/ParagraphLayout/Internal/Plain.hs => src/Data/Text/ParagraphLayout/Internal/Plain.hs +1 -0
@@ 28,6 28,7 @@ import Data.Text.ParagraphLayout.Internal.BiDiReorder
import Data.Text.ParagraphLayout.Internal.Break
import Data.Text.ParagraphLayout.Internal.Fragment
import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.ParagraphExtents
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Plain.Paragraph
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

M src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs => src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs +2 -20
@@ 6,8 6,6 @@ module Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
    , mapFragments
    , paragraphFragments
    , paragraphLayout
    , paragraphOriginX
    , paragraphOriginY
    , shapedRuns
    )
where


@@ 15,6 13,7 @@ where
import Data.Int (Int32)

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



@@ 26,23 25,6 @@ data ParagraphLayout d = ParagraphLayout
    }
    deriving (Eq, Read, Show)

paragraphOriginX :: (Num a) => a
paragraphOriginX = 0

paragraphOriginY :: (Num a) => a
paragraphOriginY = 0

empty :: (Num a) => Rect a
empty = Rect
    { x_origin = paragraphOriginX
    , y_origin = paragraphOriginY
    , x_size = 0
    , y_size = 0
    }

containRects :: (Ord a, Num a) => [Rect a] -> Rect a
containRects = foldr union empty

-- | Wrap the given `SpanLayout`s and compute their containing rectangle.
paragraphLayout :: [SpanLayout d] -> ParagraphLayout d
paragraphLayout sls = ParagraphLayout pRect sls


@@ 51,7 33,7 @@ paragraphLayout sls = ParagraphLayout pRect sls
-- | A `ParagraphLayout` with an infinite number of empty spans.
-- Useful as an identity element for `appendFragments`.
emptyParagraphLayout :: ParagraphLayout d
emptyParagraphLayout = ParagraphLayout empty $ repeat (SpanLayout [])
emptyParagraphLayout = ParagraphLayout emptyRect $ repeat (SpanLayout [])

-- | Remove fragments that do not match the given predicate.
--