vty-5.15.1: 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 :: forall m. MonadIO m => m ()
  - reserveDisplay :: forall m. MonadIO m => m ()
  - releaseDisplay :: forall m. MonadIO m => m ()
  - displayBounds :: forall m. MonadIO m => m DisplayRegion
  - outputByteBuffer :: ByteString -> IO ()
  - contextColorCount :: Int
  - supportsCursorVisibility :: Bool
  - supportsMode :: Mode -> Bool
  - setMode :: forall m. MonadIO m => Mode -> Bool -> m ()
  - getModeStatus :: forall m. MonadIO m => Mode -> m Bool
  - assumedStateRef :: IORef AssumedState
  - mkDisplayContext :: forall m. MonadIO m => Output -> DisplayRegion -> m DisplayContext
  - ringTerminalBell :: forall m. MonadIO m => m ()
  - supportsBell :: forall m. MonadIO m => m 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 :: FixedAttr -> Attr -> DisplayAttrDiff -> Write
  - writeDefaultAttr :: Write
  - writeRowEnd :: Write
  - inlineHack :: IO ()
  }
- data Mode
  - = Mouse
  - | BracketedPaste
- displayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContext
- outputPicture :: MonadIO m => DisplayContext -> Picture -> m ()
- initialAssumedState :: AssumedState
- limitAttrForDisplay :: Output -> Attr -> Attr

# Documentation

data Output #

The Vty terminal output interface.

Constructors

Output |
Fields terminalID :: String Text identifier for the output device. Used for debugging. releaseTerminal :: forall m. MonadIO m => m () Release the terminal just prior to application exit and reset it to its state prior to application startup. reserveDisplay :: forall m. MonadIO m => m () 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 :: forall m. MonadIO m => m () Return the display to the state before `reserveDisplay` If no previous state then set the display state to the initial state. displayBounds :: forall m. MonadIO m => m 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 :: forall m. MonadIO m => Mode -> Bool -> m () Enables or disables a mode (does nothing if the mode is unsupported). getModeStatus :: forall m. MonadIO m => Mode -> m Bool Returns whether a mode is enabled. assumedStateRef :: IORef AssumedState mkDisplayContext :: forall m. MonadIO m => Output -> DisplayRegion -> m 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 :: forall m. MonadIO m => m () Ring the terminal bell if supported. supportsBell :: forall m. MonadIO m => m Bool Returns whether the terminal has an audio bell feature.

data AssumedState #

Constructors

AssumedState |
Fields prevFattr :: Maybe FixedAttr prevOutputOps :: Maybe DisplayOps

data DisplayContext #

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 :: FixedAttr -> Attr -> DisplayAttrDiff -> Write writeDefaultAttr :: Write Reset the display attributes to the default display attributes. writeRowEnd :: Write inlineHack :: IO () See `inlineHack`

data Mode #

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)

Instances

Eq Mode # |
Methods (==) :: Mode -> Mode -> Bool # (/=) :: Mode -> Mode -> Bool #
Read Mode # |
Methods readsPrec :: Int -> ReadS Mode # readList :: ReadS [Mode] # readPrec :: ReadPrec Mode # readListPrec :: ReadPrec [Mode] #
Show Mode # |
Methods showsPrec :: Int -> Mode -> ShowS # show :: Mode -> String # showList :: [Mode] -> ShowS #

displayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContext #

outputPicture :: MonadIO m => DisplayContext -> Picture -> m () #

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 #

limitAttrForDisplay :: Output -> Attr -> Attr #

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