-- 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 <a>setSGR</a> and related functions provided by the
--   <tt>ansi-terminal</tt> package.
module System.Console.ANSI.Types

-- | ANSI Select Graphic Rendition (SGR) command
--   
--   In respect of colors, there are three alternative commands:
--   
--   <ol>
--   <li>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 <a>Vivid</a>
--   <a>Green</a> may not correspond to bright green;</li>
--   <li>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</li>
--   <li>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.</li>
--   </ol>
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
--   <a>xtermSystem</a>, <a>xterm6LevelRGB</a> and <a>xterm24LevelGray</a>
--   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 <a>ColorIntensity</a>. Many terminals allow the colors
--   of the standard palette to be customised, so that, for example,
--   <tt>setSGR [ SetColor Foreground Vivid Green ]</tt> 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. <a>BoldIntensity</a> 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 <a>NoBlink</a> 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:
--   
--   <pre>
--   &gt;&gt;&gt; setSGR [ SetPaletteColor $ xterm6LevelRGB 5 2 0 ] -- Dark Orange
--   </pre>
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:
--   
--   <pre>
--   &gt;&gt;&gt; setSGR [ SetPaletteColor $ xterm24LevelGray 12 ] -- Gray50
--   </pre>
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:
--   
--   <pre>
--   &gt;&gt;&gt; setSGR [ SetPaletteColor $ xtermSystem Vivid Green ]
--   </pre>
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 <a>String</a> values
--   containing codes in accordance with the 'ANSI' standards for control
--   character sequences described in the documentation of module
--   <a>System.Console.ANSI</a>.
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: <tt>ESC [
--   &lt;cursor row&gt; ; &lt;cursor column&gt; R</tt>
--   
--   Note that the information that is emitted is 1-based (the top-left
--   corner is at row 1 column 1) but <a>setCursorPositionCode</a> is
--   0-based.
--   
--   In isolation of <a>getReportedCursorPosition</a> or
--   <a>getCursorPosition</a>, 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:
--   
--   <pre>
--   ESC ] &lt;Ps&gt; ; rgb: &lt;red&gt; ; &lt;green&gt; ; &lt;blue&gt; &lt;ST&gt;
--   </pre>
--   
--   where <tt>&lt;Ps&gt;</tt> is <tt>10</tt> for <a>Foreground</a> and
--   <tt>11</tt> for <a>Background</a>; <tt>&lt;red&gt;</tt>,
--   <tt>&lt;green&gt;</tt> and <tt>&lt;blue&gt;</tt> are the color channel
--   values in hexadecimal (4, 8, 12 and 16 bit values are possible,
--   although 16 bit values are most common); and <tt>&lt;ST&gt;</tt> is
--   the STRING TERMINATOR (ST). ST depends on the terminal software and
--   may be the <tt>BEL</tt> character or <tt>ESC \</tt> 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 <a>getReportedLayerColor</a>.
--   
--   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 <tt>id</tt> parameter key, so that hyperlinks
--   with the same <tt>id</tt> 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

-- | <a>colorToCode</a> <tt>color</tt> 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 <a>ParamWithSubs</a>.
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 <a>Nothing</a>.
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])

-- | <a>csi</a> <tt>parameters controlFunction</tt>, where
--   <tt>parameters</tt> is a list of <a>Int</a>, returns the control
--   sequence comprising the control function CONTROL SEQUENCE INTRODUCER
--   (CSI) followed by the parameter(s) (separated by '<tt>;</tt>') and
--   ending with the <tt>controlFunction</tt> character(s) that identifies
--   the control function. See <a>csi'</a> for a function that handles
--   parameter values that may be followed by a parameter substring.
csi :: [Parameter] -> String -> String

-- | Like <a>csi</a> 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 '<tt>:</tt>'.
csi' :: [ParamWithSubs] -> String -> String

-- | <a>osc</a> <tt>parameterS parametersT</tt>, where <tt>parameterS</tt>
--   specifies the type of operation to perform and <tt>parametersT</tt> 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) <tt>"\ESC\\"</tt>.
osc :: String -> String -> String

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

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