vty-5.2.5: A simple terminal UI library

Safe HaskellNone

Graphics.Vty.Image

Synopsis

Documentation

type DisplayText = TextSource

A display text is a Data.Text.Lazy

TODO(corey): hm. there is an explicit equation for each type which goes to a lazy text. Each application probably uses a single type. Perhaps parameterize the entire vty interface by the input text type? TODO: Try using a builder instead of a TL.Text instance directly. That might improve performance for the usual case of appending a bunch of characters with the same attribute together.

data Image Source

This is the internal representation of Images. Use the constructors in Graphics.Vty.Image to create instances.

Images are:

  • a horizontal span of text
  • a horizontal or vertical join of two images
  • a two dimensional fill of the Pictures background character
  • a cropped image
  • an empty image of no size or content.

Instances

Eq Image 
Show Image 
Monoid Image

Append in the Monoid instance is equivalent to -.

NFData Image 

imageWidth :: Image -> IntSource

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

imageHeight :: Image -> IntSource

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

horizJoin :: Image -> Image -> ImageSource

combines two images side by side

Combines text chunks where possible. Assures outputWidth and outputHeight properties are not violated.

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.

TODO: the bg fill is biased towards top to bottom languages(?)

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

Combines two images horizontally. Alias for horizJoin

infixr 5

vertJoin :: 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.

TODO: the bg fill is biased towards right to left languages(?)

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

Combines two images vertically. Alias for vertJoin

infixr 4

horizCat :: [Image] -> ImageSource

Compose any number of images horizontally.

vertCat :: [Image] -> ImageSource

Compose any number of images vertically.

backgroundFill :: Int -> Int -> ImageSource

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

text :: Attr -> Text -> ImageSource

A Data.Text.Lazy value

text' :: Attr -> Text -> ImageSource

A Data.Text value

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 iso10646String. 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.

iso10646String :: 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 iso10646String or string.

utf8String :: Attr -> [Word8] -> ImageSource

A string of characters layed out on a single row. The input is assumed to be the bytes for UTF-8 encoded text.

utf8Bytestring :: Attr -> ByteString -> ImageSource

Renders a UTF-8 encoded lazy bytestring.

utf8Bytestring' :: Attr -> ByteString -> ImageSource

Renders a UTF-8 encoded strict bytestring.

charFill :: Integral 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.

emptyImage :: ImageSource

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

safeWcwidth :: Char -> IntSource

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

safeWcswidth :: String -> IntSource

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

wcwidth :: Char -> IntSource

wcswidth :: String -> IntSource

crop :: Int -> Int -> Image -> ImageSource

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

This is transformed to a vertical crop from the bottom followed by horizontal crop from the right.

cropRight :: Int -> Image -> ImageSource

ensure the image is no wider than the given width. If the image is wider then crop the right side.

cropLeft :: Int -> Image -> ImageSource

ensure the image is no wider than the given width. If the image is wider then crop the left side.

cropBottom :: Int -> Image -> ImageSource

crop the display height. If the image is less than or equal in height then this operation has no effect. Otherwise the image is cropped from the bottom.

cropTop :: Int -> Image -> ImageSource

crop the display height. If the image is less than or equal in height then this operation has no effect. Otherwise the image is cropped from the top.

pad :: Int -> Int -> Int -> Int -> Image -> ImageSource

pad the given image. This adds background character fills to the left, top, right, bottom. The pad values are how many display columns or rows to add.

resize :: Int -> Int -> Image -> ImageSource

Generic resize. Pads and crops as required to assure the given display width and height. This is biased to pad/crop the right and bottom.

resizeWidth :: Int -> Image -> ImageSource

Resize the width. Pads and crops as required to assure the given display width. This is biased to pad/crop the right.

resizeHeight :: Int -> Image -> ImageSource

Resize the height. Pads and crops as required to assure the given display height. This is biased to pad/crop the bottom.

translate :: Int -> Int -> Image -> ImageSource

translates an image by padding or cropping the top and left.

This can have an unexpected effect: Translating an image to less than (0,0) then to greater than (0,0) will crop the image.

translateX :: Int -> Image -> ImageSource

translates an image by padding or cropping the left

translateY :: Int -> Image -> ImageSource

translates an image by padding or cropping the top

The possible display attributes used in constructing an Image.