Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
. 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.
Vty uses threads internally, so programs made with Vty need to be
compiled with the threaded runtime using the GHC -threaded
option.
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
imgupdate
vty pic e <-nextEvent
vtyshutdown
vty++
show
e)
Synopsis
- data Vty = Vty {}
- mkVty :: Config -> IO Vty
- setWindowTitle :: Vty -> String -> IO ()
- data Mode
- 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
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:
- Initialize vty with
mkVty
(this takes control of 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 | |
|
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.
setWindowTitle :: Vty -> String -> IO () Source #
Set the terminal window title string.
This function emits an Xterm-compatible escape sequence that we anticipate will work for essentially all modern terminal emulators. Ideally we'd use a terminal capability for this, but there does not seem to exist a termcap for setting window titles. If you find that this function does not work for a given terminal emulator, please report the issue.
For details, see:
Modal terminal features that can be enabled and disabled.
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) |
Focus | Focus-in/focus-out events (whether the terminal is configured to provide events on focus change) |
Hyperlink | Hyperlink mode via the |
module Graphics.Vty.Config
module Graphics.Vty.Input
module Graphics.Vty.Output
module Graphics.Vty.Picture
module Graphics.Vty.Image
module Graphics.Vty.Attributes