packages feed

escape-artist-1.1.0: test/VisualTest.hs

{-# LANGUAGE ExtendedDefaultRules, NoMonomorphismRestriction #-}

import Data.Monoid ((<>))
import Text.EscapeArtist
import Data.List (intersperse)
-- import Text.Regex

main = do
    putStrLn "Foreground Colors"
    putStrLn "================="
    putEscLn $ BgWhite $ FgBlack   "Foreground should be black"
    putEscLn $ BgWhite $ FgRed     "Foreground should be red"
    putEscLn $ BgWhite $ FgGreen   "Foreground should be green"
    putEscLn $ BgWhite $ FgYellow  "Foreground should be yellow"
    putEscLn $ BgWhite $ FgBlue    "Foreground should be blue"
    putEscLn $ BgWhite $ FgMagenta "Foreground should be magenta"
    putEscLn $ BgWhite $ FgCyan    "Foreground should be cyan"
    putEscLn $ BgBlack $ FgWhite   "Foreground should be white"
    putStrLn ""
    putStrLn "Background Colors"
    putStrLn "================="
    putEscLn $ BgBlack   $ FgWhite "Background should be black"
    putEscLn $ BgRed     $ FgBlack "Background should be red"
    putEscLn $ BgGreen   $ FgBlack "Background should be green"
    putEscLn $ BgYellow  $ FgBlack "Background should be yellow"
    putEscLn $ BgBlue    $ FgBlack "Background should be blue"
    putEscLn $ BgMagenta $ FgBlack "Background should be magenta"
    putEscLn $ BgCyan    $ FgBlack "Background should be cyan"
    putEscLn $ BgWhite   $ FgBlack "Background should be white"
    putStrLn ""
    putStrLn "FgDefault Colors"
    putStrLn "=============="
    putEscLn $ FgRed "-->" <> FgDefault   "Foreground should be the default of the terminal" <> FgRed "<--"
    putEscLn $ (BgBlue $ FgWhite "-->") <> BgDefault "Background should be the default of the terminal" <> (BgBlue $ FgWhite "<--")
    putStrLn ""
    putStrLn "Inherit"
    putStrLn "========="
    putEscLn $ Underline $ BgWhite $ FgBlue $ ((UnderlineOff $ BgBlack $ FgWhite "-->") <> Inherit "This should be underlined, white background and blue foreground" <> (UnderlineOff $ BgBlack $ FgWhite "<---"))
    putStrLn ""
    putStrLn "Default"
    putStrLn "========="
    putEscLn $ Underline $ BgWhite $ FgBlue $ (Inherit "-->" <> Default "This should not have any attributes except for those from the terminal" <> Inherit "<---")
    putStrLn ""
    putStrLn "Blink and Blink Off"
    putStrLn "====================="
    putEscLn $ FgRed "This should not be blinking" <> Default " " <> Blink ^$ FgRed "This should be blinking"
    putEscLn $ Blink $ FgBlue $ BlinkOff "This should be not blinking from blink off" <> Default " " <> Inherit "This should be blinking"
    putStrLn ""
    putStrLn "Bright and Bright Off"
    putStrLn "====================="
    putEscLn $ FgRed "This should be dim" <> Inherit " " <> Bright ^$ FgRed "This should be bright"
    putEscLn $ Bright $ FgBlue $ BrightOff "This should be dim from bright off" <> Inherit " This should be bright"
    putStrLn ""
    putStrLn "Underline and Underline Off"
    putStrLn "==========================="
    putEscLn $ FgRed "This should not be underlined" <> Inherit " " <> Underline ^$ FgRed "This should be underlined"
    putEscLn $ Underline $ FgBlue $ UnderlineOff "This should not be underlined from underline off" <> Default " " <> Inherit "This should be underlined"
    putStrLn ""
    putStrLn "Inverse and Inverse Off"
    putStrLn "==========================="
    putEscLn $ FgRed "This should be inverse" <> Default " " <> Inverse ^$ FgRed "This should be inverse"
    putEscLn $ Inverse $ FgBlue $ InverseOff "This should not be inverse from inverse off" <> Default " " <> Inherit "This should be inverse"