Safe Haskell | None |
---|
- outputForConfig :: Config -> IO Output
- setCursorPos :: MonadIO m => Output -> Int -> Int -> m ()
- hideCursor :: MonadIO m => Output -> m ()
- showCursor :: MonadIO m => Output -> m ()
- data Output = Output {
- terminalID :: String
- releaseTerminal :: MonadIO m => m ()
- reserveDisplay :: MonadIO m => m ()
- releaseDisplay :: MonadIO m => m ()
- displayBounds :: MonadIO m => m DisplayRegion
- outputByteBuffer :: ByteString -> IO ()
- contextColorCount :: Int
- supportsCursorVisibility :: Bool
- assumedStateRef :: IORef AssumedState
- mkDisplayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContext
- data AssumedState = AssumedState {}
- 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 ()
- outputPicture :: MonadIO m => DisplayContext -> Picture -> m ()
- displayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContext
Documentation
outputForConfig :: Config -> IO OutputSource
Returns a Output
for the terminal specified in Config
The specific Output implementation used is hidden from the API user. All terminal implementations are assumed to perform more, or less, the same. Currently, all implementations use terminfo for at least some terminal specific information.
Specifics about it being based on terminfo are hidden from the API user. If a terminal implementation is developed for a terminal without terminfo support then Vty should work as expected on that terminal.
Selection of a terminal is done as follows:
- If TERM == xterm then the terminal might be one of the Mac OS X .app terminals. Check if that might be the case and use MacOSX if so. otherwise use XTermColor.
- for any other TERM value TerminfoBased is used.
To differentiate between Mac OS X terminals this uses the TERM_PROGRAM environment variable. However, an xterm started by Terminal or iTerm *also* has TERM_PROGRAM defined since the environment variable is not reset/cleared by xterm. However a Terminal.app or iTerm.app started from an xterm under X11 on mac os x will likely be done via open. Since this does not propogate environment variables (I think?) this assumes that XTERM_VERSION will never be set for a true Terminal.app or iTerm.app session.
todo add an implementation for windows that does not depend on terminfo. Should be installable with only what is provided in the haskell platform. Use ansi-terminal
setCursorPos :: MonadIO m => Output -> Int -> Int -> m ()Source
Sets the cursor position to the given output column and row.
This is not necessarially the same as the character position with the same coordinates. Characters can be a variable number of columns in width.
Currently, the only way to set the cursor position to a given character coordinate is to specify the coordinate in the Picture instance provided to outputPicture or refresh.
hideCursor :: MonadIO m => Output -> m ()Source
Hides the cursor
showCursor :: MonadIO m => Output -> m ()Source
Shows the cursor
Output | |
|
data DisplayContext Source
DisplayContext | |
|
outputPicture :: MonadIO m => DisplayContext -> Picture -> m ()Source
Displays the given Picture
.
- The image is cropped to the display size.
- Converted into a sequence of attribute changes and text spans.
- The cursor is hidden.
- Serialized to the display.
- The cursor is then shown and positioned or kept hidden.
todo: specify possible IO exceptions. abstract from IO monad to a MonadIO instance.
displayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContextSource