System.Console.ANSI

ansi-terminal-0.6.2.3: Simple ANSI terminal support, with Windows compatibility

Safe Haskell | Safe
Language | Haskell98

System.Console.ANSI

Contents

- Basic data types
- Cursor movement by character
- Cursor movement by line
- Directly changing cursor position
- Clearing parts of the screen
- Scrolling the screen
- Select Graphic Rendition mode: colors and other whizzy stuff
- Cursor visibilty changes
- Changing the title
- Checking if handle supports ANSI

Description

Provides ANSI terminal support for Windows and ANSI terminal software running on a Unix-like operating system.

The ANSI escape codes are described at http://en.wikipedia.org/wiki/ANSI_escape_code and provide a rich range of functionality for terminal control, which includes:

- Colored text output, with control over both foreground and background colors
- Hiding or showing the cursor
- Moving the cursor around
- Clearing parts of the screen

The most frequently used parts of this ANSI command set are exposed with a platform independent interface by this module. Every function exported comes in three flavours:

- Vanilla: has an `IO ()` type and doesn't take a `Handle`. This just outputs the ANSI command directly on to the terminal corresponding to stdout. Commands issued like this should work as you expect on both Windows and Unix.
- Chocolate: has an `IO ()` type but takes a `Handle`. This outputs the ANSI command on the terminal corresponding to the supplied handle. Commands issued like this should also work as your expect on both Windows and Unix.
- Strawberry: has a `String` type and just consists of an escape code which can be added to any other bit of text before being output. This version of the API is often convenient to use, but due to fundamental limitations in Windows ANSI terminal support will only work on Unix. On Windows these codes will always be the empty string, so it is possible to use them portably for e.g. coloring console output on the understanding that you will only see colors if you are running on a Unix-like operating system.

Example:

    -- Set colors and write some text in those colors.
    sgrExample :: IO ()
    sgrExample = do
        setSGR [SetColor Foreground Vivid Red]
        setSGR [SetColor Background Vivid Blue]
        putStr "Red-On-Blue"
        setSGR [Reset]
        putStr "White-On-Black"

For many more examples, see the project's extensive Example.hs file.

Synopsis

- data Color
  - = Black
  - | Red
  - | Green
  - | Yellow
  - | Blue
  - | Magenta
  - | Cyan
  - | White
- data ColorIntensity
  - = Dull
  - | Vivid
- data ConsoleLayer
  - = Foreground
  - | Background
- data BlinkSpeed
  - = SlowBlink
  - | RapidBlink
  - | NoBlink
- data Underlining
  - = SingleUnderline
  - | DoubleUnderline
  - | NoUnderline
- data ConsoleIntensity
  - = BoldIntensity
  - | FaintIntensity
  - | NormalIntensity
- data SGR
  - = Reset
  - | SetConsoleIntensity ConsoleIntensity
  - | SetItalicized Bool
  - | SetUnderlining Underlining
  - | SetBlinkSpeed BlinkSpeed
  - | SetVisible Bool
  - | SetSwapForegroundBackground Bool
  - | SetColor ConsoleLayer ColorIntensity Color
