-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Types and functions used to represent SGR aspects
--   
--   The 'ANSI' standards refer to the visual style of displaying
--   characters as their 'graphic rendition'. The 'ANSI' codes to establish
--   the graphic rendition for subsequent text are referred to as SELECT
--   GRAPHIC RENDITION (SGR). This package exposes modules that export
--   types and functions used to represent SGR aspects.
@package ansi-terminal-types
@version 1.1.3

-- | 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.
module System.Console.ANSI.Types

-- | ANSI Select Graphic Rendition (SGR) command
--   
--   In respect of colors, there are three alternative commands:
--   
--   
--   
- 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;
--   
- 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
--   
- 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.
--   
data SGR

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

-- | Set the character intensity. Partially supported natively on Windows
--   10
SetConsoleIntensity :: !ConsoleIntensity -> SGR

-- | Set italicized. Not widely supported: sometimes treated as swapping
--   foreground and background. Not supported natively on Windows 10
SetItalicized :: !Bool -> SGR

-- | Set or clear underlining. Partially supported natively on Windows 10
SetUnderlining :: !Underlining -> SGR

-- | Set or clear character blinking. Not supported natively on Windows 10
SetBlinkSpeed :: !BlinkSpeed -> SGR

-- | Set revealed or concealed. Not widely supported. Not supported
--   natively on Windows 10
SetVisible :: !Bool -> SGR

-- | Set negative or positive image. Supported natively on Windows 10
SetSwapForegroundBackground :: !Bool -> SGR

-- | 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
SetColor :: !ConsoleLayer -> !ColorIntensity -> !Color -> SGR

-- | Set a true color (24 bit color depth). Supported natively on Windows
--   10 from the Creators Update (April 2017)
SetRGBColor :: !ConsoleLayer -> !Colour Float -> SGR

-- | 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.
SetPaletteColor :: !ConsoleLayer -> !Word8 -> SGR

-- | Set a color to the default (implementation-defined)
SetDefaultColor :: !ConsoleLayer -> SGR

-- | ANSI colors can be set on three different layers
data ConsoleLayer
Foreground :: ConsoleLayer
Background :: ConsoleLayer

-- | Not widely supported.
Underlining :: ConsoleLayer

-- | 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 Color
Black :: Color
Red :: Color
Green :: Color
Yellow :: Color
Blue :: Color
Magenta :: Color
Cyan :: Color
White :: Color

-- | ANSI's standard colors come in two intensities
data ColorIntensity
Dull :: ColorIntensity
Vivid :: ColorIntensity

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

-- | Not widely supported: sometimes treated as concealing text. Not
--   supported natively on Windows 10
FaintIntensity :: ConsoleIntensity
NormalIntensity :: ConsoleIntensity

-- | ANSI text underlining
data Underlining
SingleUnderline :: Underlining

-- | Not widely supported.
DoubleUnderline :: Underlining

-- | Not widely supported.
CurlyUnderline :: Underlining

-- | Not widely supported.
DottedUnderline :: Underlining

-- | Not widely supported.
DashedUnderline :: Underlining
NoUnderline :: Underlining

-- | ANSI blink speeds: values other than NoBlink are not widely
--   supported
data BlinkSpeed

-- | Less than 150 blinks per minute
SlowBlink :: BlinkSpeed

-- | More than 150 blinks per minute
RapidBlink :: BlinkSpeed
NoBlink :: BlinkSpeed

