vty-4.7.0.20: A simple terminal UI library

Safe Haskell | None

Graphics.Vty

Synopsis

- data Vty = Vty {
  - update :: Picture -> IO ()
  - next_event :: IO Event
  - terminal :: TerminalHandle
  - refresh :: IO ()
  - shutdown :: IO ()
  }
- mkVty :: IO Vty
- mkVtyEscDelay :: Int -> IO Vty
- module Graphics.Vty.Terminal
- module Graphics.Vty.Picture
- module Graphics.Vty.DisplayRegion
- data Key
  - = KEsc
  - | KFun Int
  - | KBackTab
  - | KPrtScr
  - | KPause
  - | KASCII Char
  - | KBS
  - | KIns
  - | KHome
  - | KPageUp
  - | KDel
  - | KEnd
  - | KPageDown
  - | KBegin
  - | KNP5
  - | KUp
  - | KMenu
  - | KLeft
  - | KDown
  - | KRight
  - | KEnter
- data Modifier
  - = MShift
  - | MCtrl
  - | MMeta
  - | MAlt
- data Button
  - = BLeft
  - | BMiddle
  - | BRight
- data Event
  - = EvKey Key [Modifier]
  - | EvMouse Int Int Button [Modifier]
  - | EvResize Int Int

# Documentation

data Vty Source

The main object. At most one should be created. An alternative is to use unsafePerformIO to automatically create a singleton Vty instance when required.

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: Once the Terminal interface encompasses input this interface will be deprecated. Currently, just using the Terminal interface there is no support for input events.

Constructors

Vty |

Fields

update :: Picture -> IO ()

  Outputs the given Picture. Equivalent to output_picture applied to a display context implicitly managed by Vty.

next_event :: IO Event

  Get one Event object, blocking if necessary.

terminal :: TerminalHandle

  Handle to the terminal interface. See `Terminal`

  The use of Vty typically follows this process:

  1. initialize vty
  2. use the update equation of Vty to display a picture
  3. repeat
  4. shutdown vty.

  todo: provide a similar abstraction to Graphics.Vty.Terminal for input. Use haskeline's input backend for implementation.

  todo: remove explicit `shutdown` requirement.

refresh :: IO ()

  Refresh the display. Normally the library takes care of refreshing. Nonetheless, some other program might output to the terminal and mess the display. In that case the user might want to force a refresh.

shutdown :: IO ()

  Clean up after vty.

mkVty :: IO Vty Source

Set up the state object for using vty. At most one state object should be created at a time.

mkVtyEscDelay :: Int -> IO Vty Source

Set up the state object for using vty. At most one state object should be created at a time. The delay, in microseconds, specifies the period of time to wait for a key following reading ESC from the terminal before considering the ESC key press as a discrete event.

module Graphics.Vty.Terminal

module Graphics.Vty.Picture

module Graphics.Vty.DisplayRegion

data Key Source

Representations of non-modifier keys.

Constructors

KEsc |
KFun Int |
KBackTab |
KPrtScr |
KPause |
KASCII Char |
KBS |
KIns |
KHome |
KPageUp |
KDel |
KEnd |
KPageDown |
KBegin |
KNP5 |
KUp |
KMenu |
KLeft |
KDown |
KRight |
KEnter |

Instances

Eq Key |
Ord Key |
Show Key |

data Modifier Source

Modifier keys. Key codes are interpreted such that users are more likely to have Meta than Alt; for instance on the PC Linux console, `MMeta` will generally correspond to the physical Alt key.

Constructors

MShift |
MCtrl |
MMeta |
MAlt |

Instances

Eq Modifier |
Ord Modifier |
Show Modifier |

data Button Source

Mouse buttons. Not yet used.

Constructors

BLeft |
BMiddle |
BRight |

Instances

Eq Button |
Ord Button |
Show Button |

data Event Source

Generic events.

Constructors

EvKey Key [Modifier] |
EvMouse Int Int Button [Modifier] |
EvResize Int Int |

Instances

Eq Event |
Ord Event |
Show Event |