on master help sign in
Merge pull request #116 from ChrisPenner/empty-text-image

Remove 'emptyImage' overrides for zero-length HorizText

commit0002d3de808629c889959c2b6aa4c571e18f493f authorJonathan Daugherty <cygnus@foobox.com> dateSat 3 Dec 2016, 17:06 (10 years ago) parentf2774c1d482c11
4 files changed+10−14
.gitignore+1 src/Graphics/Vty/Image.hs+4−9 src/Graphics/Vty/Image/Internal.hs+4−4 src/Graphics/Vty/PictureToSpans.hs+1−1
.gitignore+1
@@ -9,3 +9,4 @@ test/benchmark
99.cabal-sandbox
1010cabal.sandbox.config
1111test/cabal.sandbox.config
12+.stack-work
src/Graphics/Vty/Image.hs+4−9
@@ -88,17 +88,13 @@ vertCat = foldr vertJoin EmptyImage
8888
8989-- | A Data.Text.Lazy value
9090text :: Attr -> TL.Text -> Image
91−text a txt
92− | TL.length txt == 0 = EmptyImage
93− | otherwise = let displayWidth = safeWcswidth (TL.unpack txt)
94− in HorizText a txt displayWidth (fromIntegral $! TL.length txt)
91+text a txt = let displayWidth = safeWcswidth (TL.unpack txt)
92+ in HorizText a txt displayWidth (fromIntegral $! TL.length txt)
9593
9694-- | A Data.Text value
9795text' :: Attr -> T.Text -> Image
98−text' a txt
99− | T.length txt == 0 = EmptyImage
100− | otherwise = let displayWidth = safeWcswidth (T.unpack txt)
101− in HorizText a (TL.fromStrict txt) displayWidth (T.length txt)
96+text' a txt = let displayWidth = safeWcswidth (T.unpack txt)
97+ in HorizText a (TL.fromStrict txt) displayWidth (T.length txt)
10298
10399-- | an image of a single character. This is a standard Haskell 31-bit character assumed to be in
104100-- the ISO-10646 encoding.
@@ -117,7 +113,6 @@ char a c =
117113-- directly to iso10646String or string.
118114--
119115iso10646String :: Attr -> String -> Image
120−iso10646String _ [] = EmptyImage
121116iso10646String a str =
122117 let displayWidth = safeWcswidth str
123118 in HorizText a (TL.pack str) displayWidth (length str)
src/Graphics/Vty/Image/Internal.hs+4−4
@@ -66,14 +66,14 @@ clipText txt leftSkip rightClip =
6666--
6767-- * an empty image of no size or content.
6868data Image =
69− -- | A horizontal text span is always >= 1 column and has a row height of 1.
69+ -- | A horizontal text span has a row height of 1.
7070 HorizText
7171 { attr :: Attr
7272 -- | The text to display. The display width of the text is always outputWidth.
7373 , displayText :: DisplayText
74− -- | The number of display columns for the text. Always > 0.
74+ -- | The number of display columns for the text.
7575 , outputWidth :: Int
76− -- | the number of characters in the text. Always > 0.
76+ -- | the number of characters in the text.
7777 , charWidth :: Int
7878 }
7979 -- | A horizontal join can be constructed between any two images. However a HorizJoin instance is
@@ -82,7 +82,7 @@ data Image =
8282 | HorizJoin
8383 { partLeft :: Image
8484 , partRight :: Image
85− , outputWidth :: Int -- ^ imageWidth partLeft == imageWidth partRight. Always > 1
85+ , outputWidth :: Int -- ^ imageWidth partLeft == imageWidth partRight. Always > 0
8686 , outputHeight :: Int -- ^ imageHeight partLeft == imageHeight partRight. Always > 0
8787 }
8888 -- | A veritical join can be constructed between any two images. However a VertJoin instance is
src/Graphics/Vty/PictureToSpans.hs+1−1
@@ -309,7 +309,7 @@ addMaybeClippedJoin name skip remaining offset i0Dim i0 i1 size = do
309309 when (state^.remaining <= 0) $ fail $ name ++ " with remaining <= 0"
310310 case state^.skip of
311311 s -- TODO: check if clipped in other dim. if not use addUnclipped
312− | s >= size -> fail $ name ++ " on fully clipped"
312+ | s > size -> fail $ name ++ " on fully clipped"
313313 | s == 0 -> if state^.remaining > i0Dim
314314 then do
315315 addMaybeClipped i0