Copyright | 2022 Dmitrii Kovanikov |
---|---|
License | MPL-2.0 |
Maintainer | Dmitrii Kovanikov <[email protected]> |
Stability | Experimental |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Iris.Colour.Mode
Contents
Description
The ColourMode
data type that allows disabling and enabling of
colouring.
Since: 0.0.0.0
Synopsis
- data ColourMode
- detectColourMode :: Handle -> ColourOption -> Maybe String -> IO ColourMode
- handleColourMode :: Handle -> IO ColourMode
Documentation
data ColourMode Source #
Data type that tells whether the colouring is enabled or
disabled. Its value is detected automatically on application start and
stored in CliEnv
.
Since: 0.0.0.0
Constructors
DisableColour | Since: 0.0.0.0 |
EnableColour | Since: 0.0.0.0 |
Instances
Arguments
:: Handle | A terminal handle (e.g. |
-> ColourOption | User settings |
-> Maybe String | Application name |
-> IO ColourMode |
This function performs a full check of the Handle
colouring support, env
variables and user-specified settings to detect whether the given handle
supports colouring.
Per CLI Guidelines, the algorithm for detecting the colouring support is the following:
__Disable color if your program is not in a terminal or the user requested it. These things should disable colors:__
stdout
orstderr
is not an interactive terminal (a TTY). It’s best to individually check—if you’re piping stdout to another program, it’s still useful to get colors on stderr.- The
NO_COLOR
environment variable is set. - The
TERM
environment variable has the valuedumb
. - The user passes the option
--no-color
. - You may also want to add a
MYAPP_NO_COLOR
environment variable in case users want to disable color specifically for your program.
ℹ️ Iris performs this check on the application start automatically so you don't need to call this function manually.
Since: 0.1.0.0
Internal
handleColourMode :: Handle -> IO ColourMode Source #
Returns ColourMode
of a Handle
ignoring environment and CLI options.
You can use this function on output Handle
s to find out whether they support
colouring or not.
Use a function like this to check whether you can print with colour to terminal:
handleColourMode
stdout
Since: 0.0.0.0