ansi-terminal

Simple ANSI terminal support, with Windows compatibility https://github.com/feuerbach/ansi-terminal

Version on this page:0.6.2.3
LTS Haskell 9.0:0.6.3.1
Stackage Nightly 2017-07-25:0.6.3.1
Latest on Hackage:0.6.3.1
BSD3 licensed by Max Bolingbroke
Maintained by Roman Cheplyaka

Module documentation for 0.6.2.3

ansi-terminal

Haskell ANSI Terminal Package For Windows, OS X and Linux

Description

ANSI terminal support for Haskell, which allows:

  • Cursor movement
  • Screen and line clearing
  • Color output
  • Showing or hiding the cursor
  • Changing the console title (though this is not strictly part of ANSI, it is widely supported in Unix)

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:

  • A straight IO variant that doesn't take a Handle and just applies the ANSI escape code to the terminal attached to stdout
  • An IO variant similar to above, but which takes a Handle to which the ANSI escape should be applied
  • A String variant that returns a literal string that should be included to get the effect of the code. This is the only one of the three API variants that only works on Unix-like operating systems: on Windows these strings will always be blank!

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.

Credits

The library is originally written by Max Bolingbroke

Maintainers

Roman Cheplyaka is the primary maintainer.

Oliver Charles is the backup maintainer. Please get in touch with him if the primary maintainer cannot be reached.

Changes

Changes

Version 0.6.3.1

Fix Windows + ghc 7.8 compatibility,

Version 0.6.3

  • Add ANSI support for Windows
  • Add compatibility with Win32-2.5.0.0 and above

Version 0.6.2.3

Add an example to the haddocks

Version 0.6.2.2

Fix a GHC 7.10 warning

Version 0.6.2.1

Restore compatibility with GHC 7.4 and older

Version 0.6.2

  • Add hSupportsANSI
  • Drop support for base < 4

Version 0.6.1.1

Fix to build with GHC 7.8 on Windows

Version 0.6.1

  • BoldIntensity no longer changes background color on Windows
  • setSGR [] was not equivalent to setSGR [Reset] on Windows, even though it should be according to the documentation. This is now fixed.
Depends on:
Used by 135 packages:
AC-Terminal, EstProgress, FTPLine, HUnit-Diff, SimpleLog, ansi-wl-pprint, ansigraph, argon, assertions, black-jewel, byline, cabal-plan, catnplus, cgrep, chatty, cheapskate-terminal, chell, cnc-spec-compiler, colorize-haskell, concurrent-output, console-program, copilot-theorem, craft, cryptol, darkplaces-text, data-structure-inferrer, diagrams-haddock, diffdump, distributed-process-systest, distributed-process-tests, duplo, dustme, dynamic-pp, filter-logger, final-pretty-printer, formal, forml, ghcid, git-mediate, hackage-diff, haskeline-repl, hedgehog, hermit, hformat, highlight, highlight-versions, hledger, hledger-lib, hledger-ui, hlint, holy-project, hops, hsgtd, hspec-core, hspec-expectations-pretty-diff, hspec-meta, htsn-common, idris, iridium, kansas-lava-cores, kansas-lava-papilio, kdesrc-build-extra, keiretsu, kit, language-boogie, liquid-fixpoint, list-prompt, log-warper, lol-benches, lord, mappy, mdcat, mercury-api, metrics, mikrokosmos, minions, mpppc, mpretty, network-transport-tests, nixfromnpm, nptools, patat, pretty-simple, prettyprinter-ansi-terminal, propellor, purescript, quantum-random, questioner, quoridor-hs, rascal, replicant, resolve-trivial-conflicts, rlwe-challenges, scat, sensei, sentry, serokell-util, shift, sloane, smtlib2-debug, snorkels, socketio, stack, stack-bump, stack-run, steeloverseer, stgi, stylized, symantic-document, symon, system-test, tasty, tasty-silver, teleport, test-framework, test-framework-sandbox, time-warp, timeless, tldr, todos, trifecta, twhs, unused, uu-cco, varan, wai-cli, wai-extra, wl-pprint-ansiterm, wordsetdiff, wrecker, wybor, yesod-fast-devel, yesod-platform, yet-another-logger, zifter
comments powered byDisqus