~jaro/balkon

7efca56bb946ebef06711512cbc49eb2c1216c1c — Jaro 1 year, 7 months ago f832ce6
Separate internal plain Paragraph/ParagraphLayout.
10 files changed, 47 insertions(+), 36 deletions(-)

M balkon.cabal
M lib/Data/Text/ParagraphLayout.hs
M src/Data/Text/ParagraphLayout/Internal/Paginable.hs
M src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs
M src/Data/Text/ParagraphLayout/Internal/ParagraphLine.hs
A src/Data/Text/ParagraphLayout/Internal/ParagraphOptions.hs
M src/Data/Text/ParagraphLayout/Internal/Plain.hs
R src/Data/Text/ParagraphLayout/Internal/{Paragraph.hs => Plain/Paragraph.hs}
R src/Data/Text/ParagraphLayout/Internal/{ParagraphLayout.hs => Plain/ParagraphLayout.hs}
M test/Data/Text/ParagraphLayoutSpec.hs
M balkon.cabal => balkon.cabal +3 -2
@@ 130,11 130,12 @@ library balkon-internal
        Data.Text.ParagraphLayout.Internal.LineHeight,
        Data.Text.ParagraphLayout.Internal.LinePagination,
        Data.Text.ParagraphLayout.Internal.Paginable,
        Data.Text.ParagraphLayout.Internal.Paragraph,
        Data.Text.ParagraphLayout.Internal.ParagraphConstruction,
        Data.Text.ParagraphLayout.Internal.ParagraphLayout,
        Data.Text.ParagraphLayout.Internal.ParagraphLine,
        Data.Text.ParagraphLayout.Internal.ParagraphOptions,
        Data.Text.ParagraphLayout.Internal.Plain,
        Data.Text.ParagraphLayout.Internal.Plain.Paragraph,
        Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout,
        Data.Text.ParagraphLayout.Internal.Rect,
        Data.Text.ParagraphLayout.Internal.ResolvedSpan,
        Data.Text.ParagraphLayout.Internal.Run,

M lib/Data/Text/ParagraphLayout.hs => lib/Data/Text/ParagraphLayout.hs +3 -2
@@ 46,7 46,8 @@ import Data.Text.ParagraphLayout.Internal.Fragment
import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.LinePagination
import Data.Text.ParagraphLayout.Internal.Paginable
import Data.Text.ParagraphLayout.Internal.Paragraph
import Data.Text.ParagraphLayout.Internal.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Plain
import Data.Text.ParagraphLayout.Internal.Plain.Paragraph
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.Span

M src/Data/Text/ParagraphLayout/Internal/Paginable.hs => src/Data/Text/ParagraphLayout/Internal/Paginable.hs +1 -1
@@ 8,8 8,8 @@ where
import Data.Int (Int32)

import Data.Text.ParagraphLayout.Internal.LinePagination
import Data.Text.ParagraphLayout.Internal.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.ParagraphLine
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout

data PageOptions = PageOptions


M src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs +2 -1
@@ 13,7 13,8 @@ import Data.Text.Internal.Lazy (chunk, empty)
import qualified Data.Text.Internal.Lazy as Lazy
import Data.Text.Lazy (toStrict)

import Data.Text.ParagraphLayout.Internal.Paragraph
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Plain.Paragraph
import Data.Text.ParagraphLayout.Internal.Span (Span (Span), SpanOptions)

-- | Create first span with optional ignored suffix.

M src/Data/Text/ParagraphLayout/Internal/ParagraphLine.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphLine.hs +1 -1
@@ 6,7 6,7 @@ import qualified Data.List.NonEmpty as NonEmpty

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

-- | Represents one line of a `ParagraphLayout`.

A src/Data/Text/ParagraphLayout/Internal/ParagraphOptions.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphOptions.hs +30 -0
@@ 0,0 1,30 @@
module Data.Text.ParagraphLayout.Internal.ParagraphOptions
    ( ParagraphOptions (..)
    )
where

import Data.Int (Int32)
import Data.Text.Glyphize (Font)

import Data.Text.ParagraphLayout.Internal.LineHeight

