ansi-terminal-0.11.4: Simple ANSI terminal support, with Windows compatibility
Safe Haskell Safe
Language Haskell2010

System.Console.ANSI.Types

Description

The 'ANSI' standards refer to the visual style of displaying characters as their 'graphic rendition'. The style includes the color of a character or its background, the intensity (bold, normal or faint) of a character, or whether the character is italic or underlined (single or double), 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.

Synopsis

Types used to represent SGR aspects

data SGR Source #

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;
  2. 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
  3. 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.

Constructors

Reset

Default rendition, cancels the effect of any preceding occurrence of SGR (implementation-defined)

SetConsoleIntensity ! ConsoleIntensity

Set the character intensity. Partially supported natively on Windows 10

SetItalicized ! Bool

Set italicized. Not widely supported: sometimes treated as swapping foreground and background. Not supported natively on Windows 10

SetUnderlining ! Underlining

Set or clear underlining. Partially supported natively on Windows 10

SetBlinkSpeed ! BlinkSpeed

Set or clear character blinking. Not supported natively on Windows 10

SetVisible ! Bool

Set revealed or concealed. Not widely supported. Not supported natively on Windows 10

SetSwapForegroundBackground ! Bool

Set negative or positive image. Supported natively on Windows 10

SetColor ! ConsoleLayer ! ColorIntensity ! Color

Set a color from the standard palette of 16 colors (8 colors by 2 color intensities). Many terminals allow the palette colors to be customised

SetRGBColor ! ConsoleLayer !( Colour Float )

Set a true color (24 bit color depth). Supported natively on Windows 10 from the Creators Update (April 2017)

Since: 0.7

SetPaletteColor ! ConsoleLayer ! Word8

Set a color from a palette of 256 colors using a numerical index (0-based). Supported natively on Windows 10 from the Creators Update (April 2017) but not on legacy Windows native terminals. See xtermSystem , xterm6LevelRGB and xterm24LevelGray to construct indices based on xterm's standard protocol for a 256-color palette.

Since: 0.9

SetDefaultColor ! ConsoleLayer

Set a color to the default (implementation-defined)

Since: 0.10

data ConsoleLayer Source #

ANSI colors can be set on two different layers

Instances

Instances details
Bounded ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Enum ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Eq ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Ord ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Read ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Show ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

Ix ConsoleLayer Source #
Instance details

Defined in System.Console.ANSI.Types

data Color Source #

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.

Instances

Instances details
Bounded Color Source #
Instance details

Defined in System.Console.ANSI.Types

Enum Color Source #
Instance details

Defined in System.Console.ANSI.Types

Eq Color Source #
Instance details

Defined in System.Console.ANSI.Types

Ord Color Source #
Instance details

Defined in System.Console.ANSI.Types

Read Color Source #
Instance details

Defined in System.Console.ANSI.Types

Show Color Source #
Instance details

Defined in System.Console.ANSI.Types

Ix Color Source #
Instance details

Defined in System.Console.ANSI.Types

data ColorIntensity Source #

ANSI's standard colors come in two intensities

Constructors

Dull
Vivid

Instances

Instances details
Bounded ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Enum ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Eq ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Ord ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Read ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Show ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Ix ColorIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

data ConsoleIntensity Source #

ANSI general console intensity: usually treated as setting the font style (e.g. BoldIntensity causes text to be bold)

Constructors

BoldIntensity
FaintIntensity

Not widely supported: sometimes treated as concealing text. Not supported natively on Windows 10

NormalIntensity

Instances

Instances details
Bounded ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Enum ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Eq ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Ord ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Read ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Show ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

Ix ConsoleIntensity Source #
Instance details

Defined in System.Console.ANSI.Types

data Underlining Source #

ANSI text underlining

Constructors

SingleUnderline
DoubleUnderline

Not widely supported. Not supported natively on Windows 10

NoUnderline

Instances

Instances details
Bounded Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Enum Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Eq Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Ord Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Read Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Show Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

Ix Underlining Source #
Instance details

Defined in System.Console.ANSI.Types

data BlinkSpeed Source #

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

Constructors

SlowBlink

Less than 150 blinks per minute

RapidBlink

More than 150 blinks per minute

NoBlink

Instances

Instances details
Bounded BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Enum BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Eq BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Ord BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Read BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Show BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Ix BlinkSpeed Source #
Instance details

Defined in System.Console.ANSI.Types

Constructors of xterm 256-color palette indices

xterm6LevelRGB :: Int -> Int -> Int -> Word8 Source #

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:

>>> setSGR [ SetPaletteColor $ xterm6LevelRGB 5 2 0 ] -- Dark Orange

Since: 0.9

xterm24LevelGray :: Int -> Word8 Source #

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:

>>> setSGR [ SetPaletteColor $ xterm24LevelGray 12 ] -- Gray50

Since: 0.9

xtermSystem :: ColorIntensity -> Color -> Word8 Source #

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:

>>> setSGR [ SetPaletteColor $ xtermSystem Vivid Green ]

Since: 0.9