aboutsummaryrefslogtreecommitdiffhomepage
path: root/Brick
diff options
context:
space:
mode:
Diffstat (limited to 'Brick')
-rw-r--r--Brick/Widgets/DefnList.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/Brick/Widgets/DefnList.hs b/Brick/Widgets/DefnList.hs
index 090428f..6ce0f48 100644
--- a/Brick/Widgets/DefnList.hs
+++ b/Brick/Widgets/DefnList.hs
@@ -19,16 +19,20 @@ defnList align attr defns = vBox $ line <$> defns
where
line (label, content) = markup $
(T.pack label @@ labelAttr) <> (T.pack sep @@ V.defAttr)
- <> (if align == AlignRight
- then (T.pack (gap label content) @@ V.defAttr)
- else mempty
- )
+ <> (T.pack (gap label content) @@ V.defAttr)
<> (T.pack content @@ V.defAttr)
- gap a b = take (maxWidth - length a - length b - length sep) $
- repeat ' '
+ gap a b
+ | align == AlignRight =
+ take (maxWidth - length a - length b - length sep) $
+ repeat ' '
+ | align == AlignLeft =
+ take (maxLabelWidth - length a) $
+ repeat ' '
+
maxWidth = maximum $
map (\(x,y) -> length sep + length x + length y) defns
+ maxLabelWidth = maximum $ map (\(x,y) -> length x) defns
sep = if align == AlignRight then ": " else ": "
labelAttr = maybe V.defAttr id attr