- cursorUp :: Int -> IO ()
- cursorDown :: Int -> IO ()
- cursorForward :: Int -> IO ()
- cursorBackward :: Int -> IO ()
- hCursorUp :: Handle -> Int -> IO ()
- hCursorDown :: Handle -> Int -> IO ()
- hCursorForward :: Handle -> Int -> IO ()
- hCursorBackward :: Handle -> Int -> IO ()
- cursorUpCode :: Int -> String
- cursorDownCode :: Int -> String
- cursorForwardCode :: Int -> String
- cursorBackwardCode :: Int -> String
- cursorUpLine :: Int -> IO ()
- cursorDownLine :: Int -> IO ()
- hCursorUpLine :: Handle -> Int -> IO ()
- hCursorDownLine :: Handle -> Int -> IO ()
- cursorUpLineCode :: Int -> String
- cursorDownLineCode :: Int -> String
- setCursorColumn :: Int -> IO ()
- hSetCursorColumn :: Handle -> Int -> IO ()
- setCursorColumnCode :: Int -> String
- setCursorPosition :: Int -> Int -> IO ()
- hSetCursorPosition :: Handle -> Int -> Int -> IO ()
- setCursorPositionCode :: Int -> Int -> String
- clearFromCursorToScreenEnd :: IO ()
- clearFromCursorToScreenBeginning :: IO ()
- clearScreen :: IO ()
- hClearFromCursorToScreenEnd :: Handle -> IO ()
- hClearFromCursorToScreenBeginning :: Handle -> IO ()
- hClearScreen :: Handle -> IO ()
- clearFromCursorToScreenEndCode :: String
- clearFromCursorToScreenBeginningCode :: String
- clearScreenCode :: String
- clearFromCursorToLineEnd :: IO ()
- clearFromCursorToLineBeginning :: IO ()
- clearLine :: IO ()
- hClearFromCursorToLineEnd :: Handle -> IO ()
- hClearFromCursorToLineBeginning :: Handle -> IO ()
- hClearLine :: Handle -> IO ()
- clearFromCursorToLineEndCode :: String
- clearFromCursorToLineBeginningCode :: String
- clearLineCode :: String
- scrollPageUp :: Int -> IO ()
- scrollPageDown :: Int -> IO ()
- hScrollPageUp :: Handle -> Int -> IO ()
- hScrollPageDown :: Handle -> Int -> IO ()
- scrollPageUpCode :: Int -> String
- scrollPageDownCode :: Int -> String
- setSGR :: [SGR] -> IO ()
- hSetSGR :: Handle -> [SGR] -> IO ()
- setSGRCode :: [SGR] -> String
- hideCursor :: IO ()
- showCursor :: IO ()
- hHideCursor :: Handle -> IO ()
- hShowCursor :: Handle -> IO ()
- hideCursorCode :: String
- showCursorCode :: String
- setTitle :: String -> IO ()
- hSetTitle :: Handle -> String -> IO ()
- setTitleCode :: String -> String
- hSupportsANSI :: Handle -> IO Bool

# Basic data types

data Color #

ANSI colors: come in various intensities, which are controlled by `ColorIntensity`

Constructors

Black |
Red |
Green |
Yellow |
Blue |
Magenta |
Cyan |
White |

Instances

Bounded Color # |
Methods minBound :: Color # maxBound :: Color #
Enum Color # |
Methods succ :: Color -> Color # pred :: Color -> Color # toEnum :: Int -> Color # fromEnum :: Color -> Int # enumFrom :: Color -> [Color] # enumFromThen :: Color -> Color -> [Color] # enumFromTo :: Color -> Color -> [Color] # enumFromThenTo :: Color -> Color -> Color -> [Color] #
Eq Color # |
Methods (==) :: Color -> Color -> Bool # (/=) :: Color -> Color -> Bool #
Ord Color # |
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 #
Read Color # |
Methods readsPrec :: Int -> ReadS Color # readList :: ReadS [Color] # readPrec :: ReadPrec Color # readListPrec :: ReadPrec [Color] #
Show Color # |
Methods showsPrec :: Int -> Color -> ShowS # show :: Color -> String # showList :: [Color] -> ShowS #
Ix Color # |
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

data ColorIntensity #

ANSI colors come in two intensities

Constructors

Dull |
Vivid |

Instances

