ansi-terminal-1.0.2: Simple ANSI terminal support
Safe HaskellSafe
LanguageHaskell2010

System.Console.ANSI.Codes

Description

This module exports functions that return String values containing codes in accordance with the 'ANSI' standards for control character sequences described in the documentation of module System.Console.ANSI.

Synopsis

Basic data types

data ConsoleLayer #

Constructors

Foreground 
Background 

Instances

Instances details
Bounded ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Enum ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Ix ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Read ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS ConsoleLayer

readList :: ReadS [ConsoleLayer]

readPrec :: ReadPrec ConsoleLayer

readListPrec :: ReadPrec [ConsoleLayer]

Show ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> ConsoleLayer -> ShowS

show :: ConsoleLayer -> String

showList :: [ConsoleLayer] -> ShowS

Eq ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

Methods

(==) :: ConsoleLayer -> ConsoleLayer -> Bool

(/=) :: ConsoleLayer -> ConsoleLayer -> Bool

Ord ConsoleLayer 
Instance details

Defined in System.Console.ANSI.Types

data Color #

Constructors

Black 
Red 
Green 
Yellow 
Blue 
Magenta 
Cyan 
White 

Instances

Instances details
Bounded Color 
Instance details

Defined in System.Console.ANSI.Types

Enum Color 
Instance details

Defined in System.Console.ANSI.Types

Ix Color 
Instance details

Defined in System.Console.ANSI.Types

Methods

range :: (Color, Color) -> [Color]

index :: (Color, Color) -> Color -> Int

unsafeIndex :: (Color, Color) -> Color -> Int

inRange :: (Color, Color) -> Color -> Bool

rangeSize :: (Color, Color) -> Int

unsafeRangeSize :: (Color, Color) -> Int

Read Color 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS Color

readList :: ReadS [Color]

readPrec :: ReadPrec Color

readListPrec :: ReadPrec [Color]

Show Color 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> Color -> ShowS

show :: Color -> String

showList :: [Color] -> ShowS

Eq Color 
Instance details

Defined in System.Console.ANSI.Types

Methods

(==) :: Color -> Color -> Bool

(/=) :: Color -> Color -> Bool

Ord Color 
Instance details

Defined in System.Console.ANSI.Types

Methods

compare :: Color -> Color -> Ordering

(<) :: Color -> Color -> Bool

(<=) :: Color -> Color -> Bool

(>) :: Color -> Color -> Bool

(>=) :: Color -> Color -> Bool

max :: Color -> Color -> Color

min :: Color -> Color -> Color

data SGR #

Instances

Instances details
Read SGR 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS SGR

readList :: ReadS [SGR]

readPrec :: ReadPrec SGR

readListPrec :: ReadPrec [SGR]

Show SGR 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> SGR -> ShowS

show :: SGR -> String

showList :: [SGR] -> ShowS

Eq SGR 
Instance details

Defined in System.Console.ANSI.Types

Methods

(==) :: SGR -> SGR -> Bool

(/=) :: SGR -> SGR -> Bool

data ConsoleIntensity #

Instances

Instances details
Bounded ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Enum ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Ix ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Read ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Show ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> ConsoleIntensity -> ShowS

show :: ConsoleIntensity -> String

showList :: [ConsoleIntensity] -> ShowS

Eq ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

Ord ConsoleIntensity 
Instance details

Defined in System.Console.ANSI.Types

data Underlining #

Instances

Instances details
Bounded Underlining 
Instance details

Defined in System.Console.ANSI.Types

Enum Underlining 
Instance details

Defined in System.Console.ANSI.Types

Ix Underlining 
Instance details

Defined in System.Console.ANSI.Types

Read Underlining 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS Underlining

readList :: ReadS [Underlining]

readPrec :: ReadPrec Underlining

readListPrec :: ReadPrec [Underlining]

Show Underlining 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> Underlining -> ShowS

show :: Underlining -> String

showList :: [Underlining] -> ShowS

Eq Underlining 
Instance details

Defined in System.Console.ANSI.Types

Methods

(==) :: Underlining -> Underlining -> Bool

(/=) :: Underlining -> Underlining -> Bool

Ord Underlining 
Instance details

Defined in System.Console.ANSI.Types

data BlinkSpeed #

Constructors

SlowBlink 
RapidBlink 
NoBlink 

Instances

Instances details
Bounded BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Enum BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Ix BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Read BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS BlinkSpeed

readList :: ReadS [BlinkSpeed]

readPrec :: ReadPrec BlinkSpeed

readListPrec :: ReadPrec [BlinkSpeed]

Show BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> BlinkSpeed -> ShowS

show :: BlinkSpeed -> String

showList :: [BlinkSpeed] -> ShowS

Eq BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

Methods

(==) :: BlinkSpeed -> BlinkSpeed -> Bool

(/=) :: BlinkSpeed -> BlinkSpeed -> Bool

Ord BlinkSpeed 
Instance details

Defined in System.Console.ANSI.Types

data ColorIntensity #

Constructors

Dull 
Vivid 

Instances

Instances details
Bounded ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Enum ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Ix ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Read ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Methods

readsPrec :: Int -> ReadS ColorIntensity

readList :: ReadS [ColorIntensity]

readPrec :: ReadPrec ColorIntensity

readListPrec :: ReadPrec [ColorIntensity]

Show ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Methods

showsPrec :: Int -> ColorIntensity -> ShowS

show :: ColorIntensity -> String

showList :: [ColorIntensity] -> ShowS

Eq ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

Ord ColorIntensity 
Instance details

Defined in System.Console.ANSI.Types

xterm24LevelGray :: Int -> Word8 #

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

Cursor movement by character

