GithubHelp home page GithubHelp logo

silky / ansi-terminal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unkindpartition/ansi-terminal

0.0 1.0 0.0 132 KB

ANSI terminal support for Haskell, with Windows compatibility

License: BSD 3-Clause "New" or "Revised" License

Haskell 98.57% Shell 1.43%

ansi-terminal's Introduction

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.

ansi-terminal's People

Contributors

23skidoo avatar batterseapower avatar chexxor avatar ekmett avatar ggreif avatar hsenag avatar mpilgrem avatar psibi avatar swiftsnamesake avatar unkindpartition avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.