Bounded ColorIntensity # |
Methods minBound :: ColorIntensity # maxBound :: ColorIntensity #
Enum ColorIntensity # |
Methods succ :: ColorIntensity -> ColorIntensity # pred :: ColorIntensity -> ColorIntensity # toEnum :: Int -> ColorIntensity # fromEnum :: ColorIntensity -> Int # enumFrom :: ColorIntensity -> [ColorIntensity] # enumFromThen :: ColorIntensity -> ColorIntensity -> [ColorIntensity] # enumFromTo :: ColorIntensity -> ColorIntensity -> [ColorIntensity] # enumFromThenTo :: ColorIntensity -> ColorIntensity -> ColorIntensity -> [ColorIntensity] #
Eq ColorIntensity # |
Methods (==) :: ColorIntensity -> ColorIntensity -> Bool # (/=) :: ColorIntensity -> ColorIntensity -> Bool #
Ord ColorIntensity # |
Methods compare :: ColorIntensity -> ColorIntensity -> Ordering # (<) :: ColorIntensity -> ColorIntensity -> Bool # (<=) :: ColorIntensity -> ColorIntensity -> Bool # (>) :: ColorIntensity -> ColorIntensity -> Bool # (>=) :: ColorIntensity -> ColorIntensity -> Bool # max :: ColorIntensity -> ColorIntensity -> ColorIntensity # min :: ColorIntensity -> ColorIntensity -> ColorIntensity #
Read ColorIntensity # |
Methods readsPrec :: Int -> ReadS ColorIntensity # readList :: ReadS [ColorIntensity] # readPrec :: ReadPrec ColorIntensity # readListPrec :: ReadPrec [ColorIntensity] #
Show ColorIntensity # |
Methods showsPrec :: Int -> ColorIntensity -> ShowS # show :: ColorIntensity -> String # showList :: [ColorIntensity] -> ShowS #
Ix ColorIntensity # |
Methods range :: (ColorIntensity, ColorIntensity) -> [ColorIntensity] # index :: (ColorIntensity, ColorIntensity) -> ColorIntensity -> Int # unsafeIndex :: (ColorIntensity, ColorIntensity) -> ColorIntensity -> Int inRange :: (ColorIntensity, ColorIntensity) -> ColorIntensity -> Bool # rangeSize :: (ColorIntensity, ColorIntensity) -> Int # unsafeRangeSize :: (ColorIntensity, ColorIntensity) -> Int

data ConsoleLayer #

ANSI colors can be set on two different layers

Constructors

Foreground |
Background |

Instances

Bounded ConsoleLayer # |
Methods minBound :: ConsoleLayer # maxBound :: ConsoleLayer #
Enum ConsoleLayer # |
Methods succ :: ConsoleLayer -> ConsoleLayer # pred :: ConsoleLayer -> ConsoleLayer # toEnum :: Int -> ConsoleLayer # fromEnum :: ConsoleLayer -> Int # enumFrom :: ConsoleLayer -> [ConsoleLayer] # enumFromThen :: ConsoleLayer -> ConsoleLayer -> [ConsoleLayer] # enumFromTo :: ConsoleLayer -> ConsoleLayer -> [ConsoleLayer] # enumFromThenTo :: ConsoleLayer -> ConsoleLayer -> ConsoleLayer -> [ConsoleLayer] #
Eq ConsoleLayer # |
Methods (==) :: ConsoleLayer -> ConsoleLayer -> Bool # (/=) :: ConsoleLayer -> ConsoleLayer -> Bool #
Ord ConsoleLayer # |
Methods compare :: ConsoleLayer -> ConsoleLayer -> Ordering # (<) :: ConsoleLayer -> ConsoleLayer -> Bool # (<=) :: ConsoleLayer -> ConsoleLayer -> Bool # (>) :: ConsoleLayer -> ConsoleLayer -> Bool # (>=) :: ConsoleLayer -> ConsoleLayer -> Bool # max :: ConsoleLayer -> ConsoleLayer -> ConsoleLayer # min :: ConsoleLayer -> ConsoleLayer -> ConsoleLayer #
Read ConsoleLayer # |
Methods readsPrec :: Int -> ReadS ConsoleLayer # readList :: ReadS [ConsoleLayer] # readPrec :: ReadPrec ConsoleLayer # readListPrec :: ReadPrec [ConsoleLayer] #
Show ConsoleLayer # |
Methods showsPrec :: Int -> ConsoleLayer -> ShowS # show :: ConsoleLayer -> String # showList :: [ConsoleLayer] -> ShowS #
Ix ConsoleLayer # |
Methods range :: (ConsoleLayer, ConsoleLayer) -> [ConsoleLayer] # index :: (ConsoleLayer, ConsoleLayer) -> ConsoleLayer -> Int # unsafeIndex :: (ConsoleLayer, ConsoleLayer) -> ConsoleLayer -> Int inRange :: (ConsoleLayer, ConsoleLayer) -> ConsoleLayer -> Bool # rangeSize :: (ConsoleLayer, ConsoleLayer) -> Int # unsafeRangeSize :: (ConsoleLayer, ConsoleLayer) -> Int

