brick/programs/PaddingDemo.hs

61 lines
1.4 KiB
Haskell
Raw Normal View History

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Default
2015-07-10 23:30:34 +03:00
import qualified Graphics.Vty as V
2015-07-10 23:30:34 +03:00
import Brick.Main (App(..), neverShowCursor, resizeOrQuit, defaultMain)
import Brick.Types
2015-07-10 23:30:34 +03:00
( Widget
, Padding(..)
)
import Brick.Widgets.Core
( vBox
, hBox
, str
2015-07-10 23:30:34 +03:00
, padAll
, padLeft
, padRight
, padTop
, padBottom
, padTopBottom
, padLeftRight
)
import Brick.Widgets.Border as B
import Brick.Widgets.Center as C
ui :: Widget ()
ui =
vBox [ hBox [ padLeft Max $ vCenter $ str "Left-padded"
2015-07-10 23:30:34 +03:00
, B.vBorder
, padRight Max $ vCenter $ str "Right-padded"
]
2015-07-10 23:30:34 +03:00
, B.hBorder
, hBox [ padTop Max $ hCenter $ str "Top-padded"
2015-07-10 23:30:34 +03:00
, B.vBorder
, padBottom Max $ hCenter $ str "Bottom-padded"
]
2015-07-10 23:30:34 +03:00
, B.hBorder
, hBox [ padLeftRight 2 $ str "Padded by 2 on left/right"
2015-07-10 23:30:34 +03:00
, B.vBorder
, vBox [ padTopBottom 1 $ str "Padded by 1 on top/bottom"
2015-07-10 23:30:34 +03:00
, B.hBorder
]
]
2015-07-10 23:30:34 +03:00
, B.hBorder
, padAll 2 $ str "Padded by 2 on all sides"
]
app :: App () V.Event ()
app =
App { appDraw = const [ui]
, appHandleEvent = resizeOrQuit
, appStartEvent = return
, appAttrMap = const def
, appChooseCursor = neverShowCursor
, appLiftVtyEvent = id
}
main :: IO ()
main = defaultMain app ()