vty-4.7.0.20: A simple terminal UI library

Safe Haskell | None

Graphics.Vty.Inline

Description

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.

          t <- terminal_handle
          putStr "Not styled. "
          put_attr_change t $ do
              back_color red
              apply_style underline
          putStr " Styled! "
          put_attr_change t $ default_all
          putStrLn "Not styled."
          release_terminal t

`put_attr_change` outputs the control codes to the terminal device `Handle`. This is a duplicate of the `stdout` handle when the `terminal_handle` was (first) acquired. If `stdout` has since been changed then `putStr`, `putStrLn`, `print` etc.. will output to a different `Handle` than `put_attr_change`

Copyright 2009-2010 Corey O'Connor

Synopsis

- type InlineM v = State Attr v
- back_color :: Color -> InlineM ()
- fore_color :: Color -> InlineM ()
- apply_style :: Style -> InlineM ()
- remove_style :: Style -> InlineM ()
- default_all :: InlineM ()
- put_attr_change :: (Applicative m, MonadIO m) => TerminalHandle -> InlineM () -> m ()

# Documentation

type InlineM v = State Attr vSource

back_color :: Color -> InlineM ()Source

Set the background color to the provided `Color`

fore_color :: Color -> InlineM ()Source

Set the foreground color to the provided `Color`

apply_style :: 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.

remove_style :: Style -> InlineM ()Source

Attempt to remove the specified `Style` from the display of the following text.

This will fail if apply_style for the given style has not been previously called.

default_all :: InlineM ()Source

Reset the display attributes

put_attr_change :: (Applicative m, MonadIO m) => TerminalHandle -> InlineM () -> m ()Source

Apply the provided display attribute changes to the terminal.

This also flushes the `stdout` handle.