| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Graphics.Vty
Description
Vty provides interfaces for both terminal input and terminal output.
- User input to the terminal is provided to the Vty application as a
sequence of
Events. - Output is provided to by the application to Vty in the form of a
Picture. APictureis one or more layers ofImages.Imagevalues can be built by the various constructors in Graphics.Vty.Image. Output can be syled usingAttr(attribute) values in the Graphics.Vty.Attributes module. - Each platform on which Vty is supported provides a package that
provides Vty with access to the platform-specific terminal
interface. For example, on Unix systems, the
vty-unixpackage must be used to initialize Vty with access to a Unix terminal.
As a small example, the following program demonstrates the use of Vty
on a Unix system using the vty-unix package:
import Graphics.Vty
import Graphics.Vty.Platform.Unix (mkVty)
main = do
vty <- mkVty defaultConfig
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)Vty uses threads internally, so programs made with Vty must be
compiled with the threaded runtime using the GHC -threaded option.
Synopsis
- data Vty = Vty {}
- setWindowTitle :: Vty -> String -> IO ()
- installCustomWidthTable :: Maybe FilePath -> Maybe String -> [(String, FilePath)] -> IO ()
- mkVtyFromPair :: Input -> Output -> IO Vty
- module Graphics.Vty.Config
- module Graphics.Vty.Input
- module Graphics.Vty.Input.Events
- module Graphics.Vty.Output
- module Graphics.Vty.Picture
- module Graphics.Vty.Image
- module Graphics.Vty.Attributes
Documentation
A Vty value represents a handle to the Vty library that the
application must create in order to use Vty.
The use of this library typically follows this process:
- Initialize Vty with the
mkVtyimplementation for your platform's Vty package (e.g.vty-unix), or, more generically, withmkVtyFromPair. This takes control of (and sets up) the terminal. - Use
updateto display a picture. - Use
nextEventto get the next input event. - Depending on the event, go to 2 or 5.
- Shutdown Vty and restore the terminal state with
shutdown. At this point theVtyhandle cannot be used again.
Operations on Vty handles are not thread-safe.
Constructors
| Vty | |
Fields
| |
installCustomWidthTable Source #
Arguments
| :: Maybe FilePath | Optional path to a log file where log messages should be written when attempting to load a width table. |
| -> Maybe String | Optional width table entry name (usually
the terminal name, e.g. value of |
| -> [(String, FilePath)] | Mapping from width table entry names to
width table file paths. This is usually
obtained from |
| -> IO () |
Attempt to load and install a custom character width table into this process.
This looks up the specified terminal name in the specified width table map and, if a map file path is found, the map is loaded and installed. This is exposed for Vty platform package implementors; application developers should never need to call this.
mkVtyFromPair :: Input -> Output -> IO Vty Source #
Build a Vty handle from an input/output pair.
This is exposed for Vty platform package implementors; application
developers should never need to call this, and should instead call
mkVty or equivalent from their platform package of choice.
module Graphics.Vty.Config
module Graphics.Vty.Input
module Graphics.Vty.Input.Events
module Graphics.Vty.Output
module Graphics.Vty.Picture
module Graphics.Vty.Image
module Graphics.Vty.Attributes