{-# LANGUAGE TemplateHaskell #-}
module DzenDhall.Runtime.Data where
import DzenDhall.Arguments
import DzenDhall.Data
import DzenDhall.Config hiding (Hook)
import Control.Concurrent.MVar
import Data.IORef
import Dhall hiding (maybe)
import Lens.Micro.TH
import System.IO
import System.Process (ProcessHandle)
import qualified Data.HashMap.Strict as H
apiVersion :: Int
apiVersion = 1
data Runtime = Runtime
{ _rtConfigDir :: String
, _rtConfigurations :: [Configuration]
, _rtDzenBinary :: String
, _rtArguments :: Arguments
, _rtSupportsANSI :: Bool
, _rtExitMVar :: MVar ()
}
deriving (Eq)
makeLenses ''Runtime
data Subscription
= AutomatonSubscription
AutomatonAddress
StateTransitionTable
(H.HashMap AutomatonState (Bar Initialized))
(IORef AutomatonState)
(IORef (Bar Initialized))
type Subscriptions = H.HashMap Scope [Subscription]
type ClickableAreas = H.HashMap Int Text
type AutomataCache
= H.HashMap (Scope, AutomatonAddress)
( IORef (Bar Initialized)
, StateTransitionTable
, H.HashMap AutomatonState (Bar Marshalled)
)
data StartupState
= StartupState
{ _ssSubscriptions :: Subscriptions
, _ssScopeName :: Scope
, _ssBarSettings :: BarSettings
, _ssNonce :: Int
, _ssSourceCache :: H.HashMap (Text, Source) (IORef Text, Cache)
, _ssAutomataCache :: AutomataCache
, _ssSourceQueue :: [(Source, IORef Text, Cache, Text)]
, _ssVariableDefinitions :: [(Scope, VariableName, Value)]
, _ssImages :: H.HashMap ImageContents ImageId
, _ssClickableAreas :: ClickableAreas
, _ssNamedPipe :: String
, _ssEmitterFile :: String
, _ssGetterFile :: String
, _ssSetterFile :: String
, _ssVariableFilePrefix :: String
, _ssImagePathPrefix :: String
}
makeLenses ''StartupState
data BarRuntime = BarRuntime
{ _brConfiguration :: Configuration
, _brFrameCounter :: Int
, _brNamedPipe :: String
, _brEmitterScript :: String
, _brGetterScript :: String
, _brSetterScript :: String
, _brHandle :: Handle
, _brDzenHandle :: Maybe ProcessHandle
}
makeLenses ''BarRuntime