Safe Haskell | None |
---|---|
Language | Haskell2010 |
Display attributes
Typically the values defAttr
or currentAttr
are modified to form attributes:
defAttr withForeColor
red
Is the attribute that will set the foreground color to red and the background color to the default.
This can then be used to build an image wiht a red foreground like so:
string (defAttr withForeColor
red) "this text will be red"
The default attributes set by defAttr
have a presentation determined by the terminal. This is
not something VTY can control. The user is free to define the color scheme of the terminal as
they see fit. Up to the limits of the terminal anyways.
The value currentAttr
will keep the attributes of whatever was output previously.
todo This API is very verbose IMO. I'd like something more succinct.
- data Attr = Attr {
- attrStyle :: !(MaybeDefault Style)
- attrForeColor :: !(MaybeDefault Color)
- attrBackColor :: !(MaybeDefault Color)
- data FixedAttr = FixedAttr {
- fixedStyle :: !Style
- fixedForeColor :: !(Maybe Color)
- fixedBackColor :: !(Maybe Color)
- data MaybeDefault v where
- Default :: MaybeDefault v
- KeepCurrent :: MaybeDefault v
- SetTo :: forall v. (Eq v, Show v) => !v -> MaybeDefault v
- black :: Color
- white :: Color
- cyan :: Color
- magenta :: Color
- blue :: Color
- yellow :: Color
- green :: Color
- red :: Color
- brightBlack :: Color
- brightYellow :: Color
- brightGreen :: Color
- brightRed :: Color
- brightBlue :: Color
- brightWhite :: Color
- brightCyan :: Color
- brightMagenta :: Color
- type Style = Word8
- standout :: Style
- bold :: Style
- dim :: Style
- blink :: Style
- reverseVideo :: Style
- underline :: Style
- defaultStyleMask :: Style
- styleMask :: Attr -> Word8
- hasStyle :: Style -> Style -> Bool
- withForeColor :: Attr -> Color -> Attr
- withBackColor :: Attr -> Color -> Attr
- withStyle :: Attr -> Style -> Attr
- defAttr :: Attr
- currentAttr :: Attr
- data Color
- rgbColor :: Integral i => i -> i -> i -> Color
Documentation
A display attribute defines the Color and Style of all the characters rendered after the attribute is applied.
At most 256 colors, picked from a 240 and 16 color palette, are possible for the background and foreground. The 240 colors and 16 colors are points in different palettes. See Color for more information.
Attr | |
|
Specifies the display attributes such that the final style and color values do not depend on the previously applied display attribute. The display attributes can still depend on the terminal's default colors (unfortunately).
FixedAttr | |
|
data MaybeDefault v where Source
The style and color attributes can either be the terminal defaults. Or be equivalent to the previously applied style. Or be a specific value.
Default :: MaybeDefault v | |
KeepCurrent :: MaybeDefault v | |
SetTo :: forall v. (Eq v, Show v) => !v -> MaybeDefault v |
Eq v => Eq (MaybeDefault v) | |
Eq v => Show (MaybeDefault v) | |
Eq v => Monoid (MaybeDefault v) |
Bright/Vivid variants of the standard 8-color ANSI
Bright/Vivid variants of the standard 8-color ANSI
Bright/Vivid variants of the standard 8-color ANSI
Styles are represented as an 8 bit word. Each bit in the word is 1 if the style attribute assigned to that bit should be applied and 0 if the style attribute should not be applied.
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
The 6 possible style attributes:
standout
- underline
- reverseVideo
- blink
- dim
- bold/bright
( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)
Sets the style, background color and foreground color to the default values for the terminal. There is no easy way to determine what the default background and foreground colors are.
Keeps the style, background color and foreground color that was previously set. Used to override some part of the previous style.
EG: current_style withForeColor
brightMagenta
Would be the currently applied style (be it underline, bold, etc) but with the foreground color set to brightMagenta.
Abstract data type representing a color.
Currently the foreground and background color are specified as points in either a:
- 16 color palette. Where the first 8 colors are equal to the 8 colors of the ISO 6429 (ANSI) 8 color palette and the second 8 colors are bright/vivid versions of the first 8 colors.
- 240 color palette. This palette is a regular sampling of the full RGB colorspace for the first 224 colors. The remaining 16 colors is a greyscale palette.
The 8 ISO 6429 (ANSI) colors are as follows:
black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
The mapping from points in the 240 color palette to colors actually displayable by the terminal depends on the number of colors the terminal claims to support. Which is usually determined by the terminfo "colors" property. If this property is not being accurately reported then the color reproduction will be incorrect.
If the terminal reports <= 16 colors then the 240 color palette points are only mapped to the 8 color pallete. I'm not sure of the RGB points for the "bright" colors which is why they are not addressable via the 240 color palette.
If the terminal reports > 16 colors then the 240 color palette points are mapped to the nearest points in a ("color count" - 16) subsampling of the 240 color palette.
All of this assumes the terminals are behaving similarly to xterm and rxvt when handling colors. And that the individual colors have not been remapped by the user. There may be a way to verify this through terminfo but I don't know it.
Seriously, terminal color support is INSANE.