~jaro/balkon

ebfdbbdb57733dad57c02aba88fa6d14e706e7e7 — Jaro 1 year, 7 months ago f85c0d0
Deduplicate pagination code.
M src/Data/Text/ParagraphLayout/Internal/Paginable.hs => src/Data/Text/ParagraphLayout/Internal/Paginable.hs +7 -4
@@ 79,14 79,17 @@ instance Line a => Paginable [a] where
-- | Implementation of paginating a plain text paragraph layout.
-- Breaks the layout on page boundaries and automatically adjusts coordinates.
instance Paginable (Plain.ParagraphLayout d) where
    paginate opts pl = case paginate opts (cutLines pl) of
        (c, p, Nothing) -> (c, mergeLines p, Nothing)
        (c, p, Just rest) -> (c, mergeLines p, Just (mergeLines rest))
    paginate = paginateLayout

-- | Implementation of paginating a rich text paragraph layout.
-- Breaks the layout on page boundaries and automatically adjusts coordinates.
instance Paginable (Rich.ParagraphLayout d) where
    paginate opts pl = case paginate opts (cutLines pl) of
    paginate = paginateLayout

paginateLayout :: (Line a, GenericLayout a) =>
   PageOptions -> a -> (PageContinuity, a, Maybe a)
paginateLayout opts pl =
    case paginate opts (cutLines pl) of
        (c, p, Nothing) -> (c, mergeLines p, Nothing)
        (c, p, Just rest) -> (c, mergeLines p, Just (mergeLines rest))


M src/Data/Text/ParagraphLayout/Internal/ParagraphLine.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphLine.hs +2 -1
@@ 1,6 1,7 @@
-- | Splitting paragraph layouts between lines.
module Data.Text.ParagraphLayout.Internal.ParagraphLine
    ( cutLines
    ( GenericLayout
    , cutLines
    , mergeLines
    )
where