@@ -51,6 +51,7 @@ import Core.Program.Metadata
51
51
import Core.System.Base hiding (catch , throw )
52
52
import Core.Text.Rope
53
53
import Data.Foldable (foldrM )
54
+ import System.IO (hIsTerminalDevice )
54
55
import Data.Int (Int64 )
55
56
import Data.String (IsString )
56
57
import Prettyprinter (LayoutOptions (.. ), PageWidth (.. ), layoutPretty )
@@ -164,6 +165,7 @@ data Context τ = Context
164
165
{ -- runtime properties
165
166
programNameFrom :: MVar Rope
166
167
, terminalWidthFrom :: Int
168
+ , terminalColouredFrom :: Bool
167
169
, versionFrom :: Version
168
170
, -- only used during initial setup
169
171
initialConfigFrom :: Config
@@ -353,6 +355,7 @@ configure version t config = do
353
355
q <- newEmptyMVar
354
356
i <- newMVar start
355
357
columns <- getConsoleWidth
358
+ coloured <- getConsoleColoured
356
359
level <- newEmptyMVar
357
360
out <- newTQueueIO
358
361
tel <- newTQueueIO
@@ -364,6 +367,7 @@ configure version t config = do
364
367
$! Context
365
368
{ programNameFrom = n
366
369
, terminalWidthFrom = columns
370
+ , terminalColouredFrom = coloured
367
371
, versionFrom = version
368
372
, initialConfigFrom = config
369
373
, initialExportersFrom = []
@@ -392,7 +396,12 @@ getConsoleWidth = do
392
396
Nothing -> 80
393
397
return columns
394
398
395
- --
399
+
400
+ getConsoleColoured :: IO Bool
401
+ getConsoleColoured = do
402
+ terminal <- hIsTerminalDevice stdout
403
+ pure terminal
404
+
396
405
397
406
{- |
398
407
Process the command line options and arguments. If an invalid option is
0 commit comments