brick/programs/MarkupDemo.hs
Jonathan Daugherty 47da95a36b Add markup demo
2015-06-28 20:16:51 -07:00

37 lines
816 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Monoid ((<>))
import Graphics.Vty
import Brick.Main
import Brick.Util
import Brick.Markup
import Brick.AttrMap
import Brick.Widgets.Core
import Data.Text.Markup ((@@))
ui :: Widget
ui = m1 <=> m2
where
m1 = markup $ ("Hello" @@ fg blue) <> ", " <> ("world!" @@ fg red)
m2 = markup $ ("Hello" @? "keyword1") <> ", " <> ("world!" @? "keyword2")
theMap :: AttrMap
theMap = attrMap defAttr
[ ("keyword1", fg magenta)
, ("keyword2", white `on` blue)
]
app :: App () Event
app =
App { appDraw = const [ui]
, appHandleEvent = const halt
, appAttrMap = const theMap
, appChooseCursor = neverShowCursor
, appMakeVtyEvent = id
}
main :: IO ()
main = defaultMain app ()