module Skeletest.Internal.Utils.Color (
  green,
  red,
  yellow,
  gray,
) where

import Data.Colour.Names qualified as Color
import Data.Text (Text)
import Data.Text qualified as Text
import System.Console.ANSI qualified as ANSI

withANSI :: [ANSI.SGR] -> Text -> Text
withANSI :: [SGR] -> Text -> Text
withANSI [SGR]
codes Text
s = String -> Text
Text.pack ([SGR] -> String
ANSI.setSGRCode [SGR]
codes) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack ([SGR] -> String
ANSI.setSGRCode [SGR
ANSI.Reset])

green :: Text -> Text
green :: Text -> Text
green = [SGR] -> Text -> Text
withANSI [ConsoleLayer -> ColorIntensity -> Color -> SGR
ANSI.SetColor ConsoleLayer
ANSI.Foreground ColorIntensity
ANSI.Vivid Color
ANSI.Green]

red :: Text -> Text
red :: Text -> Text
red = [SGR] -> Text -> Text
withANSI [ConsoleLayer -> ColorIntensity -> Color -> SGR
ANSI.SetColor ConsoleLayer
ANSI.Foreground ColorIntensity
ANSI.Vivid Color
ANSI.Red]

yellow :: Text -> Text
yellow :: Text -> Text
yellow = [SGR] -> Text -> Text
withANSI [ConsoleLayer -> ColorIntensity -> Color -> SGR
ANSI.SetColor ConsoleLayer
ANSI.Foreground ColorIntensity
ANSI.Vivid Color
ANSI.Yellow]

gray :: Text -> Text
gray :: Text -> Text
gray = [SGR] -> Text -> Text
withANSI [ConsoleLayer -> Colour Float -> SGR
ANSI.SetRGBColor ConsoleLayer
ANSI.Foreground Colour Float
forall a. (Ord a, Floating a) => Colour a
Color.gray]