diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2017-02-25 15:17:15 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-02-25 15:17:15 -0700 |
commit | c4a2d0cdd5be556848627fb65d603e1fd5d66a2f (patch) | |
tree | f7d7fb54fb9beb5f0762fae86f660cf9f687b22a /Brick | |
parent | 3ced073c900ae0389771b438da3d0584a6dfec63 (diff) | |
download | sscan-c4a2d0cdd5be556848627fb65d603e1fd5d66a2f.tar.gz |
factor out defnList widget
Diffstat (limited to 'Brick')
-rw-r--r-- | Brick/Widgets/DefnList.hs | 13 |
1 files changed, 13 insertions, 0 deletions
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 = ": " |