brick/programs/PaddingDemo.hs
Jonathan Daugherty 3081e7367d Replace "Name" type with custom name type variable everywhere
This experimental change makes it possible to:
* Avoid runtime errors due to name typos
* Achieve compile-time guarantees about name matching and usage
* Force widget functions to be name-agnostic by being polymorphic
  in their name type
* Clean up focus handling by making it possible to pattern-match
  on cursor location names

The change also made many types more heavyweight and in some cases
this is unpleasant when we don't want to have to care about names.
But in those cases we can just use 'n' or '()' depending on how
concrete we need to be.  I'm not yet sure how this is going to play
out in practice.
2016-03-04 14:42:49 -08:00

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 ()