From c4a2d0cdd5be556848627fb65d603e1fd5d66a2f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 25 Feb 2017 15:17:15 -0700 Subject: factor out defnList widget --- Brick/Widgets/DefnList.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Brick/Widgets/DefnList.hs (limited to 'Brick') diff --git a/Brick/Widgets/DefnList.hs b/Brick/Widgets/DefnList.hs new file mode 100644 index 0000000..5750cdc --- /dev/null +++ b/Brick/Widgets/DefnList.hs @@ -0,0 +1,13 @@ +module Brick.Widgets.DefnList (defnList) where + +import Brick.Types +import Brick.Widgets.Core + +defnList :: [(String, String)] -> Widget () +defnList defns = vBox $ line <$> defns + where + line (label, content) = str $ + label ++ sep ++ (gap label content) ++ content + gap a b = take (maxWidth - length a - length b - length sep) $ repeat ' ' + maxWidth = maximum $ map (\(x,y) -> length sep + length x + length y) defns + sep = ": " -- cgit v1.2.3