mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-12 12:23:21 +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
43 lines
1.0 KiB
Haskell
43 lines
1.0 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
module Main where
|
|
|
|
import Data.Monoid ((<>))
|
|
import qualified Graphics.Vty as V
|
|
|
|
import Brick.Main (App(..), defaultMain, resizeOrQuit, neverShowCursor)
|
|
import Brick.Types
|
|
( Widget
|
|
)
|
|
import Brick.Widgets.Core
|
|
( (<=>)
|
|
)
|
|
import Brick.Util (on, fg)
|
|
import Brick.Markup (markup, (@?))
|
|
import Brick.AttrMap (attrMap, AttrMap)
|
|
import Data.Text.Markup ((@@))
|
|
|
|
ui :: Widget
|
|
ui = m1 <=> m2
|
|
where
|
|
m1 = markup $ ("Hello" @@ fg V.blue) <> ", " <> ("world!" @@ fg V.red)
|
|
m2 = markup $ ("Hello" @? "keyword1") <> ", " <> ("world!" @? "keyword2")
|
|
|
|
theMap :: AttrMap
|
|
theMap = attrMap V.defAttr
|
|
[ ("keyword1", fg V.magenta)
|
|
, ("keyword2", V.white `on` V.blue)
|
|
]
|
|
|
|
app :: App () V.Event
|
|
app =
|
|
App { appDraw = const [ui]
|
|
, appHandleEvent = resizeOrQuit
|
|
, appAttrMap = const theMap
|
|
, appStartEvent = return
|
|
, appChooseCursor = neverShowCursor
|
|
, appLiftVtyEvent = id
|
|
}
|
|
|
|
main :: IO ()
|
|
main = defaultMain app ()
|