calculator-0.2.2.1: src/Calculator/Color.hs
module Calculator.Color
( Color (..)
, color
, bold
) where
--------------------------------------------------------------------------------
data Color = Black | Red | Green | Yellow
| Blue | Magenta | Cyan | White
| Reset
deriving Enum
--------------------------------------------------------------------------------
color :: Color -> Bool -> String -> String
color c b s = let col = show (fromEnum c)
bol = if b then "1" else "22"
in "\ESC[" ++ bol ++ ";3" ++ col ++ "m" ++ s ++ "\ESC[0;m"
--------------------------------------------------------------------------------
bold :: String -> String
bold = color Reset True
--------------------------------------------------------------------------------