vty-4.7.0.20: A simple terminal UI library

Safe Haskell | Safe-Inferred

Graphics.Vty.Attributes

Synopsis

- data Attr = Attr {
  - attr_style :: !(MaybeDefault Style)
  - attr_fore_color :: !(MaybeDefault Color)
  - attr_back_color :: !(MaybeDefault Color)
  }
- data FixedAttr = FixedAttr {
  - fixed_style :: !Style
  - fixed_fore_color :: !(Maybe Color)
  - fixed_back_color :: !(Maybe Color)
  }
- data MaybeDefault v where
  - Default :: MaybeDefault v
  - KeepCurrent :: MaybeDefault v
  - SetTo :: forall v. (Eq v, Show v) => !v -> MaybeDefault v
- data Color
  - = ISOColor !Word8
  - | Color240 !Word8
- black :: Color
- white :: Color
- cyan :: Color
- magenta :: Color
- blue :: Color
- yellow :: Color
- green :: Color
- red :: Color
- bright_black :: Color
- bright_yellow :: Color
- bright_green :: Color
- bright_red :: Color
- bright_blue :: Color
- bright_white :: Color
- bright_cyan :: Color
- bright_magenta :: Color
- type Style = Word8
- standout :: Style
- bold :: Style
- dim :: Style
- blink :: Style
- reverse_video :: Style
- underline :: Style
- default_style_mask :: Style
- style_mask :: Attr -> Word8
- has_style :: Style -> Style -> Bool
- with_fore_color :: Attr -> Color -> Attr
- with_back_color :: Attr -> Color -> Attr
- with_style :: Attr -> Style -> Attr
- def_attr :: Attr
- current_attr :: Attr

# Documentation

data Attr Source

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.

Constructors

Attr |

Fields

attr_style :: !(MaybeDefault Style)
attr_fore_color :: !(MaybeDefault Color)
attr_back_color :: !(MaybeDefault Color)

Instances

Eq Attr |
Show Attr |
Monoid Attr |

data FixedAttr Source

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).

Constructors

FixedAttr |

Fields

fixed_style :: !Style
fixed_fore_color :: !(Maybe Color)
fixed_back_color :: !(Maybe Color)

Instances

Eq FixedAttr |
Show 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.

Constructors

Default :: MaybeDefault v |
KeepCurrent :: MaybeDefault v |
SetTo :: forall v. (Eq v, Show v) => !v -> MaybeDefault v |

Instances

Eq v => Eq (MaybeDefault v) |
Eq v => Show (MaybeDefault v) |
Eq v => Monoid (MaybeDefault v) |

data Color Source

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.

The 8 ISO 6429 (ANSI) colors are as follows:

1. black
2. red
3. green
4. yellow
5. blue
6. magenta
7. cyan
8. 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.

Constructors

ISOColor !Word8 |
Color240 !Word8 |

Instances

Eq Color |
Show Color |

black :: Color Source

Standard 8-color ANSI terminal color codes.

white :: Color Source

Standard 8-color ANSI terminal color codes.

cyan :: Color Source

Standard 8-color ANSI terminal color codes.

magenta :: Color Source

Standard 8-color ANSI terminal color codes.

blue :: Color Source

Standard 8-color ANSI terminal color codes.

yellow :: Color Source

Standard 8-color ANSI terminal color codes.

green :: Color Source

Standard 8-color ANSI terminal color codes.

red :: Color Source

Standard 8-color ANSI terminal color codes.

bright_black :: Color Source

Bright/Vivid variants of the standard 8-color ANSI

bright_yellow :: Color Source

Bright/Vivid variants of the standard 8-color ANSI

bright_green :: Color Source

Bright/Vivid variants of the standard 8-color ANSI

bright_red :: Color Source

Bright/Vivid variants of the standard 8-color ANSI

bright_blue :: Color Source

bright_white :: Color Source

bright_cyan :: Color Source

bright_magenta :: Color Source

type Style = Word8 Source

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.

standout :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

bold :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

dim :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

blink :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

reverse_video :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

underline :: Style Source

The 6 possible style attributes:

- standout
- underline
- reverse_video
- blink
- dim
- bold/bright

( The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)

default_style_mask :: Style Source

style_mask :: Attr -> Word8 Source

has_style :: Style -> Style -> Bool Source

true if the given Style value has the specified Style set.

with_fore_color :: Attr -> Color -> Attr Source

Set the foreground color of an `Attr`.

with_back_color :: Attr -> Color -> Attr Source

Set the background color of an `Attr`.

with_style :: Attr -> Style -> Attr Source

Add the given style attribute

def_attr :: Attr Source

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.

current_attr :: Attr Source

Keeps the style, background color and foreground color that was previously set. Used to override some part of the previous style.

EG: current_style `with_fore_color` bright_magenta

Would be the currently applied style (be it underline, bold, etc) but with the foreground color set to bright_magenta.