gdritter repos bock / master color / unix / Logging / Bock / Color.hs
master

Tree @master (Download .tar.gz)

Color.hs @master

5f9886d
 
 
 
 
 
 
 
 
 
 
 
 
 
module Logging.Bock.Color (supportsColor) where

import qualified GHC.IO.Handle as IO
import qualified System.Posix.IO as Posix
import qualified System.Posix.Terminal as Posix

supportsColor :: IO.Handle -> IO Bool
supportsColor original = do
  -- we need to duplicate the handle before turning it into an FD as
  -- converting it to an FD will clone it, and that's... not what we
  -- want
  handle <- IO.hDuplicate original
  fd <- Posix.handleToFd handle
  Posix.queryTerminal fd