vty-5.16: A simple terminal UI library

Safe Haskell | None
Language | Haskell2010

Graphics.Vty.Span

Description

A picture is translated into a sequences of state changes and character spans. The attribute is applied to all following spans, including spans of the next row. The nth element of the sequence represents the nth row (from top to bottom) of the picture to render.

A span op sequence will be defined for all rows and columns (and no more) of the region provided with the picture to `spansForPic`.

Synopsis

- data SpanOp
  - = TextSpan {
    - textSpanAttr :: !Attr
    - textSpanOutputWidth :: !Int
    - textSpanCharWidth :: !Int
    - textSpanText :: DisplayText
    }
  - | Skip !Int
  - | RowEnd !Int
- type SpanOps = Vector SpanOp
- dropOps :: Int -> SpanOps -> SpanOps
- splitOpsAt :: Int -> SpanOps -> (SpanOps, SpanOps)
- type DisplayOps = Vector SpanOps
- displayOpsColumns :: DisplayOps -> Int
- displayOpsRows :: DisplayOps -> Int
- affectedRegion :: DisplayOps -> DisplayRegion
- spanOpsEffectedColumns :: SpanOps -> Int
- spanOpHasWidth :: SpanOp -> Maybe (Int, Int)
- columnsToCharOffset :: Int -> SpanOp -> Int

# Documentation

data SpanOp Source #

This represents an operation on the terminal: either an attribute change or the output of a text string.

Constructors

TextSpan | A span of UTF-8 text occupies a specific number of screen space columns. A single UTF character does not necessarily represent 1 colunm. See Codec.Binary.UTF8.Width TextSpan [Attr] [output width in columns] [number of characters] [data]

Fields

- textSpanAttr :: !Attr
- textSpanOutputWidth :: !Int
- textSpanCharWidth :: !Int
- textSpanText :: DisplayText

Skip !Int | Skips the given number of columns.
RowEnd !Int | Marks the end of a row. Specifies how many columns are remaining. These columns will not be explicitly overwritten with the span ops. The terminal is require to assure the remaining columns are clear.

Instances

Eq SpanOp Source # |
Methods (==) :: SpanOp -> SpanOp -> Bool # (/=) :: SpanOp -> SpanOp -> Bool #
Show SpanOp Source # |
Methods showsPrec :: Int -> SpanOp -> ShowS # show :: SpanOp -> String # showList :: [SpanOp] -> ShowS #

type SpanOps = Vector SpanOp Source #

A vector of span operations executed in succession. This represents the operations required to render a row of the terminal. The operations in one row may affect subsequent rows. For example, setting the foreground color in one row will affect all subsequent rows until the foreground color is changed.

dropOps :: Int -> SpanOps -> SpanOps Source #

splitOpsAt :: Int -> SpanOps -> (SpanOps, SpanOps) Source #

type DisplayOps = Vector SpanOps Source #

A vector of span operation vectors for display, one per row of the output region.

displayOpsColumns :: DisplayOps -> Int Source #

The number of columns the DisplayOps are defined for.

All spans are verified to define same number of columns.

displayOpsRows :: DisplayOps -> Int Source #

The number of rows the DisplayOps are defined for.

affectedRegion :: DisplayOps -> DisplayRegion Source #

spanOpsEffectedColumns :: SpanOps -> Int Source #

The number of columns a SpanOps affects.

spanOpHasWidth :: SpanOp -> Maybe (Int, Int) Source #

The width of a single SpanOp in columns.

columnsToCharOffset :: Int -> SpanOp -> Int Source #

The number of columns to the character at the given position in the span op.