GF.System.Console

Plain source file: src/compiler/GF/System/Console.hs (2015-03-03)

GF.System.Console is imported by: ...
{-# LANGUAGE CPP #-}
module GF.System.Console(
    -- ** Console IO
    -- *** Changing which character encoding to use for console IO
    setConsoleEncoding,changeConsoleEncoding,
    -- *** Console colors
    TermColors(..),getTermColors
) where
import System.IO
import Control.Monad(guard)
import Control.Monad.Trans(MonadIO(..))




import System.Console.Terminfo


-- | Set the console encoding (for Windows, has no effect on Unix-like systems)
setConsoleEncoding =





       return () :: IO ()

changeConsoleEncoding code =
    do



       setEncoding code

setEncoding code =
    do enc <- mkTextEncoding code
       hSetEncoding stdin  enc
       hSetEncoding stdout enc
       hSetEncoding stderr enc


data TermColors = TermColors { redFg,blueFg,restore :: String } deriving Show
noTermColors = TermColors "" "" ""

getTermColors :: MonadIO m => m TermColors
getTermColors =
    liftIO $
    do term <- setupTermFromEnv
       return $ maybe noTermColors id $ getCapability term $
         do n <- termColors
            guard (n>=8)
            fg <- setForegroundColor
            restore <- restoreDefaultColors
            return $ TermColors (fg Red) (fg Blue) restore

Index

(HTML for this module was generated on 2015-03-03. About the conversion tool.)