2015-06-29 08:40:25 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2018-03-17 19:03:30 +03:00
|
|
|
{-# LANGUAGE CPP #-}
|
2015-06-29 08:40:25 +03:00
|
|
|
module Main where
|
|
|
|
|
2018-03-17 19:03:30 +03:00
|
|
|
#if !(MIN_VERSION_base(4,11,0))
|
2015-06-29 08:40:25 +03:00
|
|
|
import Data.Monoid
|
2018-03-17 19:03:30 +03:00
|
|
|
#endif
|
2015-06-29 08:40:25 +03:00
|
|
|
import Graphics.Vty
|
2016-10-26 06:19:31 +03:00
|
|
|
( Attr, white, blue, cyan, green, red, yellow
|
2017-10-06 23:05:24 +03:00
|
|
|
, black, withURL
|
2015-07-10 22:49:17 +03:00
|
|
|
)
|
2015-06-29 08:40:25 +03:00
|
|
|
|
|
|
|
import Brick.Main
|
2015-08-20 05:40:06 +03:00
|
|
|
import Brick.Types
|
2015-07-10 22:49:17 +03:00
|
|
|
( Widget
|
2015-08-20 05:40:06 +03:00
|
|
|
)
|
|
|
|
import Brick.Widgets.Core
|
|
|
|
( (<=>)
|
2015-07-10 22:49:17 +03:00
|
|
|
, withAttr
|
|
|
|
, vBox
|
2015-08-20 05:40:06 +03:00
|
|
|
, str
|
2017-10-06 23:27:41 +03:00
|
|
|
, hyperlink
|
2017-10-09 23:02:21 +03:00
|
|
|
, modifyDefAttr
|
2015-07-10 22:49:17 +03:00
|
|
|
)
|
2015-06-29 08:40:25 +03:00
|
|
|
import Brick.Util (on, fg)
|
|
|
|
import Brick.AttrMap (attrMap, AttrMap)
|
|
|
|
|
2016-10-26 06:19:31 +03:00
|
|
|
ui :: Widget n
|
2015-06-29 08:40:25 +03:00
|
|
|
ui =
|
2015-08-20 05:40:06 +03:00
|
|
|
vBox [ str "This text uses the global default attribute."
|
|
|
|
, withAttr "foundFull" $
|
|
|
|
str "Specifying an attribute name means we look it up in the attribute tree."
|
|
|
|
, (withAttr "foundFgOnly" $
|
|
|
|
str ("When we find a value, we merge it with its parent in the attribute")
|
|
|
|
<=> str "name tree all the way to the root (the global default).")
|
|
|
|
, withAttr "missing" $
|
|
|
|
str "A missing attribute name just resumes the search at its parent."
|
|
|
|
, withAttr ("general" <> "specific") $
|
|
|
|
str "In this way we build complete attribute values by using an inheritance scheme."
|
|
|
|
, withAttr "foundFull" $
|
|
|
|
str "You can override everything ..."
|
|
|
|
, withAttr "foundFgOnly" $
|
2017-10-06 23:26:36 +03:00
|
|
|
str "... or only what you want to change and inherit the rest."
|
2015-08-20 05:40:06 +03:00
|
|
|
, str "Attribute names are assembled with the Monoid append operation to indicate"
|
|
|
|
, str "hierarchy levels, e.g. \"window\" <> \"title\"."
|
2017-10-06 23:05:24 +03:00
|
|
|
, str " "
|
|
|
|
, withAttr "linked" $
|
|
|
|
str "This text is hyperlinked in terminals that support hyperlinking."
|
2017-10-06 23:27:41 +03:00
|
|
|
, str " "
|
|
|
|
, hyperlink "http://www.google.com/" $
|
|
|
|
str "This text is also hyperlinked in terminals that support hyperlinking."
|
2017-10-09 23:02:21 +03:00
|
|
|
, str " "
|
|
|
|
, modifyDefAttr (`withURL` "http://www.google.com/") $
|
|
|
|
str "This text is hyperlinked by modifying the default attribute."
|
2015-06-29 08:40:25 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
globalDefault :: Attr
|
|
|
|
globalDefault = white `on` blue
|
|
|
|
|
|
|
|
theMap :: AttrMap
|
|
|
|
theMap = attrMap globalDefault
|
|
|
|
[ ("foundFull", white `on` green)
|
|
|
|
, ("foundFgOnly", fg red)
|
|
|
|
, ("general", yellow `on` black)
|
|
|
|
, ("general" <> "specific", fg cyan)
|
2017-10-06 23:05:24 +03:00
|
|
|
, ("linked", fg yellow `withURL` "http://www.google.com/")
|
2015-06-29 08:40:25 +03:00
|
|
|
]
|
|
|
|
|
2016-10-26 06:19:31 +03:00
|
|
|
app :: App () e ()
|
2015-06-29 08:40:25 +03:00
|
|
|
app =
|
|
|
|
App { appDraw = const [ui]
|
|
|
|
, appHandleEvent = resizeOrQuit
|
2015-07-01 05:15:29 +03:00
|
|
|
, appStartEvent = return
|
2015-06-29 08:40:25 +03:00
|
|
|
, appAttrMap = const theMap
|
|
|
|
, appChooseCursor = neverShowCursor
|
|
|
|
}
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain app ()
|