From df28848f3f5bde0f29fc2e2d2b2c7725a260f33b Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Fri, 3 Jul 2015 15:49:13 -0700 Subject: [PATCH] str: right-pad short lines in multi-line text strings --- src/Brick/Widgets/Internal.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Brick/Widgets/Internal.hs b/src/Brick/Widgets/Internal.hs index aa51f22..b980aa5 100644 --- a/src/Brick/Widgets/Internal.hs +++ b/src/Brick/Widgets/Internal.hs @@ -219,7 +219,11 @@ str s = -- behavior of empty strings (they have imageHeight 1) [] -> return $ def & image .~ (V.string (c^.attr) "") [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 = str . T.unpack