vty-4.7.3: A simple terminal UI library

Safe HaskellNone

Graphics.Vty.Image

Synopsis

Documentation

type DisplayString = Seq (Char, Word)Source

We pair each character with it's display length. This way we only compute the length once per character. * Though currently the width of some strings is still compute multiple times.

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 -> WordSource

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

image_height :: Image -> WordSource

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

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

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 -> ImageSource

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] -> ImageSource

Compose any number of images horizontally.

vert_cat :: [Image] -> ImageSource

Compose any number of images vertically.

background_fill :: Word -> Word -> ImageSource

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

char :: Attr -> Char -> ImageSource

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 -> ImageSource

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 -> ImageSource

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] -> ImageSource

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 -> ImageSource

Renders a UTF-8 encoded bytestring.

char_fill :: Enum d => Attr -> Char -> d -> d -> ImageSource

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 :: ImageSource

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

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

Apply the given offset to the image.

safe_wcwidth :: Char -> WordSource

Returns the display width of a character. Assumes all characters with unknown widths are 1 width

safe_wcswidth :: String -> WordSource

Returns the display width of a string. Assumes all characters with unknown widths are 1 width

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

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

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

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.