-- | Some utility functions for working with pretty console output.
module Futhark.Util.Console
  ( color,
    inRed,
    inGreen,
    inBold,
  )
where

import System.Console.ANSI

-- | Surround the given string with the given start/end colour codes.
color :: [SGR] -> String -> String
color :: [SGR] -> String -> String
color [SGR]
sgr String
s = [SGR] -> String
setSGRCode [SGR]
sgr String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ [SGR] -> String
setSGRCode [SGR
Reset]

-- | Make the string red.
inRed :: String -> String
inRed :: String -> String
inRed String
s = [SGR] -> String
setSGRCode [ConsoleLayer -> ColorIntensity -> Color -> SGR
SetColor ConsoleLayer
Foreground ColorIntensity
Vivid Color
Red] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ [SGR] -> String
setSGRCode [SGR
Reset]

-- | Make the string green.
inGreen :: String -> String
inGreen :: String -> String
inGreen String
s = [SGR] -> String
setSGRCode [ConsoleLayer -> ColorIntensity -> Color -> SGR
SetColor ConsoleLayer
Foreground ColorIntensity
Vivid Color
Red] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ [SGR] -> String
setSGRCode [SGR
Reset]

-- | Make the string bold.
inBold :: String -> String
inBold :: String -> String
inBold String
s = [SGR] -> String
setSGRCode [ConsoleIntensity -> SGR
SetConsoleIntensity ConsoleIntensity
BoldIntensity] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
s String -> String -> String
forall a. [a] -> [a] -> [a]
++ [SGR] -> String
setSGRCode [SGR
Reset]