data BlinkSpeed #

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

Bounded BlinkSpeed # |
Methods minBound :: BlinkSpeed # maxBound :: BlinkSpeed #
Enum BlinkSpeed # |
Methods succ :: BlinkSpeed -> BlinkSpeed # pred :: BlinkSpeed -> BlinkSpeed # toEnum :: Int -> BlinkSpeed # fromEnum :: BlinkSpeed -> Int # enumFrom :: BlinkSpeed -> [BlinkSpeed] # enumFromThen :: BlinkSpeed -> BlinkSpeed -> [BlinkSpeed] # enumFromTo :: BlinkSpeed -> BlinkSpeed -> [BlinkSpeed] # enumFromThenTo :: BlinkSpeed -> BlinkSpeed -> BlinkSpeed -> [BlinkSpeed] #
Eq BlinkSpeed # |
Methods (==) :: BlinkSpeed -> BlinkSpeed -> Bool # (/=) :: BlinkSpeed -> BlinkSpeed -> Bool #
Ord BlinkSpeed # |
Methods compare :: BlinkSpeed -> BlinkSpeed -> Ordering # (<) :: BlinkSpeed -> BlinkSpeed -> Bool # (<=) :: BlinkSpeed -> BlinkSpeed -> Bool # (>) :: BlinkSpeed -> BlinkSpeed -> Bool # (>=) :: BlinkSpeed -> BlinkSpeed -> Bool # max :: BlinkSpeed -> BlinkSpeed -> BlinkSpeed # min :: BlinkSpeed -> BlinkSpeed -> BlinkSpeed #
Read BlinkSpeed # |
Methods readsPrec :: Int -> ReadS BlinkSpeed # readList :: ReadS [BlinkSpeed] # readPrec :: ReadPrec BlinkSpeed # readListPrec :: ReadPrec [BlinkSpeed] #
Show BlinkSpeed # |
Methods showsPrec :: Int -> BlinkSpeed -> ShowS # show :: BlinkSpeed -> String # showList :: [BlinkSpeed] -> ShowS #
Ix BlinkSpeed # |
Methods range :: (BlinkSpeed, BlinkSpeed) -> [BlinkSpeed] # index :: (BlinkSpeed, BlinkSpeed) -> BlinkSpeed -> Int # unsafeIndex :: (BlinkSpeed, BlinkSpeed) -> BlinkSpeed -> Int inRange :: (BlinkSpeed, BlinkSpeed) -> BlinkSpeed -> Bool # rangeSize :: (BlinkSpeed, BlinkSpeed) -> Int # unsafeRangeSize :: (BlinkSpeed, BlinkSpeed) -> Int

data Underlining #

ANSI text underlining

Constructors

SingleUnderline |
DoubleUnderline | Not widely supported
NoUnderline |

Instances

