From 5d664fc528c3b92a4c38474a79a4958374818dae Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Wed, 13 Jan 2021 17:14:09 +1100 Subject: [PATCH] lib: Expose textConcatBottomPadded. --- hledger-lib/Hledger/Utils/Text.hs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/hledger-lib/Hledger/Utils/Text.hs b/hledger-lib/Hledger/Utils/Text.hs index db3440777..1906a07b1 100644 --- a/hledger-lib/Hledger/Utils/Text.hs +++ b/hledger-lib/Hledger/Utils/Text.hs @@ -34,7 +34,7 @@ module Hledger.Utils.Text formatText, -- -- * multi-line layout textConcatTopPadded, - -- concatBottomPadded, + textConcatBottomPadded, -- concatOneLine, -- vConcatLeftAligned, -- vConcatRightAligned, @@ -201,18 +201,11 @@ textConcatTopPadded :: [Text] -> Text textConcatTopPadded = TL.toStrict . renderRow def{tableBorders=False, borderSpaces=False} . Group NoLine . map (Header . textCell BottomLeft) --- -- | Join several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. --- -- Treats wide characters as double width. --- concatBottomPadded :: [String] -> String --- concatBottomPadded strs = intercalate "\n" $ map concat $ transpose padded --- where --- lss = map lines strs --- h = maximum $ map length lss --- ypad ls = ls ++ replicate (difforzero h (length ls)) "" --- xpad ls = map (padRightWide w) ls where w | null ls = 0 --- | otherwise = maximum $ map strWidth ls --- padded = map (xpad . ypad) lss - +-- | Join several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. +-- Treats wide characters as double width. +textConcatBottomPadded :: [Text] -> Text +textConcatBottomPadded = TL.toStrict . renderRow def{tableBorders=False, borderSpaces=False} + . Group NoLine . map (Header . textCell TopLeft) -- -- | Join multi-line strings horizontally, after compressing each of -- -- them to a single line with a comma and space between each original line.