vty-4.7.0.20: A simple terminal UI library

Safe Haskell | None

Graphics.Vty.Picture

Synopsis

- data Picture = Picture {
  - pic_cursor :: Cursor
  - pic_image :: Image
  - pic_background :: Background
  }
- pic_for_image :: Image -> Picture
- data Cursor
  - = NoCursor
  - | Cursor Word Word
- data Background = Background {
  - background_char :: Char
  - background_attr :: Attr
  }
- data Image
- image_width :: Image -> Word
- image_height :: Image -> Word
- (<|>) :: Image -> Image -> Image
- (<->) :: Image -> Image -> Image
- horiz_cat :: [Image] -> Image
- vert_cat :: [Image] -> Image
- background_fill :: Word -> Word -> Image
- char :: Attr -> Char -> Image
- string :: Attr -> String -> Image
- iso_10646_string :: Attr -> String -> Image
- utf8_string :: Attr -> [Word8] -> Image
- utf8_bytestring :: Attr -> ByteString -> Image
- char_fill :: Enum d => Attr -> Char -> d -> d -> Image
- empty_image :: Image
- translate :: (Int, Int) -> Image -> Image
- crop :: (Word, Word) -> Image -> Image
- pad :: (Word, Word) -> Image -> Image
- module Graphics.Vty.Attributes

# Documentation

data Picture Source

The type of images to be displayed using `update`. Can be constructed directly or using `pic_for_image`. Which provides an initial instance with reasonable defaults for pic_cursor and pic_background.

Constructors

Picture |

Fields

pic_cursor :: Cursor
pic_image :: Image
pic_background :: Background

Instances

Show Picture |

pic_for_image :: Image -> Picture Source

Create a picture for display for the given image. The picture will not have a displayed cursor and the background display attribute will be `current_attr`.

data Cursor Source

A picture can be configured either to not show the cursor or show the cursor at the specified character position.

There is not a 1 to 1 map from character positions to a row and column on the screen due to characters that take more than 1 column.

todo: The Cursor can be given a (character,row) offset outside of the visible bounds of the output region. In this case the cursor will not be shown.

Constructors

NoCursor |
Cursor Word Word |

data Background Source

Unspecified regions are filled with the picture's background pattern. The background pattern can specify a character and a display attribute. If the display attribute used previously should be used for a background fill then use `current_attr` for the background attribute. This is the default background display attribute.

(tofix) The current attribute is always set to the default attributes at the start of updating the screen to a picture.

(tofix) The background character *must* occupy a single column and no more.

Constructors

Background |

Fields

background_char :: Char
background_attr :: Attr

data Image Source

An image in VTY defines:

- properties required to display the image. These are properties that effect the output image but are independent of position
- A set of position-dependent text and attribute regions. The possible regions are:
- a point. ( char )
- a horizontal line of characters with a single attribute. (string, utf8_string, utf8_bytestring )
- a fill of a single character. (char_fill)
- a fill of the picture's background. (background_fill)

todo: increase the number of encoded bytestring formats supported.

Instances

Eq Image |
Show Image |
Monoid Image | Currently append in the Monoid instance is equivalent to -.

image_width :: Image -> Word Source

The width of an Image. This is the number display columns the image will occupy.

image_height :: Image -> Word Source

The height of an Image. This is the number of display rows the image will occupy.

(<|>) :: Image -> Image -> Image Source

Combines two images side by side.

The result image will have a width equal to the sum of the two images width. And the height will equal the largest height of the two images. The area not defined in one image due to a height missmatch will be filled with the background pattern.

(<->) :: Image -> Image -> Image Source

Combines two images vertically. The result image will have a height equal to the sum of the heights of both images. The width will equal the largest width of the two images. The area not defined in one image due to a width missmatch will be filled with the background pattern.

horiz_cat :: [Image] -> Image Source

Compose any number of images horizontally.

vert_cat :: [Image] -> Image Source

Compose any number of images vertically.

background_fill :: Word -> Word -> Image Source

An area of the picture's bacground (See Background) of w columns and h rows.

char :: Attr -> Char -> Image Source

an image of a single character. This is a standard Haskell 31-bit character assumed to be in the ISO-10646 encoding.

string :: Attr -> String -> Image Source

Alias for iso_10646_string. Since the usual case is that a literal string like foo is represented internally as a list of ISO 10646 31 bit characters.

Note: Keep in mind that GHC will compile source encoded as UTF-8 but the literal strings, while UTF-8 encoded in the source, will be transcoded to a ISO 10646 31 bit characters runtime representation.

iso_10646_string :: Attr -> String -> Image Source

A string of characters layed out on a single row with the same display attribute. The string is assumed to be a sequence of ISO-10646 characters.

Note: depending on how the Haskell compiler represents string literals a string literal in a UTF-8 encoded source file, for example, may be represented as a ISO-10646 string. That is, I think, the case with GHC 6.10. This means, for the most part, you don't need to worry about the encoding format when outputting string literals. Just provide the string literal directly to iso_10646_string or string.

utf8_string :: Attr -> [Word8] -> Image Source

A string of characters layed out on a single row. The string is assumed to be a sequence of UTF-8 characters.

utf8_bytestring :: Attr -> ByteString -> Image Source

Renders a UTF-8 encoded bytestring.

char_fill :: Enum d => Attr -> Char -> d -> d -> Image Source

creates a fill of the specified character. The dimensions are in number of characters wide and number of rows high.

Unlike the Background fill character this character can have double column display width.

empty_image :: Image Source

The empty image. Useful for fold combinators. These occupy no space nor define any display attributes.

translate :: (Int, Int) -> Image -> Image Source

Apply the given offset to the image.

crop :: (Word, Word) -> Image -> Image Source

Ensure an image is no larger than the provided size. If the image is larger then crop.

pad :: (Word, Word) -> Image -> Image Source

Ensure an image is at least the provided size. If the image is smaller then pad.

The possible display attributes used in constructing an `Image`.

module Graphics.Vty.Attributes