-- | Defines options relevant to the entire paragraph.
data ParagraphOptions = ParagraphOptions

    { paragraphFont :: Font
    -- ^ Font to be used for shaping and measurement.
    -- Make sure to set its scale (see `Data.Text.Glyphize.optionScale`) using
    -- the same units that you want in the output.

    , paragraphLineHeight :: LineHeight
    -- ^ Preferred line height of the resulting box fragments.

    , paragraphMaxWidth :: Int32
    -- ^ Line width at which line breaking should occur.
    -- Lines will be broken at language-appropriate boundaries.
    -- If a line still exceeds this limit then, it will be broken at character
    -- boundaries, and if it already consists of a single cluster that cannot
    -- be further broken down, it will overflow.

    }
    deriving (Eq, Show)

M src/Data/Text/ParagraphLayout/Internal/Plain.hs => src/Data/Text/ParagraphLayout/Internal/Plain.hs +3 -2
@@ 28,8 28,9 @@ 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.Paragraph
import Data.Text.ParagraphLayout.Internal.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Plain.Paragraph
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
import qualified Data.Text.ParagraphLayout.Internal.ProtoFragment as PF
import Data.Text.ParagraphLayout.Internal.Rect
import Data.Text.ParagraphLayout.Internal.ResolvedSpan (WithSpan (WithSpan))

R src/Data/Text/ParagraphLayout/Internal/Paragraph.hs => src/Data/Text/ParagraphLayout/Internal/Plain/Paragraph.hs +2 -25
@@ 1,20 1,17 @@
module Data.Text.ParagraphLayout.Internal.Paragraph
module Data.Text.ParagraphLayout.Internal.Plain.Paragraph
    ( Paragraph (..)
    , ParagraphOptions (..)
    , paragraphSpanBounds
    , paragraphSpanTexts
    , paragraphText
    )
where

import Data.Int (Int32)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.List.NonEmpty as NonEmpty
import Data.Text.Array (Array)
import Data.Text.Glyphize (Font)
import Data.Text.Internal (Text (Text))

import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.ParagraphOptions
import Data.Text.ParagraphLayout.Internal.Span

-- | Text to be laid out as a single paragraph.


@@ 57,26 54,6 @@ data Paragraph = Paragraph
    ParagraphOptions
    -- ^ Options applying to the paragraph as a whole.

data ParagraphOptions = ParagraphOptions

    { paragraphFont :: Font
    -- ^ Font to be used for shaping and measurement.
    -- Make sure to set its scale (see `Data.Text.Glyphize.optionScale`) using
    -- the same units that you want in the output.

    , paragraphLineHeight :: LineHeight
    -- ^ Preferred line height of the resulting box fragments.

    , paragraphMaxWidth :: Int32
    -- ^ Line width at which line breaking should occur.
    -- Lines will be broken at language-appropriate boundaries.
    -- If a line still exceeds this limit then, it will be broken at character
    -- boundaries, and if it already consists of a single cluster that cannot
    -- be further broken down, it will overflow.

    }
    deriving (Eq, Show)

-- | Calculate the offsets into the `Paragraph`'s underlying `Data.Text.Array`
-- where each span starts and ends, in ascending order. The resulting list
-- will be one larger than the list of input spans.

R src/Data/Text/ParagraphLayout/Internal/ParagraphLayout.hs => src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs +1 -1
@@ 1,4 1,4 @@
module Data.Text.ParagraphLayout.Internal.ParagraphLayout
module Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
    ( ParagraphLayout (..)
    , appendFragments
    , emptyParagraphLayout

M test/Data/Text/ParagraphLayoutSpec.hs => test/Data/Text/ParagraphLayoutSpec.hs +1 -1
@@ 12,7 12,7 @@ import System.FilePath ((</>))
import Data.Text.ParagraphLayout
import Data.Text.ParagraphLayout.FontLoader
import Data.Text.ParagraphLayout.Internal.Fragment
import Data.Text.ParagraphLayout.Internal.ParagraphLayout
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout
import Data.Text.ParagraphLayout.ParagraphData
import Data.Text.ParagraphLayout.Rect