ghc-debug-brick-0.8.0.0: src/GHC/Debug/Brick/UI.hs
{-# LANGUAGE NumericUnderscores #-}
module GHC.Debug.Brick.UI where
import Brick
import Brick.BChan
import Control.Concurrent
import Control.Monad (forever)
import qualified Graphics.Vty as Vty
import qualified Graphics.Vty.CrossPlatform as Vty
import GHC.Debug.Brick.Model
import GHC.Debug.Brick.Render
import GHC.Debug.Brick.Render.Utils
import GHC.Debug.Brick.Update
{-
hBox
[ withAttr treeAttr $ Widget Fixed Fixed $ do
c <- getContext
limitedResult <- render (hLimit (c ^. availWidthL - T.length t) $ vLimit (c ^. availHeightL) $ body)
return $ emptyResult & imageL .~ vertCat (replicate (limitedResult ^. imageL . to imageHeight) (text' (c ^. attrL) t))
, body
]
where
bodyWidth =
render (hLimit (c ^. availWidthL - (length depth * 2 + 4)) $ vLimit (c ^. availHeightL) $ body)
-}
myAppStartEvent :: EventM Name AppState ()
myAppStartEvent = return ()
myAppAttrMap :: AppState -> AttrMap
myAppAttrMap _appState =
attrMap (Vty.withStyle (Vty.white `on` Vty.black) Vty.dim)
[ (menuAttr, Vty.withStyle (Vty.white `on` Vty.blue) Vty.bold)
, (inputAttr, Vty.black `on` Vty.green)
, (labelAttr, Vty.withStyle (fg Vty.white) Vty.bold)
, (highlightAttr, Vty.black `on` Vty.yellow)
, (treeAttr, fg Vty.red)
, (disabledMenuAttr, Vty.withStyle (grey `on` Vty.blue) Vty.bold)
]
mainApp :: IO ()
mainApp = do
eventChan <- newBChan 10
_ <- forkIO $ forever $ do
writeBChan eventChan PollTick
-- 2s
threadDelay 2_000_000
let buildVty = Vty.mkVty Vty.defaultConfig
initialVty <- buildVty
let app :: App AppState Event Name
app = App
{ appDraw = myAppDraw
, appChooseCursor = showFirstCursor
, appHandleEvent = myAppHandleEvent
, appStartEvent = myAppStartEvent
, appAttrMap = myAppAttrMap
}
_finalState <- customMain initialVty buildVty
(Just eventChan) app (initialAppState eventChan)
return ()