1{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveAnyClass #-}
4module Graphics.Vty.Attributes.Color
8 -- | Standard 8-color ANSI terminal color codes.
10 -- Note that these map to colors in the terminal's custom palette. For
11 -- instance, `white` maps to whatever the terminal color theme uses for
14 -- Use these functions if you want to make apps that fit the terminal theme.
15 -- If you want access to more/stronger colors use `rgbColor`
25 -- | Bright/Vivid variants of the standard 8-color ANSI
34 -- ** Creating Colors From RGB
36 , module Graphics.Vty.Attributes.Color240
44import Graphics.Vty.Attributes.Color240
46-- | Abstract data type representing a color.
48-- Currently the foreground and background color are specified as points
51-- * 16 color palette. Where the first 8 colors are equal to the 8
52-- colors of the ISO 6429 (ANSI) 8 color palette and the second 8
53-- colors are bright/vivid versions of the first 8 colors.
55-- * 240 color palette. This palette is a regular sampling of the full
56-- RGB colorspace for the first 224 colors. The remaining 16 colors is
57-- a greyscale palette.
59-- The 8 ISO 6429 (ANSI) colors are as follows:
77-- The mapping from points in the 240 color palette to colors actually
78-- displayable by the terminal depends on the number of colors the
79-- terminal claims to support. Which is usually determined by the
80-- terminfo "colors" property. If this property is not being accurately
81-- reported then the color reproduction will be incorrect.
83-- If the terminal reports <= 16 colors then the 240 color palette
84-- points are only mapped to the 8 color pallete. I'm not sure of
85-- the RGB points for the "bright" colors which is why they are not
86-- addressable via the 240 color palette.
88-- If the terminal reports > 16 colors then the 240 color palette
89-- points are mapped to the nearest points in a ("color count" - 16)
90-- subsampling of the 240 color palette.
92-- All of this assumes the terminals are behaving similarly to xterm and
93-- rxvt when handling colors. And that the individual colors have not
94-- been remapped by the user. There may be a way to verify this through
95-- terminfo but I don't know it.
97-- Seriously, terminal color support is INSANE.
98data Color = ISOColor !Word8 | Color240 !Word8
99 deriving ( Eq, Show, Read, Generic, NFData )
101black, red, green, yellow, blue, magenta, cyan, white :: Color
111brightBlack, brightRed, brightGreen, brightYellow :: Color
112brightBlue, brightMagenta, brightCyan, brightWhite :: Color
113brightBlack = ISOColor 8
114brightRed = ISOColor 9
115brightGreen = ISOColor 10
116brightYellow = ISOColor 11
117brightBlue = ISOColor 12
118brightMagenta= ISOColor 13
119brightCyan = ISOColor 14
120brightWhite = ISOColor 15
123-- | Create a Vty 'Color' (in the 240 color set) from an RGB triple.
124-- This function is lossy in the sense that we only internally support 240 colors but the
125-- #RRGGBB format supports 16^3 colors.
126rgbColor :: Integral i => i -> i -> i -> Color
127rgbColor r g b = Color240 (rgbColorToColor240 r g b)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list