brick/programs/MarkupDemo.hs

38 lines
894 B
Haskell
Raw Normal View History

2015-06-29 06:16:51 +03:00
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Monoid ((<>))
import Graphics.Vty
import Brick.Main
import Brick.Widgets.Core
import Brick.Util (on, fg)
import Brick.Markup (markup, (@?))
import Brick.AttrMap (attrMap, AttrMap)
2015-06-29 06:16:51 +03:00
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 = resizeOrQuit
2015-06-29 06:16:51 +03:00
, appAttrMap = const theMap
, appStartEvent = return
2015-06-29 06:16:51 +03:00
, appChooseCursor = neverShowCursor
, appMakeVtyEvent = id
}
main :: IO ()
main = defaultMain app ()