brick/programs/MarkupDemo.hs

41 lines
1002 B
Haskell
Raw Normal View History

2015-06-29 06:16:51 +03:00
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Monoid ((<>))
2015-07-10 23:28:23 +03:00
import qualified Graphics.Vty as V
2015-06-29 06:16:51 +03:00
2015-07-10 23:28:23 +03:00
import Brick.Main (App(..), defaultMain, resizeOrQuit, neverShowCursor)
2015-06-29 06:16:51 +03:00
import Brick.Widgets.Core
2015-07-10 23:28:23 +03:00
( Widget
, (<=>)
)
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
2015-07-10 23:28:23 +03:00
m1 = markup $ ("Hello" @@ fg V.blue) <> ", " <> ("world!" @@ fg V.red)
2015-06-29 06:16:51 +03:00
m2 = markup $ ("Hello" @? "keyword1") <> ", " <> ("world!" @? "keyword2")
theMap :: AttrMap
2015-07-10 23:28:23 +03:00
theMap = attrMap V.defAttr
[ ("keyword1", fg V.magenta)
, ("keyword2", V.white `on` V.blue)
2015-06-29 06:16:51 +03:00
]
2015-07-10 23:28:23 +03:00
app :: App () V.Event
2015-06-29 06:16:51 +03:00
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
, appLiftVtyEvent = id
2015-06-29 06:16:51 +03:00
}
main :: IO ()
main = defaultMain app ()