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