on master help sign in
documentation fixes
41c42dfCorey O'Connor
src/Graphics/Vty.hs+15−4
@@ -1,15 +1,26 @@
1−-- | Vty supports input and output to terminal devices. The input is provides as a sequence of
1+-- | Vty supports input and output to terminal devices.
2+--
3+-- - The input is provides as a sequence of 'Event's.
4+--
2−-- 'Event's. The output is defined by a 'Picture'. Which is one or more layers of 'Image's.
5+-- - The output is defined by a 'Picture'. Which is one or more layers of 'Image's.
3−--
6+-- The constructors in "Graphics.Vty.Image.Internal" should not be used directly. The module
4−-- - References
7+-- "Graphics.Vty.Image" provides a number of constructor equations that will build correct
8+-- 'Image' values. See 'string', '<|>', and '<->' for starters.
5--
9--
10+-- - 'Image's can be styled using 'Attr'. See "Graphics.Vty.Attributes".
11+--
6-- Good sources of documentation for terminal programming are:
12-- Good sources of documentation for terminal programming are:
7--
13--
8-- - <https://github.com/b4winckler/vim/blob/master/src/term.c>
14-- - <https://github.com/b4winckler/vim/blob/master/src/term.c>
15+--
9-- - <http://invisible-island.net/xterm/ctlseqs/ctlseqs.html>
16-- - <http://invisible-island.net/xterm/ctlseqs/ctlseqs.html>
17+--
10-- - <http://ulisse.elettra.trieste.it/services/doc/serial/config.html>
18-- - <http://ulisse.elettra.trieste.it/services/doc/serial/config.html>
19+--
11-- - <http://www.leonerd.org.uk/hacks/hints/xterm-8bit.html>
20-- - <http://www.leonerd.org.uk/hacks/hints/xterm-8bit.html>
21+--
12-- - <http://www.unixwiz.net/techtips/termios-vmin-vtime.html>
22-- - <http://www.unixwiz.net/techtips/termios-vmin-vtime.html>
23+--
13-- - <<http://vt100.net/docs/vt100-ug/chapter3.html vt100 control sequences>
24-- - <<http://vt100.net/docs/vt100-ug/chapter3.html vt100 control sequences>
14module Graphics.Vty ( Vty(..)
25module Graphics.Vty ( Vty(..)
15 , mkVty
26 , mkVty
src/Graphics/Vty/Image/Internal.hs+16−7
@@ -1,4 +1,5 @@
1{-# LANGUAGE NamedFieldPuns #-}
1{-# LANGUAGE NamedFieldPuns #-}
2+{-# OPTIONS_HADDOCK hide #-}
2module Graphics.Vty.Image.Internal where
3module Graphics.Vty.Image.Internal where
3
4
4import Graphics.Vty.Attributes
5import Graphics.Vty.Attributes
@@ -37,21 +38,29 @@ clip_text txt left_skip right_clip =
37 clip_for_char_width _ _ _ = error "clip_for_char_width applied to undefined"
38 clip_for_char_width _ _ _ = error "clip_for_char_width applied to undefined"
38 in txt''
39 in txt''
39
40
40−-- | An image in VTY is
41+-- | This is the internal representation of Images. Use the constructors in "Graphics.Vty.Image" to
42+-- create instances.
41--
43--
42−-- * a horizontal line of characters with a single attribute.
44+-- Images are:
45+--
46+-- * a horizontal span of text
47+--
48+-- * a horizontal or vertical join of two images
49+--
43−-- * a fill of the picture's background. (background_fill)
50+-- * a two dimensional fill of the 'Picture's background character
44−-- * a horizontal and vertical crops from both directions.
51+--
45−-- * horizontal and vertical combinations
52+-- * a cropped image
53+--
54+-- * an empty image of no size or content.
46data Image =
55data Image =
47 -- | A horizontal text span is always >= 1 column and has a row height of 1.
56 -- | A horizontal text span is always >= 1 column and has a row height of 1.
48 HorizText
57 HorizText
49 { attr :: Attr
58 { attr :: Attr
50 -- | The text to display. The display width of the text is always output_width.
59 -- | The text to display. The display width of the text is always output_width.
51 , display_text :: DisplayText
60 , display_text :: DisplayText
52− -- | The number of display columns for the text.
61+ -- | The number of display columns for the text. Always > 0.
53 , output_width :: Int
62 , output_width :: Int
54− -- | the number of characters in the text.
63+ -- | the number of characters in the text. Always > 0.
55 , char_width :: Int
64 , char_width :: Int
56 }
65 }
57 -- | A horizontal join can be constructed between any two images. However a HorizJoin instance is
66 -- | A horizontal join can be constructed between any two images. However a HorizJoin instance is
src/Graphics/Vty/Input.hs+1−3
@@ -1,6 +1,4 @@
1−-- Copyright 2009-2010 Corey O'Connor
2−--
3−-- Right, I'm mostly guessing on these details. So, as far as I can figure:
1+-- | Right, I'm mostly guessing on these details. So, as far as I can figure:
4--
2--
5-- There are two input modes:
3-- There are two input modes:
6-- 1. 7 bit
4-- 1. 7 bit
src/Graphics/Vty/Output.hs+9−11
@@ -7,24 +7,22 @@
7-- 1. "Graphics.Vty.Output": This instantiates an abtract interface to the terminal interface based
7-- 1. "Graphics.Vty.Output": This instantiates an abtract interface to the terminal interface based
8-- on the TERM and COLORTERM environment variables.
8-- on the TERM and COLORTERM environment variables.
9--
9--
10−-- 2. Graphics.Vty.Output.Interface: Defines the generic interface all terminals need to implement.
10+-- 2. "Graphics.Vty.Output.Interface": Defines the generic interface all terminals need to implement.
11--
11--
12−-- 3. Graphics.Vty.Output.TerminfoBased: Defines a terminal instance that uses terminfo for all
12+-- 3. "Graphics.Vty.Output.TerminfoBased": Defines a terminal instance that uses terminfo for all
13-- control strings. No attempt is made to change the character set to UTF-8 for these terminals.
13-- control strings. No attempt is made to change the character set to UTF-8 for these terminals.
14-- I don't know a way to reliably determine if that is required or how to do so.
14-- I don't know a way to reliably determine if that is required or how to do so.
15--
15--
16−-- 4. Graphics.Vty.Output.XTermColor: This module contains an interface suitable for xterm-like
16+-- 4. "Graphics.Vty.Output.XTermColor": This module contains an interface suitable for xterm-like
17-- terminals. These are the terminals where TERM == xterm. This does use terminfo for as many
17-- terminals. These are the terminals where TERM == xterm. This does use terminfo for as many
18-- control codes as possible.
18-- control codes as possible.
19−--
20−-- Copyright 2009-2010 Corey O'Connor
21module Graphics.Vty.Output ( module Graphics.Vty.Output
19module Graphics.Vty.Output ( module Graphics.Vty.Output
22− , Output(..) -- \todo hide constructors
20+ , Output(..) -- \todo hide constructors
23− , AssumedState(..)
21+ , AssumedState(..)
24− , DisplayContext(..) -- \todo hide constructors
22+ , DisplayContext(..) -- \todo hide constructors
25− , output_picture
23+ , output_picture
26− , display_context
24+ , display_context
27− )
25+ )
28 where
26 where
29
27
30
28
src/Graphics/Vty/Picture.hs+10−5
@@ -14,6 +14,7 @@ import Graphics.Vty.Image
14import Control.DeepSeq
14import Control.DeepSeq
15
15
16-- | The type of images to be displayed using 'update'.
16-- | The type of images to be displayed using 'update'.
17+--
17-- Can be constructed directly or using `pic_for_image`. Which provides an initial instance with
18-- Can be constructed directly or using `pic_for_image`. Which provides an initial instance with
18-- reasonable defaults for pic_cursor and pic_background.
19-- reasonable defaults for pic_cursor and pic_background.
19data Picture = Picture
20data Picture = Picture
@@ -28,12 +29,15 @@ instance Show Picture where
28instance NFData Picture where
29instance NFData Picture where
29 rnf (Picture c l b) = c `deepseq` l `deepseq` b `deepseq` ()
30 rnf (Picture c l b) = c `deepseq` l `deepseq` b `deepseq` ()
30
31
32+-- | a picture with no cursor, background or image layers
31empty_picture :: Picture
33empty_picture :: Picture
32empty_picture = Picture NoCursor [] ClearBackground
34empty_picture = Picture NoCursor [] ClearBackground
33
35
36+-- | The given 'Image' is added as the top layer of the 'Picture'
34add_to_top :: Picture -> Image -> Picture
37add_to_top :: Picture -> Image -> Picture
35add_to_top p i = p {pic_layers = i : pic_layers p}
38add_to_top p i = p {pic_layers = i : pic_layers p}
36
39
40+-- | The given 'Image' is added as the bottom layer of the 'Picture'
37add_to_bottom :: Picture -> Image -> Picture
41add_to_bottom :: Picture -> Image -> Picture
38add_to_bottom p i = p {pic_layers = pic_layers p ++ [i]}
42add_to_bottom p i = p {pic_layers = pic_layers p ++ [i]}
39
43
@@ -48,7 +52,7 @@ pic_for_image i = Picture
48
52
49-- | Create a picture for display with the given layers. Ordered top to bottom.
53-- | Create a picture for display with the given layers. Ordered top to bottom.
50--
54--
51−-- The first image is the top layer.
55+-- The first 'Image' is the top layer.
52pic_for_layers :: [Image] -> Picture
56pic_for_layers :: [Image] -> Picture
53pic_for_layers is = Picture
57pic_for_layers is = Picture
54 { pic_cursor = NoCursor
58 { pic_cursor = NoCursor
@@ -72,10 +76,11 @@ instance NFData Cursor where
72 rnf NoCursor = ()
76 rnf NoCursor = ()
73 rnf (Cursor w h) = w `seq` h `seq` ()
77 rnf (Cursor w h) = w `seq` h `seq` ()
74
78
75−-- | Unspecified regions are filled with the picture's background pattern. The background pattern
79+-- | A 'Picture' has a background pattern. The background is either ClearBackground. Which shows the
80+-- layer below or is blank if the bottom layer. Or the background pattern is a character and a
76−-- can specify a character and a display attribute. If the display attribute used previously should
81+-- display attribute. If the display attribute used previously should be used for a background fill
77−-- be used for a background fill then use `current_attr` for the background attribute. This is the
82+-- then use `current_attr` for the background attribute. This is the default background display
78−-- default background display attribute.
83+-- attribute.
79--
84--
80-- \todo The current attribute is always set to the default attributes at the start of updating the
85-- \todo The current attribute is always set to the default attributes at the start of updating the
81-- screen to a picture.
86-- screen to a picture.
vty.cabal+1−1
@@ -34,6 +34,7 @@ data-files: README.md,
34 AUTHORS,
34 AUTHORS,
35 CHANGELOG,
35 CHANGELOG,
36 LICENSE
36 LICENSE
37+tested-with: ghc >= 7.6.2
37
38
38library
39library
39 default-language: Haskell2010
40 default-language: Haskell2010
@@ -105,7 +106,6 @@ library
105 ghc-prof-options: -O2 -funbox-strict-fields -threaded -caf-all -Wall -fspec-constr -fspec-constr-count=10
106 ghc-prof-options: -O2 -funbox-strict-fields -threaded -caf-all -Wall -fspec-constr -fspec-constr-count=10
106
107
107 cc-options: -O2
108 cc-options: -O2
108− tested-with: ghc >= 7.6.2
109
109
110test-suite verify-attribute-ops
110test-suite verify-attribute-ops
111 default-language: Haskell2010
111 default-language: Haskell2010