-- | 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
--   
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 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
--   
xterm24LevelGray :: Int -> 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:
--   
--   
--   >>> setSGR [ SetPaletteColor $ xtermSystem Vivid Green ]
--   
xtermSystem :: ColorIntensity -> Color -> Word8
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.BlinkSpeed
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.Color
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.ColorIntensity
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.ConsoleLayer
instance GHC.Internal.Enum.Bounded System.Console.ANSI.Types.Underlining
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.BlinkSpeed
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.Color
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.ColorIntensity
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.ConsoleLayer
instance GHC.Internal.Enum.Enum System.Console.ANSI.Types.Underlining
instance GHC.Classes.Eq System.Console.ANSI.Types.BlinkSpeed
instance GHC.Classes.Eq System.Console.ANSI.Types.Color
instance GHC.Classes.Eq System.Console.ANSI.Types.ColorIntensity
instance GHC.Classes.Eq System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Classes.Eq System.Console.ANSI.Types.ConsoleLayer
instance GHC.Classes.Eq System.Console.ANSI.Types.SGR
instance GHC.Classes.Eq System.Console.ANSI.Types.Underlining
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.BlinkSpeed
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.Color
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.ColorIntensity
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.ConsoleLayer
instance GHC.Internal.Ix.Ix System.Console.ANSI.Types.Underlining
instance GHC.Classes.Ord System.Console.ANSI.Types.BlinkSpeed
instance GHC.Classes.Ord System.Console.ANSI.Types.Color
instance GHC.Classes.Ord System.Console.ANSI.Types.ColorIntensity
instance GHC.Classes.Ord System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Classes.Ord System.Console.ANSI.Types.ConsoleLayer
instance GHC.Classes.Ord System.Console.ANSI.Types.Underlining
instance GHC.Internal.Read.Read System.Console.ANSI.Types.BlinkSpeed
instance GHC.Internal.Read.Read System.Console.ANSI.Types.Color
instance GHC.Internal.Read.Read System.Console.ANSI.Types.ColorIntensity
instance GHC.Internal.Read.Read System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Internal.Read.Read System.Console.ANSI.Types.ConsoleLayer
instance GHC.Internal.Read.Read System.Console.ANSI.Types.SGR
instance GHC.Internal.Read.Read System.Console.ANSI.Types.Underlining
instance GHC.Internal.Show.Show System.Console.ANSI.Types.BlinkSpeed
instance GHC.Internal.Show.Show System.Console.ANSI.Types.Color
instance GHC.Internal.Show.Show System.Console.ANSI.Types.ColorIntensity
instance GHC.Internal.Show.Show System.Console.ANSI.Types.ConsoleIntensity
instance GHC.Internal.Show.Show System.Console.ANSI.Types.ConsoleLayer
instance GHC.Internal.Show.Show System.Console.ANSI.Types.SGR
instance GHC.Internal.Show.Show System.Console.ANSI.Types.Underlining

-- | 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.
module System.Console.ANSI.Codes
cursorUpCode :: Int -> String
cursorDownCode :: Int -> String
cursorForwardCode :: Int -> String
cursorBackwardCode :: Int -> String
cursorUpLineCode :: Int -> String
cursorDownLineCode :: Int -> 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).
setCursorColumnCode :: Int -> 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).
setCursorPositionCode :: Int -> Int -> String

saveCursorCode :: String

restoreCursorCode :: String

-- | 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.
reportCursorPositionCode :: String
clearFromCursorToScreenEndCode :: String
clearFromCursorToScreenBeginningCode :: String
clearScreenCode :: String
clearFromCursorToLineEndCode :: String
clearFromCursorToLineBeginningCode :: String
clearLineCode :: String
enableLineWrapCode :: String
disableLineWrapCode :: String
scrollPageUpCode :: Int -> String
scrollPageDownCode :: Int -> String
useAlternateScreenBufferCode :: String
useNormalScreenBufferCode :: String

-- | Code to emit the foreground or backgrond 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.
--   
--   Underlining is not supported.
reportLayerColorCode :: ConsoleLayer -> String
setSGRCode :: [SGR] -> String
hideCursorCode :: String
showCursorCode :: String

-- | Code to introduce a hyperlink.
hyperlinkCode :: String -> String -> 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.
hyperlinkWithIdCode :: String -> String -> String -> 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.
hyperlinkWithParamsCode :: [(String, String)] -> String -> String -> 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).
setTitleCode :: String -> String

-- | colorToCode color returns the 0-based index of the
--   color (one of the eight colors in the ANSI standard).
colorToCode :: Color -> Int

-- | Type synonym representing parameter values (without parameter
--   substrings). To represent a paramater value followed by a parameter
--   substring, see ParamWithSubs.
type Parameter = Int

-- | Type synonym representing parameter elements of a parameter substring.
--   An empty parameter element (which represents a default value for the
--   parameter element) has value Nothing.
type SubParam = Maybe Int

-- | Type synonym representing parameter values optionally followed by a
--   parameter substring. Parameter substrings were introduced by 13.1.8 of
--   T.416 (03/93) for SGR parameter values 38 and 48 and have subsequently
--   been adapted for other uses.
type ParamWithSubs = (Parameter, [SubParam])

-- | 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. See csi' for a function that handles
--   parameter values that may be followed by a parameter substring.
csi :: [Parameter] -> String -> String

-- | Like csi but extended to parameters that may be followed by a
--   parameter substring. The parameter elements of a parameter substring
--   are separated from the parameter value and each other by ':'.
csi' :: [ParamWithSubs] -> String -> 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\\".
osc :: String -> String -> String

-- | sgrToCode sgr returns the parameter of the SELECT
--   GRAPHIC RENDITION (SGR) aspect identified by sgr. If the
--   parameter is followed by a parameter substring returns an empty list.
--   See sgrToCode' for a function that handles also parameter
--   values that are followed by a parameter substring.
sgrToCode :: SGR -> [Parameter]

-- | sgrToCode' sgr returns the parameter of the SELECT
--   GRAPHIC RENDITION (SGR) aspect identified by sgr.
sgrToCode' :: SGR -> Either ParamWithSubs [Parameter]