Bounded Underlining # |
Methods minBound :: Underlining # maxBound :: Underlining #
Enum Underlining # |
Methods succ :: Underlining -> Underlining # pred :: Underlining -> Underlining # toEnum :: Int -> Underlining # fromEnum :: Underlining -> Int # enumFrom :: Underlining -> [Underlining] # enumFromThen :: Underlining -> Underlining -> [Underlining] # enumFromTo :: Underlining -> Underlining -> [Underlining] # enumFromThenTo :: Underlining -> Underlining -> Underlining -> [Underlining] #
Eq Underlining # |
Methods (==) :: Underlining -> Underlining -> Bool # (/=) :: Underlining -> Underlining -> Bool #
Ord Underlining # |
Methods compare :: Underlining -> Underlining -> Ordering # (<) :: Underlining -> Underlining -> Bool # (<=) :: Underlining -> Underlining -> Bool # (>) :: Underlining -> Underlining -> Bool # (>=) :: Underlining -> Underlining -> Bool # max :: Underlining -> Underlining -> Underlining # min :: Underlining -> Underlining -> Underlining #
Read Underlining # |
Methods readsPrec :: Int -> ReadS Underlining # readList :: ReadS [Underlining] # readPrec :: ReadPrec Underlining # readListPrec :: ReadPrec [Underlining] #
Show Underlining # |
Methods showsPrec :: Int -> Underlining -> ShowS # show :: Underlining -> String # showList :: [Underlining] -> ShowS #
Ix Underlining # |
Methods range :: (Underlining, Underlining) -> [Underlining] # index :: (Underlining, Underlining) -> Underlining -> Int # unsafeIndex :: (Underlining, Underlining) -> Underlining -> Int inRange :: (Underlining, Underlining) -> Underlining -> Bool # rangeSize :: (Underlining, Underlining) -> Int # unsafeRangeSize :: (Underlining, Underlining) -> Int

data ConsoleIntensity #

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
NormalIntensity |

Instances

Bounded ConsoleIntensity # |
Methods minBound :: ConsoleIntensity # maxBound :: ConsoleIntensity #
Enum ConsoleIntensity # |
Methods succ :: ConsoleIntensity -> ConsoleIntensity # pred :: ConsoleIntensity -> ConsoleIntensity # toEnum :: Int -> ConsoleIntensity # fromEnum :: ConsoleIntensity -> Int # enumFrom :: ConsoleIntensity -> [ConsoleIntensity] # enumFromThen :: ConsoleIntensity -> ConsoleIntensity -> [ConsoleIntensity] # enumFromTo :: ConsoleIntensity -> ConsoleIntensity -> [ConsoleIntensity] # enumFromThenTo :: ConsoleIntensity -> ConsoleIntensity -> ConsoleIntensity -> [ConsoleIntensity] #
Eq ConsoleIntensity # |
Methods (==) :: ConsoleIntensity -> ConsoleIntensity -> Bool # (/=) :: ConsoleIntensity -> ConsoleIntensity -> Bool #
Ord ConsoleIntensity # |
Methods compare :: ConsoleIntensity -> ConsoleIntensity -> Ordering # (<) :: ConsoleIntensity -> ConsoleIntensity -> Bool # (<=) :: ConsoleIntensity -> ConsoleIntensity -> Bool # (>) :: ConsoleIntensity -> ConsoleIntensity -> Bool # (>=) :: ConsoleIntensity -> ConsoleIntensity -> Bool # max :: ConsoleIntensity -> ConsoleIntensity -> ConsoleIntensity # min :: ConsoleIntensity -> ConsoleIntensity -> ConsoleIntensity #
Read ConsoleIntensity # |
Methods readsPrec :: Int -> ReadS ConsoleIntensity # readList :: ReadS [ConsoleIntensity] # readPrec :: ReadPrec ConsoleIntensity # readListPrec :: ReadPrec [ConsoleIntensity] #
Show ConsoleIntensity # |
Methods showsPrec :: Int -> ConsoleIntensity -> ShowS # show :: ConsoleIntensity -> String # showList :: [ConsoleIntensity] -> ShowS #
Ix ConsoleIntensity # |
Methods range :: (ConsoleIntensity, ConsoleIntensity) -> [ConsoleIntensity] # index :: (ConsoleIntensity, ConsoleIntensity) -> ConsoleIntensity -> Int # unsafeIndex :: (ConsoleIntensity, ConsoleIntensity) -> ConsoleIntensity -> Int inRange :: (ConsoleIntensity, ConsoleIntensity) -> ConsoleIntensity -> Bool # rangeSize :: (ConsoleIntensity, ConsoleIntensity) -> Int # unsafeRangeSize :: (ConsoleIntensity, ConsoleIntensity) -> Int

