vty-5.2.1: A simple terminal UI library

Safe HaskellNone




data Key Source

Representations of non-modifier keys.

  • KFun is indexed from 0 to 63. Range of supported FKeys varies by terminal and keyboard.
  • KUpLeft, KUpRight, KDownLeft, KDownRight, KCenter support varies by terminal and keyboard.
  • Actually, support for most of these but KEsc, KChar, KBS, and KEnter vary by terminal and keyboard.


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.



data Button Source

Mouse buttons.

todo not supported.




data Event Source



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

todo mouse events are not supported

EvResize Int Int

if read from eventChannel this is the size at the time of the signal. If read from nextEvent this is the size at the time the event was processed by Vty. Typically these are the same, but if somebody is resizing the terminal quickly they can be different.


data Input Source




_eventChannel :: Chan Event

Channel of events direct from input processing. Unlike nextEvent this will not refresh the display if the next event is an EvResize.

shutdownInput :: IO ()

Shuts down the input processing. This should return the terminal input state to before the input initialized.

_configRef :: IORef Config

Changes to this value are reflected after the next event.

_inputDebug :: Maybe Handle

input debug log

inputForConfig :: Config -> IO InputSource

Set up the terminal with file descriptor inputFd for input. Returns a Input.

The table used to determine the Events to produce for the input bytes comes from classifyMapForTerm. Which is then overridden by the the applicable entries from inputMap.

The terminal device is configured with the attributes:

  • IXON disabled - disables software flow control on outgoing data. This stops the process from being suspended if the output terminal cannot keep up. I presume this has little effect these days. I hope this means that output will be buffered if the terminal cannot keep up. In the old days the output might of been dropped?

raw mode is used for input.

  • ISIG disabled - enables keyboard combinations that result in signals. TODO: should probably be a dynamic option.
  • ECHO disabled - input is not echod to the output. TODO: should be a dynamic option.
  • ICANON disabled - canonical mode (line mode) input is not used. TODO: should be a dynamic option.
  • IEXTEN disabled - extended functions are disabled. TODO: I don't know what those are.