Fork me on GitHub

ansi-terminal by Max Bolingbroke

Haskell ANSI Terminal Package For Windows, OS X and Linux

Description

ANSI terminal support for Haskell, which allows:

It is compatible with Windows (via an emulation layer) and those Unixes with ANSI terminals.

If you like this, you may be interested in ansi-wl-pprint, which provides a pretty-printer that can construct strings containing ANSI colorisation.

Not all of the ANSI escape codes are provided by this module, but most (if not all) of the popular and well supported ones are. For a full list, have a look at the current version of the API. Each supported escape code or family of codes has a corresponding function that comes in three variants:

Example

A full example is available, but for a taste of how the library works try the following code:

import System.Console.ANSI

main = do
    setCursorPosition 5 0
    setTitle "ANSI Terminal Short Example"

    setSGR [ SetConsoleIntensity BoldIntensity
           , SetColor Foreground Vivid Red
           ]
    putStr "Hello"
    
    setSGR [ SetConsoleIntensity NormalIntensity
           , SetColor Foreground Vivid White
           , SetColor Background Dull Blue
           ]
    putStrLn "World!"

Documentation

Haddock documentation is available at Hackage.

Download

Install with Cabal:

$ sudo cabal install ansi-terminal

Download this project in either zip or tar formats.

Clone the project with Git:

$ git clone git://github.com/batterseapower/ansi-terminal

Alternatively, browse the source on GitHub

Contact

You can submit a ticket at Lighthouse to report a bug.

Other enquiries can be directed to me via email