data SGR #

ANSI Select Graphic Rendition command

Constructors

Reset |
SetConsoleIntensity ConsoleIntensity |
SetItalicized Bool | Not widely supported: sometimes treated as swapping foreground and background
SetUnderlining Underlining |
SetBlinkSpeed BlinkSpeed |
SetVisible Bool | Not widely supported
SetSwapForegroundBackground Bool |
SetColor ConsoleLayer ColorIntensity Color |

Instances

Eq SGR # |
Methods (==) :: SGR -> SGR -> Bool # (/=) :: SGR -> SGR -> Bool #
Ord SGR # |
Methods compare :: SGR -> SGR -> Ordering # (<) :: SGR -> SGR -> Bool # (<=) :: SGR -> SGR -> Bool # (>) :: SGR -> SGR -> Bool # (>=) :: SGR -> SGR -> Bool # max :: SGR -> SGR -> SGR # min :: SGR -> SGR -> SGR #
Read SGR # |
Methods readsPrec :: Int -> ReadS SGR # readList :: ReadS [SGR] # readPrec :: ReadPrec SGR # readListPrec :: ReadPrec [SGR] #
Show SGR # |
Methods showsPrec :: Int -> SGR -> ShowS # show :: SGR -> String # showList :: [SGR] -> ShowS #

# Cursor movement by character

cursorUp #

Arguments

:: Int | Number of lines or characters to move
-> IO () |

cursorDown #

Arguments

:: Int | Number of lines or characters to move
-> IO () |

cursorForward #

Arguments

:: Int | Number of lines or characters to move
-> IO () |

cursorBackward #

Arguments

:: Int | Number of lines or characters to move
-> IO () |

hCursorUp #

Arguments

:: Handle |
-> Int | Number of lines or characters to move
-> IO () |

hCursorDown #

Arguments

:: Handle |
-> Int | Number of lines or characters to move
-> IO () |

hCursorForward #

Arguments

:: Handle |
-> Int | Number of lines or characters to move
-> IO () |

hCursorBackward #

Arguments

:: Handle |
-> Int | Number of lines or characters to move
-> IO () |

cursorUpCode #

Arguments

:: Int | Number of lines or characters to move
-> String |

cursorDownCode #

Arguments

:: Int | Number of lines or characters to move
-> String |

cursorForwardCode #

Arguments

:: Int | Number of lines or characters to move
-> String |

cursorBackwardCode #

Arguments

:: Int | Number of lines or characters to move
-> String |

# Cursor movement by line

cursorUpLine #

Arguments

:: Int | Number of lines to move
-> IO () |

cursorDownLine #

Arguments

:: Int | Number of lines to move
-> IO () |

hCursorUpLine #

Arguments

:: Handle |
-> Int | Number of lines to move
-> IO () |

hCursorDownLine #

Arguments

:: Handle |
-> Int | Number of lines to move
-> IO () |

cursorUpLineCode #

Arguments

:: Int | Number of lines to move
-> String |

cursorDownLineCode #

Arguments

:: Int | Number of lines to move
-> String |

# Directly changing cursor position

setCursorColumn #

Arguments

:: Int | 0-based column to move to
-> IO () |

hSetCursorColumn #

Arguments

:: Handle |
-> Int | 0-based column to move to
-> IO () |

