Safe Haskell | None |
---|---|
Language | Haskell2010 |
The inline module provides a limited interface to changing the style of terminal output. The intention is for this interface to be used inline with other output systems.
The changes specified by the InlineM monad are applied to the terminals display attributes. These display attributes effect the display of all following text output to the terminal file descriptor.
For example, in an IO monad the following code with print the text "Not styled. " Followed by the text " Styled! " drawn over a red background and underlined.
putStr "Not styled. " putAttrChange_ $ do backColor red applyStyle underline putStr " Styled! " putAttrChange_ $ defaultAll putStrLn "Not styled."
putAttrChange
outputs the control codes to the terminal device Handle
. This is a duplicate
of the stdout
handle when the terminalHandle
was (first) acquired. If stdout
has since been
changed then putStr
, putStrLn
, print
etc.. will output to a different Handle
than
putAttrChange
Copyright 2009-2010 Corey O'Connor
- type InlineM v = State Attr v
- backColor :: Color -> InlineM ()
- foreColor :: Color -> InlineM ()
- applyStyle :: Style -> InlineM ()
- removeStyle :: Style -> InlineM ()
- defaultAll :: InlineM ()
- putAttrChange :: (Applicative m, MonadIO m) => Output -> InlineM () -> m ()
- putAttrChange_ :: (Applicative m, MonadIO m) => InlineM () -> m ()
- withVty :: (Vty -> IO b) -> IO b
Documentation
applyStyle :: Style -> InlineM () Source
Attempt to change the Style
of the following text.
If the terminal does not support the style change no error is produced. The style can still be removed.
removeStyle :: Style -> InlineM () Source
Attempt to remove the specified Style
from the display of the following text.
This will fail if applyStyle for the given style has not been previously called.
defaultAll :: InlineM () Source
Reset the display attributes
putAttrChange :: (Applicative m, MonadIO m) => Output -> InlineM () -> m () Source
Apply the provided display attribute changes to the given terminal output device.
This does not flush the terminal.
putAttrChange_ :: (Applicative m, MonadIO m) => InlineM () -> m () Source
Apply the provided display attributes changes to the terminal output device that was current at the time this was first used. Which, for most use cases, is the current terminal.
This will flush the terminal output.