|
Packit |
fc89b4 |
ansi-terminal
|
|
Packit |
fc89b4 |
=============
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Haskell ANSI Terminal Package For Windows, OS X and Linux
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Description
|
|
Packit |
fc89b4 |
-----------
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
[ANSI](http://en.wikipedia.org/wiki/ANSI_escape_sequences) terminal
|
|
Packit |
fc89b4 |
support for Haskell, which allows:
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
- Cursor movement
|
|
Packit |
fc89b4 |
- Screen and line clearing
|
|
Packit |
fc89b4 |
- Color output
|
|
Packit |
fc89b4 |
- Showing or hiding the cursor
|
|
Packit |
fc89b4 |
- Changing the console title (though this is not strictly part of
|
|
Packit |
fc89b4 |
ANSI, it is widely supported in Unix)
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
It is compatible with Windows (via an emulation layer) and those Unixes
|
|
Packit |
fc89b4 |
with ANSI terminals.
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
If you like this, you may be interested in
|
|
Packit |
fc89b4 |
[ansi-wl-pprint](http://github.com/batterseapower/ansi-wl-pprint), which
|
|
Packit |
fc89b4 |
provides a pretty-printer that can construct strings containing ANSI
|
|
Packit |
fc89b4 |
colorisation.
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Not all of the ANSI escape codes are provided by this module, but most
|
|
Packit |
fc89b4 |
(if not all) of the popular and well supported ones are. For a full
|
|
Packit |
fc89b4 |
list, have a look at the [current version of the
|
|
Packit |
fc89b4 |
API](http://github.com/feuerbach/ansi-terminal/tree/master/includes/Common-Include.hs).
|
|
Packit |
fc89b4 |
Each supported escape code or family of codes has a corresponding
|
|
Packit |
fc89b4 |
function that comes in three variants:
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
- A straight `IO` variant that doesn't take a `Handle` and just
|
|
Packit |
fc89b4 |
applies the ANSI escape code to the terminal attached to stdout
|
|
Packit |
fc89b4 |
- An `IO` variant similar to above, but which takes a `Handle` to
|
|
Packit |
fc89b4 |
which the ANSI escape should be applied
|
|
Packit |
fc89b4 |
- A `String` variant that returns a literal string that should be
|
|
Packit |
fc89b4 |
included to get the effect of the code. This is the only one of the
|
|
Packit |
fc89b4 |
three API variants that only works on Unix-like operating systems:
|
|
Packit |
fc89b4 |
on Windows these strings will always be blank!
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Example
|
|
Packit |
fc89b4 |
-------
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
A full example is
|
|
Packit |
fc89b4 |
[available](http://github.com/feuerbach/ansi-terminal/tree/master/System/Console/ANSI/Example.hs),
|
|
Packit |
fc89b4 |
but for a taste of how the library works try the following code:
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
``` haskell
|
|
Packit |
fc89b4 |
import System.Console.ANSI
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
main = do
|
|
Packit |
fc89b4 |
setCursorPosition 5 0
|
|
Packit |
fc89b4 |
setTitle "ANSI Terminal Short Example"
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
setSGR [ SetConsoleIntensity BoldIntensity
|
|
Packit |
fc89b4 |
, SetColor Foreground Vivid Red
|
|
Packit |
fc89b4 |
]
|
|
Packit |
fc89b4 |
putStr "Hello"
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
setSGR [ SetConsoleIntensity NormalIntensity
|
|
Packit |
fc89b4 |
, SetColor Foreground Vivid White
|
|
Packit |
fc89b4 |
, SetColor Background Dull Blue
|
|
Packit |
fc89b4 |
]
|
|
Packit |
fc89b4 |
putStrLn "World!"
|
|
Packit |
fc89b4 |
```
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
![](https://raw.githubusercontent.com/feuerbach/ansi-terminal/master/example.png)
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Documentation
|
|
Packit |
fc89b4 |
-------------
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Haddock documentation is [available at
|
|
Packit |
fc89b4 |
Hackage](http://hackage.haskell.org/packages/archive/ansi-terminal/latest/doc/html/System-Console-ANSI.html).
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Credits
|
|
Packit |
fc89b4 |
-------
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
The library is originally written by [Max Bolingbroke](https://github.com/batterseapower)
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
Maintainers
|
|
Packit |
fc89b4 |
-----------
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
[Roman Cheplyaka](https://github.com/feuerbach) is the primary maintainer.
|
|
Packit |
fc89b4 |
|
|
Packit |
fc89b4 |
[Oliver Charles](https://github.com/ocharles) is the backup maintainer. Please
|
|
Packit |
fc89b4 |
get in touch with him if the primary maintainer cannot be reached.
|