console-style-0.0.1.0: Styled console text output using ANSI escape sequences.

CopyrightDaniel Mendler (c) 2016
LicenseMIT (see the file LICENSE)
Maintainermail@daniel-mendler.de
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

System.Console.Style

Description

This library provides styled text output using ANSI escape sequences. The main feature is that the library keeps track of a stack of the applied styles using a state monad. This makes it easy to use this library for a pretty printer with nested annotations, e.g., wl-pprint-console.

Example:

basicExample :: IO ()
basicExample = runWithStyle [FgColor Blue] $ do
  withStyle [Bold] $ liftIO $ putStr "Bold Blue"

  setStyle [Save, Italic, BgColor Red]
  liftIO $ putStr "Italic Red"
  setStyle [Restore]

  setStyle [Under]
  liftIO $ putStr "Under Blue"
  setStyle [Reset]

  liftIO $ putStrLn "Normal output"

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

Documentation

data Blink Source #

Constructors

NoBlink 
BlinkSlow 
BlinkFast 

class HasStyle s where Source #

Minimal complete definition

getStyle, putStyle

Methods

getStyle :: s -> Style Source #

putStyle :: Style -> s -> s Source #

data Term Source #

Instances

Eq Term Source # 

Methods

(==) :: Term -> Term -> Bool #

(/=) :: Term -> Term -> Bool #

Show Term Source # 

Methods

showsPrec :: Int -> Term -> ShowS #

show :: Term -> String #

showList :: [Term] -> ShowS #

hRunWithStyle :: MonadIO m => Handle -> [SetStyle] -> StyleT m a -> m a Source #

hSetStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => Handle -> f SetStyle -> m () Source #

hWithStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => Handle -> f SetStyle -> m a -> m a Source #

runStyleT :: Monad m => Term -> StyleT m a -> m a Source #

runWithStyle :: MonadIO m => [SetStyle] -> StyleT m a -> m a Source #

setStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m () Source #

withStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m a -> m a Source #