Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
Event
s. - Output is provided to by the application to Vty in the form of a
Picture
. APicture
is one or more layers ofImage
s.Image
values 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-unix
package 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
mkVty
implementation for your platform's Vty package (e.g.vty-unix
), or, more generically, withmkVtyFromPair
. This takes control of (and sets up) the terminal. - Use
update
to display a picture. - Use
nextEvent
to 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 theVty
handle cannot be used again.
Operations on Vty handles are not thread-safe.
Vty | |
|
installCustomWidthTable Source #
:: 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