Copyright | Daniel Mendler (c) 2016 |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | mail@daniel-mendler.de |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
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
defaultStyle :: Term -> Style 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 #