1{-# LANGUAGE BangPatterns #-}
2-- | The Picture data structure is representative of the final terminal view.
4-- This module re-exports most of the Graphics.Vty.Image and Graphics.Vty.Attributes modules.
6-- Copyright 2009-2010 Corey O'Connor
7module Graphics.Vty.Picture ( module Graphics.Vty.Picture
8 , module Graphics.Vty.Image
12import Graphics.Vty.Image
16-- | The type of images to be displayed using 'update'.
17-- Can be constructed directly or using `pic_for_image`. Which provides an initial instance with
18-- reasonable defaults for pic_cursor and pic_background.
20 { pic_cursor :: Cursor
21 , pic_layers :: [Image]
22 , pic_background :: Background
25instance Show Picture where
26 show (Picture _ layers _ ) = "Picture ?? " ++ show layers ++ " ??"
28instance NFData Picture where
29 rnf (Picture c l b) = c `deepseq` l `deepseq` b `deepseq` ()
31-- | Create a picture for display for the given image. The picture will not have a displayed cursor
32-- and the background display attribute will be `current_attr`.
33pic_for_image :: Image -> Picture
34pic_for_image i = Picture
35 { pic_cursor = NoCursor
37 , pic_background = ClearBackground
40-- | Create a picture for display with the given layers. Ordered top to bottom.
42-- The first image is the top layer.
43pic_for_layers :: [Image] -> Picture
44pic_for_layers is = Picture
45 { pic_cursor = NoCursor
47 , pic_background = ClearBackground
50-- | A picture can be configured either to not show the cursor or show the cursor at the specified
53-- There is not a 1 to 1 map from character positions to a row and column on the screen due to
54-- characters that take more than 1 column.
56-- todo: The Cursor can be given a (character,row) offset outside of the visible bounds of the
57-- output region. In this case the cursor will not be shown.
62instance NFData Cursor where
64 rnf (Cursor w h) = w `seq` h `seq` ()
66-- | Unspecified regions are filled with the picture's background pattern. The background pattern
67-- can specify a character and a display attribute. If the display attribute used previously should
68-- be used for a background fill then use `current_attr` for the background attribute. This is the
69-- default background display attribute.
71-- \todo The current attribute is always set to the default attributes at the start of updating the
72-- screen to a picture.
75 { background_char :: Char
76 , background_attr :: Attr
78 -- | The background is:
80 -- * the space character if there are remaining non-skip ops
81 -- * (?) nothing if there are no remaining non-skip ops.
83 -- Might require the terminal interface to do a line clear?
84 -- Or should the nothing case be switched with crlf?
87instance NFData Background where
88 rnf (Background c a) = c `seq` a `seq` ()
89 rnf ClearBackground = ()
91-- | Compatibility with applications that do not use more than a single layer.
92pic_image :: Picture -> Image
93pic_image = head . pic_layers
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list