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)
|
2022-08-05 04:44:57 +03:00
|
|
|
import Brick.AttrMap (attrMap, AttrMap, attrName)
|
2015-06-29 08:40:25 +03:00
|
|
|
|
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."
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "foundFull") $
|
2015-08-20 05:40:06 +03:00
|
|
|
str "Specifying an attribute name means we look it up in the attribute tree."
|
2022-09-24 13:56:11 +03:00
|
|
|
, withAttr (attrName "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)."
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "missing") $
|
2015-08-20 05:40:06 +03:00
|
|
|
str "A missing attribute name just resumes the search at its parent."
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "general" <> attrName "specific") $
|
2015-08-20 05:40:06 +03:00
|
|
|
str "In this way we build complete attribute values by using an inheritance scheme."
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "foundFull") $
|
2015-08-20 05:40:06 +03:00
|
|
|
str "You can override everything ..."
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "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"
|
2022-09-24 13:56:11 +03:00
|
|
|
, str "hierarchy levels, e.g. attrName \"window\" <> attrName \"title\"."
|
2017-10-06 23:05:24 +03:00
|
|
|
, str " "
|
2022-08-05 04:44:57 +03:00
|
|
|
, withAttr (attrName "linked") $
|
2017-10-06 23:05:24 +03:00
|
|
|
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
|
2022-08-05 04:44:57 +03:00
|
|
|
[ (attrName "foundFull", white `on` green)
|
|
|
|
, (attrName "foundFgOnly", fg red)
|
|
|
|
, (attrName "general", yellow `on` black)
|
|
|
|
, (attrName "general" <> attrName "specific",
|
|
|
|
fg cyan)
|
|
|
|
, (attrName "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
|
2022-07-17 09:10:03 +03:00
|
|
|
, appStartEvent = return ()
|
2015-06-29 08:40:25 +03:00
|
|
|
, appAttrMap = const theMap
|
|
|
|
, appChooseCursor = neverShowCursor
|
|
|
|
}
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain app ()
|