mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 21:46:11 +03:00
35aa2ad8a4
instance for Widget - This makes the module layout more predictable since Brick.Widgets.Core now (mostly) only contains widgets and widget transformations - Utility functions closely related to types are now in Brick.Types - Brick.Types.Internal contains types used internal by the renderer, some are re-exported by Brick.Types
61 lines
1.4 KiB
Haskell
61 lines
1.4 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
module Main where
|
|
|
|
import Data.Default
|
|
import qualified Graphics.Vty as V
|
|
|
|
import Brick.Main (App(..), neverShowCursor, resizeOrQuit, defaultMain)
|
|
import Brick.Types
|
|
( Widget
|
|
, Padding(..)
|
|
)
|
|
import Brick.Widgets.Core
|
|
( vBox
|
|
, hBox
|
|
, str
|
|
, 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"
|
|
, B.vBorder
|
|
, padRight Max $ vCenter $ str "Right-padded"
|
|
]
|
|
, B.hBorder
|
|
, hBox [ padTop Max $ hCenter $ str "Top-padded"
|
|
, B.vBorder
|
|
, padBottom Max $ hCenter $ str "Bottom-padded"
|
|
]
|
|
, B.hBorder
|
|
, hBox [ padLeftRight 2 $ str "Padded by 2 on left/right"
|
|
, B.vBorder
|
|
, vBox [ padTopBottom 1 $ str "Padded by 1 on top/bottom"
|
|
, B.hBorder
|
|
]
|
|
]
|
|
, 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 ()
|