git-annex/Types/Messages.hs

53 lines
1.2 KiB
Haskell
Raw Normal View History

{- git-annex Messages data types
-
- Copyright 2012-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Types.Messages where
import qualified Data.Aeson as Aeson
2015-04-03 23:56:56 +00:00
import Control.Concurrent
#ifdef WITH_CONCURRENTOUTPUT
import System.Console.Regions (ConsoleRegion)
#endif
data OutputType = NormalOutput | QuietOutput | JSONOutput Bool
deriving (Show)
data SideActionBlock = NoBlock | StartBlock | InBlock
deriving (Eq)
data MessageState = MessageState
{ outputType :: OutputType
, concurrentOutputEnabled :: Bool
, sideActionBlock :: SideActionBlock
, implicitMessages :: Bool
2015-11-06 16:51:25 +00:00
#ifdef WITH_CONCURRENTOUTPUT
, consoleRegion :: Maybe ConsoleRegion
, consoleRegionErrFlag :: Bool
2015-11-06 16:51:25 +00:00
#endif
, jsonBuffer :: Maybe Aeson.Object
, promptLock :: MVar () -- left full when not prompting
}
newMessageState :: IO MessageState
newMessageState = do
promptlock <- newMVar ()
return $ MessageState
2015-11-06 16:51:25 +00:00
{ outputType = NormalOutput
, concurrentOutputEnabled = False
2015-11-06 16:51:25 +00:00
, sideActionBlock = NoBlock
, implicitMessages = True
2015-11-06 16:51:25 +00:00
#ifdef WITH_CONCURRENTOUTPUT
, consoleRegion = Nothing
, consoleRegionErrFlag = False
#endif
, jsonBuffer = Nothing
, promptLock = promptlock
2015-11-06 16:51:25 +00:00
}