M .golden/richParagraphLayout/loremIpsum20emRight.golden => .golden/richParagraphLayout/loremIpsum20emRight.golden +1 -1
@@ 1,5 1,5 @@
ParagraphLayout
- { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 20000, y_size = -12331}
+ { paragraphRect = Rect {x_origin = 209, y_origin = 0, x_size = 19791, y_size = -12331}
, paragraphFragments =
[ Fragment
{ fragmentUserData = "text"
M src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs => src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs +10 -2
@@ 6,14 6,20 @@ module Data.Text.ParagraphLayout.Internal.ParagraphExtents
)
where
+import Data.Maybe (fromMaybe)
+
import Data.Text.ParagraphLayout.Internal.Rect
+-- | X coordinate used as the left edge of every paragraph.
paragraphOriginX :: (Num a) => a
paragraphOriginX = 0
+-- | Y coordinate used as the top edge of every paragraph.
paragraphOriginY :: (Num a) => a
paragraphOriginY = 0
+-- | A `Rect` located at the top left corner of a paragraph,
+-- with zero size in each dimension.
emptyRect :: (Num a) => Rect a
emptyRect = Rect
{ x_origin = paragraphOriginX
@@ 22,5 28,7 @@ emptyRect = Rect
, y_size = 0
}
-containRects :: (Ord a, Num a) => [Rect a] -> Rect a
-containRects = foldr (union LH) emptyRect
+-- | Smallest rectangle containing the given rectangles,
+-- or `emptyRect` if none are given.
+containRects :: (Num a, Ord a) => [Rect a] -> Rect a
+containRects rects = fromMaybe emptyRect $ unionMany LH rects