on ae06339 help sign in
vty/src/Graphics/Vty/Picture.hs
72 lines 2.8 kB history raw
1-- Copyright 2009-2010 Corey O'Connor
2module Graphics.Vty.Picture ( module Graphics.Vty.Picture
3 , Image
4 , image_width
5 , image_height
6 , (<|>)
7 , (<->)
8 , horiz_cat
9 , vert_cat
10 , background_fill
11 , char
12 , string
13 , iso_10646_string
14 , utf8_string
15 , utf8_bytestring
16 , char_fill
17 , empty_image
18 , translate
19 -- | The possible display attributes used in constructing an `Image`.
20 , module Graphics.Vty.Attributes
21 )
22 where
24import Graphics.Vty.Attributes
25import Graphics.Vty.Image hiding ( attr )
27import Data.Word
29-- |The type of images to be displayed using 'update'.
30-- Can be constructed directly or using `pic_for_image`. Which provides an initial instance with
31-- reasonable defaults for pic_cursor and pic_background.
32data Picture = Picture
33 { pic_cursor :: Cursor
34 , pic_image :: Image
35 , pic_background :: Background
36 }
38-- | Create a picture for display for the given image. The picture will not have a displayed cursor
39-- and the background display attribute will be `current_attr`.
40pic_for_image :: Image -> Picture
41pic_for_image i = Picture
42 { pic_cursor = NoCursor
43 , pic_image = i
44 , pic_background = Background ' ' current_attr
45 }
47-- | A picture can be configured either to not show the cursor or show the cursor at the specified
48-- character position.
49--
50-- There is not a 1 to 1 map from character positions to a row and column on the screen due to
51-- characters that take more than 1 column.
52--
53-- todo: The Cursor can be given a (character,row) offset outside of the visible bounds of the
54-- output region. In this case the cursor will not be shown.
55data Cursor =
56 NoCursor
57 | Cursor Word Word
59-- | Unspecified regions are filled with the picture's background pattern. The background pattern
60-- can specify a character and a display attribute. If the display attribute used previously should
61-- be used for a background fill then use `current_attr` for the background attribute. This is the
62-- default background display attribute.
63--
64-- (tofix) The current attribute is always set to the default attributes at the start of updating the
65-- screen to a picture.
66--
67-- (tofix) The background character *must* occupy a single column and no more.
68data Background = Background
69 { background_char :: Char
70 , background_attr :: Attr
71 }