These functions yield "" when the number is 0 as, on some terminals, a 0 parameter for the underlying 'ANSI' code specifies a default parameter of 1.

cursorUpCode Source #

Arguments

:: Int

Number of lines or characters to move

-> String 

cursorDownCode Source #

Arguments

:: Int

Number of lines or characters to move

-> String 

cursorForwardCode Source #

Arguments

:: Int

Number of lines or characters to move

-> String 

cursorBackwardCode Source #

Arguments

:: Int

Number of lines or characters to move

-> String 

Cursor movement by line

These functions yield the equivalent of setCursorColumnCode 0 when the number is 0 as, on some terminals, a 0 parameter for the underlying 'ANSI' code specifies a default parameter of 1.

cursorUpLineCode Source #

Arguments

:: Int

Number of lines to move

-> String 

cursorDownLineCode Source #

Arguments

:: Int

Number of lines to move

-> String 

Directly changing cursor position

setCursorColumnCode Source #

Arguments

:: Int

0-based column to move to

-> String 

Code to move the cursor to the specified column. The column numbering is 0-based (that is, the left-most column is numbered 0).

setCursorPositionCode Source #

Arguments

:: Int

0-based row to move to

-> Int

0-based column to move to

-> String 

Code to move the cursor to the specified position (row and column). The position is 0-based (that is, the top-left corner is at row 0 column 0).

Saving, restoring and reporting cursor position

saveCursorCode :: String Source #

Since: 0.7.1

restoreCursorCode :: String Source #

Since: 0.7.1

reportCursorPositionCode :: String Source #

Code to emit the cursor position into the console input stream, immediately after being recognised on the output stream, as: ESC [ <cursor row> ; <cursor column> R

Note that the information that is emitted is 1-based (the top-left corner is at row 1 column 1) but setCursorPositionCode is 0-based.

In isolation of getReportedCursorPosition or getCursorPosition, this function may be of limited use on Windows operating systems because of difficulties in obtaining the data emitted into the console input stream.

Since: 0.7.1

Clearing parts of the screen

Scrolling the screen

These functions yield "" when the number is 0 as, on some terminals, a 0 parameter for the underlying 'ANSI' code specifies a default parameter of 1.

scrollPageUpCode Source #

Arguments

:: Int

Number of lines to scroll by

-> String 

scrollPageDownCode Source #

Arguments

:: Int

Number of lines to scroll by

-> String 

Using screen buffers

Reporting background or foreground colors

reportLayerColorCode :: ConsoleLayer -> String Source #

Code to emit the layer color into the console input stream, immediately after being recognised on the output stream, as: ESC ] <Ps> ; rgb: <red> ; <green> ; <blue> <ST> where <Ps> is 10 for Foreground and 11 for Background; <red>, <green> and <blue> are the color channel values in hexadecimal (4, 8, 12 and 16 bit values are possible, although 16 bit values are most common); and <ST> is the STRING TERMINATOR (ST). ST depends on the terminal software and may be the BEL character or ESC \ characters.

This function may be of limited, or no, use on Windows operating systems because (1) the control character sequence is not supported on native terminals (2) of difficulties in obtaining the data emitted into the console input stream. See getReportedLayerColor.

Since: 0.11.4

Select Graphic Rendition mode: colors and other whizzy stuff

setSGRCode Source #

Arguments

:: [SGR]

Commands: these will typically be applied on top of the current console SGR mode. An empty list of commands is equivalent to the list [Reset]. Commands are applied left to right.

-> String 

Cursor visibilty changes

Hyperlinks

Some, but not all, terminals support hyperlinks - that is, clickable text that points to a URI.

hyperlinkCode Source #

Arguments

:: String

URI

-> String

Link text

-> String 

Code to introduce a hyperlink.

Since: 0.11.3

hyperlinkWithIdCode Source #

Arguments

:: String

Identifier for the link

-> String

URI

-> String

Link text

-> String 

Code to introduce a hyperlink with an identifier for the link. Some terminals support an identifier, so that hyperlinks with the same identifier are treated as connected.

Since: 0.11.3

hyperlinkWithParamsCode Source #

Arguments

:: [(String, String)]

Parameters

-> String

URI

-> String

Link text

-> String 

Code to introduce a hyperlink with (key, value) parameters. Some terminals support an id parameter key, so that hyperlinks with the same id value are treated as connected.

Since: 0.11.3

Changing the title

setTitleCode Source #

Arguments

:: String

New window title and icon name

-> String 

Code to set the terminal window title and the icon name (that is, the text for the window in the Start bar, or similar).

Utilities

colorToCode :: Color -> Int Source #

colorToCode color returns the 0-based index of the color (one of the eight colors in the ANSI standard).

csi Source #

Arguments

:: [Int]

List of parameters for the control sequence

-> String

Character(s) that identify the control function

-> String 

csi parameters controlFunction, where parameters is a list of Int, returns the control sequence comprising the control function CONTROL SEQUENCE INTRODUCER (CSI) followed by the parameter(s) (separated by ';') and ending with the controlFunction character(s) that identifies the control function.

osc Source #

Arguments

:: String

Ps parameter

-> String

Pt parameter(s)

-> String 

osc parameterS parametersT, where parameterS specifies the type of operation to perform and parametersT is the other parameter(s) (if any), returns the control sequence comprising the control function OPERATING SYSTEM COMMAND (OSC) followed by the parameters (separated by ';') and ending with the STRING TERMINATOR (ST) "\ESC\\".

Since: 0.11.4

sgrToCode Source #

Arguments

:: SGR

The SGR aspect

-> [Int] 

sgrToCode sgr returns the parameter of the SELECT GRAPHIC RENDITION (SGR) aspect identified by sgr.