| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Graphics.Vty
Description
Vty supports input and output to terminal devices.
- Input to the terminal is provided to the app as a sequence of
Events. The output is defined by a
Picture. Which is one or more layers ofImages.- The module Graphics.Vty.Image provides a number of constructor equations that will build
correct
Imagevalues. Seestring,<|>, and<->for starters. - The constructors in Graphics.Vty.Image.Internal should not be used.
- The module Graphics.Vty.Image provides a number of constructor equations that will build
correct
Images can be styled usingAttr. See Graphics.Vty.Attributes.
See the vty-examples package for a number of examples.
import Graphics.Vty main = do cfg <-standardIOConfigvty <-mkVtycfg let line0 =string(defAttr`withForeColor`green) "first line" line1 =string(defAttr`withBackColor`blue) "second line" img = line0<->line1 pic =picForImageimgupdatevty pic e <-nextEventvtyshutdownvty++showe)
Good sources of documentation for terminal programming are:
- https://github.com/b4winckler/vim/blob/master/src/term.c
- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
- http://ulisse.elettra.trieste.it/services/doc/serial/config.html
- http://www.leonerd.org.uk/hacks/hints/xterm-8bit.html
- http://www.unixwiz.net/techtips/termios-vmin-vtime.html
- vt100 control sequences
- data Vty = Vty {}
- mkVty :: Config -> IO Vty
- module Graphics.Vty.Config
- module Graphics.Vty.Input
- module Graphics.Vty.Output
- module Graphics.Vty.Picture
- type DisplayRegion = (Int, Int)
- data Mode
Documentation
The main object. At most one should be created.
The use of Vty typically follows this process:
- initialize vty
- use the update equation of Vty to display a picture
- repeat
- shutdown vty.
An alternative to tracking the Vty instance is to use withVty in Graphics.Vty.Inline.Unsafe.
This does not assure any thread safety. In theory, as long as an update action is not executed when another update action is already then it's safe to call this on multiple threads.
todo Remove explicit shutdown requirement.
Constructors
| Vty | |
Fields
| |
mkVty :: Config -> IO Vty Source #
Set up the state object for using vty. At most one state object should be created at a time for a given terminal device.
The specified config is added to the userConfig. With the userConfig taking precedence.
See Graphics.Vty.Config
For most applications mkVty def is sufficient.
module Graphics.Vty.Config
module Graphics.Vty.Input
module Graphics.Vty.Output
module Graphics.Vty.Picture
type DisplayRegion = (Int, Int) Source #
Named alias for a Int pair