setCursorColumnCode #

Arguments

:: Int | 0-based column to move to
-> String |

setCursorPosition #

Arguments

:: Int | 0-based row to move to
-> Int | 0-based column to move to
-> IO () |

hSetCursorPosition #

Arguments

:: Handle |
-> Int | 0-based row to move to
-> Int | 0-based column to move to
-> IO () |

setCursorPositionCode #

Arguments

:: Int | 0-based row to move to
-> Int | 0-based column to move to
-> String |

# Clearing parts of the screen

clearFromCursorToScreenEnd :: IO () #

clearFromCursorToScreenBeginning :: IO () #

clearScreen :: IO () #

hClearFromCursorToScreenEnd :: Handle -> IO () #

hClearFromCursorToScreenBeginning :: Handle -> IO () #

hClearScreen :: Handle -> IO () #

clearFromCursorToScreenEndCode :: String #

clearFromCursorToScreenBeginningCode :: String #

clearScreenCode :: String #

clearFromCursorToLineEnd :: IO () #

clearFromCursorToLineBeginning :: IO () #

clearLine :: IO () #

hClearFromCursorToLineEnd :: Handle -> IO () #

hClearFromCursorToLineBeginning :: Handle -> IO () #

hClearLine :: Handle -> IO () #

clearFromCursorToLineEndCode :: String #

clearFromCursorToLineBeginningCode :: String #

clearLineCode :: String #

# Scrolling the screen

scrollPageUp #

Arguments

:: Int | Number of lines to scroll by
-> IO () |

Scroll the displayed information up or down the terminal: not widely supported

scrollPageDown #

Arguments

:: Int | Number of lines to scroll by
-> IO () |

Scroll the displayed information up or down the terminal: not widely supported

hScrollPageUp #

Arguments

:: Handle |
-> Int | Number of lines to scroll by
-> IO () |

Scroll the displayed information up or down the terminal: not widely supported

hScrollPageDown #

Arguments

:: Handle |
-> Int | Number of lines to scroll by
-> IO () |

Scroll the displayed information up or down the terminal: not widely supported

scrollPageUpCode #

Arguments

:: Int | Number of lines to scroll by
-> String |

Scroll the displayed information up or down the terminal: not widely supported

scrollPageDownCode #

Arguments

:: Int | Number of lines to scroll by
-> String |

Scroll the displayed information up or down the terminal: not widely supported

# Select Graphic Rendition mode: colors and other whizzy stuff

setSGR #

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.
-> IO () |

Set the Select Graphic Rendition mode

hSetSGR #

Arguments

:: Handle |
-> [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.
-> IO () |

Set the Select Graphic Rendition mode

setSGRCode #

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 |

Set the Select Graphic Rendition mode

# Cursor visibilty changes

hideCursor :: IO () #

showCursor :: IO () #

hHideCursor :: Handle -> IO () #

hShowCursor :: Handle -> IO () #

hideCursorCode :: String #

showCursorCode :: String #

# Changing the title

setTitle #

Arguments

:: String | New title
-> IO () |

Set the terminal window title

hSetTitle #

Arguments

:: Handle |
-> String | New title
-> IO () |

Set the terminal window title

setTitleCode #

Arguments

:: String | New title
-> String |

Set the terminal window title

Thanks to Brandon S. Allbery and Curt Sampson for pointing me in the right direction on xterm title setting on haskell-cafe. The "0" signifies that both the title and "icon" text should be set: i.e. the text for the window in the Start bar (or similar) as well as that in the actual window title. This is chosen for consistent behaviour between Unixes and Windows.

# Checking if handle supports ANSI

hSupportsANSI :: Handle -> IO Bool #

Use heuristics to determine whether the functions defined in this package will work with a given handle.

The current implementation checks that the handle is a terminal, and that the `TERM` environment variable doesn't say `dumb` (whcih is what Emacs sets for its own terminal).