vty-5.28.2: A simple terminal UI library

Safe Haskell | None
Language | Haskell2010

Graphics.Vty.Output.Interface

Description

This module provides an abstract interface for performing terminal output. The only user-facing part of this API is `Output`.

Synopsis

- data Output = Output {
  - terminalID :: String
  - releaseTerminal :: IO ()
  - reserveDisplay :: IO ()
  - releaseDisplay :: IO ()
  - displayBounds :: IO DisplayRegion
  - outputByteBuffer :: ByteString -> IO ()
  - contextColorCount :: Int
  - supportsCursorVisibility :: Bool
  - supportsMode :: Mode -> Bool
  - setMode :: Mode -> Bool -> IO ()
  - getModeStatus :: Mode -> IO Bool
  - assumedStateRef :: IORef AssumedState
  - mkDisplayContext :: Output -> DisplayRegion -> IO DisplayContext
  - ringTerminalBell :: IO ()
  - supportsBell :: IO Bool
  }
- data AssumedState = AssumedState {
  - prevFattr :: Maybe FixedAttr
  - prevOutputOps :: Maybe DisplayOps
  }
- data DisplayContext = DisplayContext {
  - contextDevice :: Output
  - contextRegion :: DisplayRegion
  - writeMoveCursor :: Int -> Int -> Write
  - writeShowCursor :: Write
  - writeHideCursor :: Write
  - writeSetAttr :: Bool -> FixedAttr -> Attr -> DisplayAttrDiff -> Write
  - writeDefaultAttr :: Bool -> Write
  - writeRowEnd :: Write
  - inlineHack :: IO ()
  }
- data Mode
  - = Mouse
  - | BracketedPaste
  - | Focus
  - | Hyperlink
- displayContext :: Output -> DisplayRegion -> IO DisplayContext
- outputPicture :: DisplayContext -> Picture -> IO ()
- initialAssumedState :: AssumedState
- limitAttrForDisplay :: Output -> Attr -> Attr

# Documentation

data Output Source #

The Vty terminal output interface.

Constructors

Output |

Fields

- terminalID :: String

  Text identifier for the output device. Used for debugging.

- releaseTerminal :: IO ()

  Release the terminal just prior to application exit and reset it to its state prior to application startup.

- reserveDisplay :: IO ()

  Clear the display and initialize the terminal to some initial display state.

  The expectation of a program is that the display starts in some The initial state. initial state would consist of fixed values:

  - cursor at top left
  - UTF-8 character encoding
  - drawing characteristics are the default
- releaseDisplay :: IO ()

  Return the display to the state before `reserveDisplay` If no previous state then set the display state to the initial state.

- displayBounds :: IO DisplayRegion

  Returns the current display bounds.

- outputByteBuffer :: ByteString -> IO ()

  Output the bytestring to the terminal device.

- contextColorCount :: Int

  Specifies the maximum number of colors supported by the context.

- supportsCursorVisibility :: Bool

  Specifies whether the cursor can be shown / hidden.

- supportsMode :: Mode -> Bool

  Indicates support for terminal modes for this output device.

- setMode :: Mode -> Bool -> IO ()

  Enables or disables a mode (does nothing if the mode is unsupported).

- getModeStatus :: Mode -> IO Bool

  Returns whether a mode is enabled.

- assumedStateRef :: IORef AssumedState
- mkDisplayContext :: Output -> DisplayRegion -> IO DisplayContext

  Acquire display access to the given region of the display. Currently all regions have the upper left corner of (0,0) and the lower right corner at (max displayWidth providedWidth, max displayHeight providedHeight)

- ringTerminalBell :: IO ()

  Ring the terminal bell if supported.

- supportsBell :: IO Bool

  Returns whether the terminal has an audio bell feature.

data AssumedState Source #

Constructors

AssumedState |

Fields

- prevFattr :: Maybe FixedAttr
- prevOutputOps :: Maybe DisplayOps

data DisplayContext Source #

Constructors

DisplayContext |

Fields

- contextDevice :: Output
- contextRegion :: DisplayRegion

  Provide the bounds of the display context.

- writeMoveCursor :: Int -> Int -> Write

  Sets the output position to the specified row and column where the number of bytes required for the control codes can be specified seperate from the actual byte sequence.

- writeShowCursor :: Write
- writeHideCursor :: Write
- writeSetAttr :: Bool -> FixedAttr -> Attr -> DisplayAttrDiff -> Write
- writeDefaultAttr :: Bool -> Write

  Reset the display attributes to the default display attributes.

- writeRowEnd :: Write
- inlineHack :: IO ()

  See `inlineHack`

data Mode Source #

Modal terminal features that can be enabled and disabled.

Constructors

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 `withURL` attribute modifier (see https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). Note that this may not work gracefully in all terminal emulators so be sure to test this mode with the terminals you intend to support. It is off by default.

#### Instances

Instances details

Eq Mode Source # |
Instance details Defined in Graphics.Vty.Output.Interface Methods (==) :: Mode -> Mode -> Bool (/=) :: Mode -> Mode -> Bool
Read Mode Source # |
Instance details Defined in Graphics.Vty.Output.Interface Methods readsPrec :: Int -> ReadS Mode readList :: ReadS [Mode] readPrec :: ReadPrec Mode readListPrec :: ReadPrec [Mode]
Show Mode Source # |
Instance details Defined in Graphics.Vty.Output.Interface Methods showsPrec :: Int -> Mode -> ShowS show :: Mode -> String showList :: [Mode] -> ShowS

displayContext :: Output -> DisplayRegion -> IO DisplayContext Source #

outputPicture :: DisplayContext -> Picture -> IO () Source #

Displays the given `Picture`.

1. The image is cropped to the display size.
2. Converted into a sequence of attribute changes and text spans.
3. The cursor is hidden.
4. Serialized to the display.
5. The cursor is then shown and positioned or kept hidden.

initialAssumedState :: AssumedState Source #

limitAttrForDisplay :: Output -> Attr -> Attr Source #

Not all terminals support all display attributes. This filters a display attribute to what the given terminal can display.