@@ -171,6 +171,9 @@ utf8Bytestring' :: Attr -> B.ByteString -> Image
171utf8Bytestring' a bs = text' a (T.decodeUtf8 bs)
171utf8Bytestring' a bs = text' a (T.decodeUtf8 bs)
173-- | Make an image filling a region with the specified character.
173-- | Make an image filling a region with the specified character.
175+-- If either the width or height are less than or equal to 0, then
176+-- the result is the empty image.
174charFill :: Integral d
177charFill :: Integral d
176 -- ^ The attribute to use.
179 -- ^ The attribute to use.
@@ -181,14 +184,17 @@ charFill :: Integral d
182 -- ^ The region height.
185 -- ^ The region height.
184−charFill _a _c 0 _h = EmptyImage
187+charFill a c w h
185−charFill _a _c _w 0 = EmptyImage
188+ | w <= 0 || h <= 0 = EmptyImage
186−charFill a c w h =
189+ | otherwise = vertCat
190+ $ replicate (fromIntegral h)
187− vertCat $ replicate (fromIntegral h) $ HorizText a txt displayWidth charWidth
191+ $ HorizText a txt displayWidth charWidth
189− txt = TL.replicate (fromIntegral w) (TL.singleton c)
193+ txt = TL.replicate charWidth (TL.singleton c)
190− displayWidth = safeWcwidth c * (fromIntegral w)
194+ displayWidth = safeWcwidth c * charWidth
196+ charWidth :: Num a => a
191− charWidth = fromIntegral w
197+ charWidth = fromIntegral w
193-- | The empty image. Useful for fold combinators. These occupy no space
199-- | The empty image. Useful for fold combinators. These occupy no space
194-- and do not affect display attributes.
200-- and do not affect display attributes.