vty-5.16: A simple terminal UI library

Safe Haskell | None
Language | Haskell2010

Graphics.Vty

Description

Vty provides interfaces for both terminal input and terminal output.

- Input to the terminal is provided to the Vty application as a sequence of `Event`s.
- Output is provided to Vty by the application in the form of a `Picture`. A `Picture` is one or more layers of `Image`s. `Image` values can be built by the various constructors in Graphics.Vty.Image. Output can be syled using `Attr` (attribute) values in the Graphics.Vty.Attributes module.

     import Graphics.Vty

     main = do
         cfg <- standardIOConfig
         vty <- mkVty cfg
         let line0 = string (defAttr ` withForeColor ` green) "first line"
             line1 = string (defAttr ` withBackColor ` blue) "second line"
             img = line0 <-> line1
             pic = picForImage img
         update vty pic
         e <- nextEvent vty
         shutdown vty
         print ("Last event was: " ++ show e)

Synopsis

- data Vty = Vty {
  - update :: Picture -> IO ()
  - nextEvent :: IO Event
  - inputIface :: Input
  - outputIface :: Output
  - refresh :: IO ()
  - shutdown :: IO ()
  }
- mkVty :: Config -> IO Vty
- data Mode
  - = Mouse
  - | BracketedPaste
- module Graphics.Vty.Config
- module Graphics.Vty.Input
- module Graphics.Vty.Output
- module Graphics.Vty.Output.Interface
- module Graphics.Vty.Picture
- module Graphics.Vty.Image
- module Graphics.Vty.Attributes

# Documentation

data Vty Source #

A Vty value represents a handle to the Vty library that the application must create in order to use Vty.

The use of Vty typically follows this process:

1. Initialize vty
2. Use `update` to display a picture.
3. Use `nextEvent` to get the next input event.
4. Depending on the event, go to 2 or 5.
5. Shutdown vty.

Operations on Vty handles are not thread-safe.

Constructors

Vty |

Fields

- update :: Picture -> IO ()

  Outputs the given `Picture`.

- nextEvent :: IO Event

  Get one `Event` object, blocking if none are available. This will refresh the terminal if the event is a `EvResize`.

- inputIface :: Input

  The input interface. See `Input`.

- outputIface :: Output

  The output interface. See `Output`.

- refresh :: IO ()

  Refresh the display. `nextEvent` will refresh the display if a resize occurs, but this can be used to refresh the display explicitly. If other programs output to the terminal and mess up the display then the application might want to force a refresh using this function.

- shutdown :: IO ()

  Clean up after vty. A call to this function is necessary to cleanly restore the terminal state before application exit. The above methods will throw an exception if executed after this is executed.

mkVty :: Config -> IO Vty Source #

Create a Vty handle. At most one handle should be created at a time for a given terminal device.

The specified configuration is added to the the configuration loaded by `userConfig` with the `userConfig` configuration taking precedence. See Graphics.Vty.Config.

For most applications `mkVty defaultConfig` is sufficient.

data Mode Source #

Modal terminal features that can be enabled and disabled.

Constructors

Mouse | Mouse mode (whether the terminal is configured to provide mouse input events)
BracketedPaste | Paste mode (whether the terminal is configured to provide events on OS pastes)

Instances

Eq Mode Source # |
Methods (==) :: Mode -> Mode -> Bool # (/=) :: Mode -> Mode -> Bool #
Read Mode Source # |
Methods readsPrec :: Int -> ReadS Mode # readList :: ReadS [Mode] # readPrec :: ReadPrec Mode # readListPrec :: ReadPrec [Mode] #
Show Mode Source # |
Methods showsPrec :: Int -> Mode -> ShowS # show :: Mode -> String # showList :: [Mode] -> ShowS #

module Graphics.Vty.Config

module Graphics.Vty.Input

module Graphics.Vty.Output

module Graphics.Vty.Output.Interface

module Graphics.Vty.Picture

module Graphics.Vty.Image

module Graphics.Vty.Attributes