on master help sign in
-

Ignore-this: cf8f3d06e3c2fe5d580ea699b838e222 darcs-hash:20091109020018-f0a0d-01d08870acd6f1479c676d85e0c2c1590a0525f5.gz

commitf3f6af59899805f26fdbe3da0735b03cf3d8a6aa authorcoreyoconnor <coreyoconnor@gmail.com> dateSun 8 Nov 2009, 18:00 (17 years ago) parenta9c1532
6 files changed+42−10
src/Graphics/Vty/AttributeChange.hs+6−8 src/Graphics/Vty/DisplayAttributes.hs+17−1 test/Makefile+2−1 test/Verify/Graphics/Vty/DisplayAttributes.hs+8 test/verify_display_attributes.hs+9 test/verify_control_strings.hs → test/verify_parse_terminfo_caps.hs
src/Graphics/Vty/AttributeChange.hs+6−8
@@ -8,20 +8,18 @@ import Graphics.Vty.Terminal.Generic
88
99import Control.Monad.State.Strict
1010
11−data ChangeState = ChangeState
12− { change_sequence :: ()
13− }
14−
15−type AttrChange v = State ChangeState v
11+type AttrChange v = State DisplayAttrDiff v
1612
1713back_color :: Color -> AttrChange ()
18−back_color c = return ()
14+back_color c = modify $ \ChangeState cs -> cs `mappend` [ DisplayAttrDiff [] NoColorChange ( SetTo c ) ]
1915
2016style :: Style -> AttrChange ()
21−style s = return ()
17+style s = modify $ \ChangeState cs -> cs `mappend` [ DisplayAttrDiff NoColorChange NoColorChange ]
18+
19+diff_styles :: Style -> Style -> [StyleStateChange]
2220
2321default_all :: AttrChange ()
24−default_all = return ()
22+default_all = modify $ \ChangeState cs -> cs `mappend` [ DisplayAttrDiff remove_all_styles ColorToDefault ColorToDefault ]
2523
2624put_attr_change :: TerminalHandle -> AttrChange () -> IO ()
2725put_attr_change t c = do
src/Graphics/Vty/DisplayAttributes.hs+17−1
@@ -1,10 +1,11 @@
1+{-# LANGUAGE BangPatterns #-}
12module Graphics.Vty.DisplayAttributes
23 where
34
45import Graphics.Vty.Attributes
56
67import Data.Bits ( (.&.) )
7−import Data.Monoid ( mconcat )
8+import Data.Monoid ( Monoid(..), mconcat )
89
910-- | Given the previously applied display attributes as a FixedAttr and the current display
1011-- attributes as an Attr produces a FixedAttr that represents the current display attributes. This
@@ -29,6 +30,21 @@ data DisplayAttrDiff = DisplayAttrDiff
2930 , back_color_diff :: DisplayColorDiff
3031 }
3132
33+instance Monoid DisplayAttrDiff where
34+ mempty = DisplayAttrDiff [] NoColorChange NoColorChange
35+ mappend d_0 d_1 =
36+ let ds = simplify_style_diffs ( style_diffs d_0 ) ( style_diffs d_1 )
37+ fcd = simplify_color_diffs ( fore_color_diff d_0 ) ( fore_color_diff d_1 )
38+ bcd = simplify_color_diffs ( back_color_diff d_0 ) ( back_color_diff d_1 )
39+ in DisplayAttrDiff ds fcd bcd
40+
41+simplify_style_diffs :: [ StyleStateChange ] -> [ StyleStateChange ] -> [ StyleStateChange ]
42+simplify_style_diffs cs_0 cs_1 = cs_0 `mappend` cs_1
43+
44+simplify_color_diffs _cd ColorToDefault = ColorToDefault
45+simplify_color_diffs cd NoColorChange = cd
46+simplify_color_diffs _cd ( SetColor !c ) = SetColor c
47+
3248data DisplayColorDiff
3349 = ColorToDefault
3450 | NoColorChange
test/Makefile+2−1
@@ -1,6 +1,7 @@
11VERIF_TESTS := \
22verify_attribute_ops \
3−verify_control_strings \
3+verify_display_attributes \
4+verify_parse_terminfo_caps \
45verify_utf8_width \
56verify_image_ops \
67verify_image_trans \
test/Verify/Graphics/Vty/DisplayAttributes.hsnew file+8
@@ -0,0 +1,8 @@
1+module Verify.Graphics.Vty.DisplayAttributes ( module Verify.Graphics.Vty.DisplayAttributes
2+ , module Graphics.Vty.DisplayAttributes
3+ )
4+ where
5+
6+import Graphics.Vty.DisplayAttributes
7+import Verify
8+
test/verify_display_attributes.hsnew file+9
@@ -0,0 +1,9 @@
1+module Main where
2+
3+import Verify.Graphics.Vty.DisplayAttributes
4+import Verify.Graphics.Vty.Attributes
5+
6+import Verify
7+
8+main = run_test $ do
9+ return ()
test/verify_control_strings.hs → test/verify_parse_terminfo_caps.hsrenamed

The content is the same.