Community
Modules 2

System.Console.ANSI.Types

The 'ANSI' standards refer to the visual style of displaying characters as their 'graphic rendition'. The style includes the color of a character, its background, or (where supported) its underlining; the intensity (bold, normal or faint) of a character; or whether the character is italic or underlined (single, double, curly, dotted or dashed), blinking (slowly or rapidly) or visible or not. The 'ANSI' codes to establish the graphic rendition for subsequent text are referred to as SELECT GRAPHIC RENDITION (SGR).

This module exports types and functions used to represent SGR aspects. See also setSGR and related functions provided by the ansi-terminal package.

12 generation diagnostics
  • unattached documentation comment at 99:3
  • unattached documentation comment at 123:3
  • unattached documentation comment at 126:3
  • unattached documentation comment at 128:3
  • unattached documentation comment at 131:3
  • unattached documentation comment at 133:3
  • unattached documentation comment at 135:3
  • unattached documentation comment at 138:3
  • unattached documentation comment at 140:3
  • unattached documentation comment at 144:3
  • unattached documentation comment at 149:3
  • unattached documentation comment at 157:3

Types used to represent SGR aspects

data SGR

ANSI Select Graphic Rendition (SGR) command

In respect of colors, there are three alternative commands:

  1. the 'ANSI' standards allow for eight standard colors (with two intensities). Windows and many other terminals (including xterm) allow the user to redefine the standard colors (so, for example Vivid Green may not correspond to bright green;

  1. an extension of the standard that allows true colors (24 bit color depth) in RGB space. This is usually the best alternative for more colors; and

  1. another extension that allows a palette of 256 colors, each color specified by an index. Xterm provides a protocol for a palette of 256 colors that many other terminals, including Windows 10, follow. Some terminals (including xterm) allow the user to redefine some or all of the palette colors.

SetColor :: ConsoleLayer -> ColorIntensity -> Color -> SGR

data Color

ANSI's eight standard colors. They come in two intensities, which are controlled by ColorIntensity. Many terminals allow the colors of the standard palette to be customised, so that, for example, setSGR [ SetColor Foreground Vivid Green ] may not result in bright green characters.

data ColorIntensity

ANSI's standard colors come in two intensities

Dull :: ColorIntensity

Vivid :: ColorIntensity

data BlinkSpeed

ANSI blink speeds: values other than NoBlink are not widely supported

Constructors of xterm 256-color palette indices

xterm6LevelRGB :: Int -> Int -> Int -> Word8

Given xterm's standard protocol for a 256-color palette, returns the index to that part of the palette which is a 6 level (6x6x6) color cube of 216 RGB colors. Throws an error if any of the red, green or blue channels is outside the range 0 to 5. An example of use is:


xterm24LevelGray :: Int -> Word8

Given xterm's standard protocol for a 256-color palette, returns the index to that part of the palette which is a spectrum of 24 grays, from dark gray (0) to near white (23) (black and white are themselves excluded). Throws an error if the gray is outside of the range 0 to 23. An example of use is:


xtermSystem :: ColorIntensity -> Color -> Word8

Given xterm's standard protocol for a 256-color palette, returns the index to that part of the palette which corresponds to the 'ANSI' standards' 16 standard, or 'system', colors (eight colors in two intensities). An example of use is:


Instances

45
  • instance Bounded Color
  • instance Enum Color
  • instance Eq Color
  • instance Ix Color
  • instance Ord Color
  • instance Read Color
  • instance Show Color
  • instance Bounded ColorIntensity
  • instance Eq ColorIntensity
  • instance Enum ColorIntensity
  • instance Ix ColorIntensity
  • instance Ord ColorIntensity
  • instance Read ColorIntensity
  • instance Show ColorIntensity
  • instance Bounded ConsoleLayer
  • instance Eq ConsoleLayer
  • instance Enum ConsoleLayer
  • instance Ix ConsoleLayer
  • instance Ord ConsoleLayer
  • instance Read ConsoleLayer
  • instance Show ConsoleLayer
  • instance Bounded BlinkSpeed
  • instance Eq BlinkSpeed
  • instance Enum BlinkSpeed
  • instance Ix BlinkSpeed
  • instance Ord BlinkSpeed
  • instance Read BlinkSpeed
  • instance Show BlinkSpeed
  • instance Bounded Underlining
  • instance Eq Underlining
  • instance Enum Underlining
  • instance Ix Underlining
  • instance Ord Underlining
  • instance Read Underlining
  • instance Show Underlining
  • instance Bounded ConsoleIntensity
  • instance Eq ConsoleIntensity
  • instance Enum ConsoleIntensity
  • instance Ix ConsoleIntensity
  • instance Ord ConsoleIntensity
  • instance Read ConsoleIntensity
  • instance Show ConsoleIntensity
  • instance Eq SGR
  • instance Read SGR
  • instance Show SGR
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 12 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-aa6debbd-web-3

Metadata snapshot: 657daf55323efbace376e4c5ba45e174010a761423ed513e5feb28ad359b2638

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.