Skip to content
Snippets Groups Projects

Satisfy NO_COLOR requirements as per https://no-color.org

Merged Paolo Martini requested to merge mrtnpaolo/ghcup-hs:no-color into master
4 unresolved threads
Files
2
+ 28
11
@@ -44,6 +44,7 @@ import Data.Vector ( Vector
import Data.Versions hiding ( str )
import Haskus.Utils.Variant.Excepts
import Prelude hiding ( appendFile )
import System.Environment
import System.Exit
import System.IO.Unsafe
import URI.ByteString
@@ -250,19 +251,35 @@ app = App { appDraw = \st -> [ui st]
defaultAttributes :: AttrMap
defaultAttributes = attrMap
Vty.defAttr
[ ("active" , Vty.defAttr `Vty.withBackColor` Vty.blue)
, ("not-installed", Vty.defAttr `Vty.withForeColor` Vty.red)
, ("set" , Vty.defAttr `Vty.withForeColor` Vty.green)
, ("installed" , Vty.defAttr `Vty.withForeColor` Vty.green)
, ("recommended" , Vty.defAttr `Vty.withForeColor` Vty.green)
, ("hls-powered" , Vty.defAttr `Vty.withForeColor` Vty.green)
, ("latest" , Vty.defAttr `Vty.withForeColor` Vty.yellow)
, ("prerelease" , Vty.defAttr `Vty.withForeColor` Vty.red)
, ("compiled" , Vty.defAttr `Vty.withForeColor` Vty.blue)
, ("stray" , Vty.defAttr `Vty.withForeColor` Vty.blue)
[ ("active" , Vty.defAttr `withBackColor` Vty.blue)
, ("not-installed", Vty.defAttr `withForeColor` Vty.red)
, ("set" , Vty.defAttr `withForeColor` Vty.green)
, ("installed" , Vty.defAttr `withForeColor` Vty.green)
, ("recommended" , Vty.defAttr `withForeColor` Vty.green)
, ("hls-powered" , Vty.defAttr `withForeColor` Vty.green)
, ("latest" , Vty.defAttr `withForeColor` Vty.yellow)
, ("prerelease" , Vty.defAttr `withForeColor` Vty.red)
, ("compiled" , Vty.defAttr `withForeColor` Vty.blue)
, ("stray" , Vty.defAttr `withForeColor` Vty.blue)
, ("help" , Vty.defAttr `Vty.withStyle` Vty.italic)
, ("hooray" , Vty.defAttr `Vty.withForeColor` Vty.brightWhite)
, ("hooray" , Vty.defAttr `withForeColor` Vty.brightWhite)
]
where
withForeColor :: Vty.Attr -> Vty.Color -> Vty.Attr
{-# NOINLINE withForeColor #-}
withForeColor = unsafePerformIO $ do
Please register or sign in to reply
x <- lookupEnv "NO_COLOR"
pure $ case x of
Nothing -> Vty.withForeColor
Just _ -> const
withBackColor :: Vty.Attr -> Vty.Color -> Vty.Attr
{-# NOINLINE withBackColor #-}
withBackColor = unsafePerformIO $ do
x <- lookupEnv "NO_COLOR"
pure $ case x of
Nothing -> Vty.withBackColor
Just _ -> \attr _ -> attr `Vty.withStyle` Vty.reverseVideo
dimAttributes :: AttrMap
Loading