str: right-pad short lines in multi-line text strings

This commit is contained in:
Jonathan Daugherty 2015-07-03 15:49:13 -07:00
parent 19221e6a6f
commit df28848f3f

View File

@ -219,7 +219,11 @@ str s =
-- behavior of empty strings (they have imageHeight 1) -- behavior of empty strings (they have imageHeight 1)
[] -> return $ def & image .~ (V.string (c^.attr) "") [] -> return $ def & image .~ (V.string (c^.attr) "")
[one] -> return $ def & image .~ (V.string (c^.attr) one) [one] -> return $ def & image .~ (V.string (c^.attr) one)
multiple -> return $ def & image .~ (V.vertCat $ V.string (c^.attr) <$> multiple) multiple ->
let maxLength = maximum $ length <$> multiple
lineImgs = lineImg <$> multiple
lineImg lStr = V.string (c^.attr) (lStr ++ replicate (maxLength - length lStr) ' ')
in return $ def & image .~ (V.vertCat lineImgs)
txt :: T.Text -> Widget txt :: T.Text -> Widget
txt = str . T.unpack txt = str . T.unpack