2020-02-08 03:43:36 +03:00
|
|
|
{-# LANGUAGE CPP #-}
|
2015-06-29 06:16:51 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main where
|
|
|
|
|
2020-02-08 03:43:36 +03:00
|
|
|
#if !(MIN_VERSION_base(4,11,0))
|
2015-06-29 06:16:51 +03:00
|
|
|
import Data.Monoid ((<>))
|
2020-02-08 03:43:36 +03:00
|
|
|
#endif
|
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-08-20 05:40:06 +03:00
|
|
|
import Brick.Types
|
2015-07-10 23:28:23 +03:00
|
|
|
( Widget
|
2016-01-24 02:55:23 +03:00
|
|
|
, Padding(..)
|
2015-08-20 05:40:06 +03:00
|
|
|
)
|
|
|
|
import Brick.Widgets.Core
|
|
|
|
( (<=>)
|
2016-01-24 02:55:23 +03:00
|
|
|
, (<+>)
|
|
|
|
, padLeft
|
2015-07-10 23:28:23 +03:00
|
|
|
)
|
2015-06-29 06:18:59 +03:00
|
|
|
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 ((@@))
|
|
|
|
|
2016-03-05 01:42:49 +03:00
|
|
|
ui :: Widget ()
|
2016-01-24 02:55:23 +03:00
|
|
|
ui = (m1 <=> m2) <+> (padLeft (Pad 1) m3)
|
2015-06-29 06:16:51 +03:00
|
|
|
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")
|
2016-01-24 02:55:23 +03:00
|
|
|
m3 = markup $ ("Hello," @? "keyword1") <> "\n" <> ("world!" @? "keyword2")
|
2015-06-29 06:16:51 +03:00
|
|
|
|
|
|
|
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
|
|
|
]
|
|
|
|
|
2016-10-26 06:19:31 +03:00
|
|
|
app :: App () e ()
|
2015-06-29 06:16:51 +03:00
|
|
|
app =
|
|
|
|
App { appDraw = const [ui]
|
2015-06-29 08:38:35 +03:00
|
|
|
, appHandleEvent = resizeOrQuit
|
2015-06-29 06:16:51 +03:00
|
|
|
, appAttrMap = const theMap
|
2015-07-01 05:15:29 +03:00
|
|
|
, appStartEvent = return
|
2015-06-29 06:16:51 +03:00
|
|
|
, appChooseCursor = neverShowCursor
|
|
|
|
}
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain app ()
|