on master help sign in
-

Ignore-this: 6760a9d5f7046574c57e19e4765be2c5 darcs-hash:20091109004102-f0a0d-200c832476604fc2c2437e103b027ce64d3d879f.gz

commita9c1532905ec7c393a7ef8564adb8bdaa6f756c3 authorcoreyoconnor <coreyoconnor@gmail.com> dateSun 8 Nov 2009, 16:41 (17 years ago) parent02c916d
3 files changed+12−10
src/Graphics/Vty/DisplayAttributes.hs+3−3 src/Graphics/Vty/Terminal/Generic.hs+9−6 test/interactive_terminal_test.hs−1
src/Graphics/Vty/DisplayAttributes.hs+3−3
@@ -23,7 +23,7 @@ fix_display_attr fattr attr
2323 fix_color c KeepCurrent = c
2424 fix_color _c (SetTo c) = Just c
2525
26−data DisplayAttrDiffs = DisplayAttrDiffs
26+data DisplayAttrDiff = DisplayAttrDiff
2727 { style_diffs :: [ StyleStateChange ]
2828 , fore_color_diff :: DisplayColorDiff
2929 , back_color_diff :: DisplayColorDiff
@@ -49,8 +49,8 @@ data StyleStateChange
4949 | ApplyBold
5050 | RemoveBold
5151
52−display_attr_diffs :: FixedAttr -> FixedAttr -> DisplayAttrDiffs
53−display_attr_diffs attr attr' = DisplayAttrDiffs
52+display_attr_diffs :: FixedAttr -> FixedAttr -> DisplayAttrDiff
53+display_attr_diffs attr attr' = DisplayAttrDiff
5454 { style_diffs = diff_styles ( fixed_style attr ) ( fixed_style attr' )
5555 , fore_color_diff = diff_color ( fixed_fore_color attr ) ( fixed_fore_color attr' )
5656 , back_color_diff = diff_color ( fixed_back_color attr ) ( fixed_back_color attr' )
src/Graphics/Vty/Terminal/Generic.hs+9−6
@@ -38,9 +38,12 @@ new_terminal_handle :: forall t. Terminal t => t -> IO TerminalHandle
3838new_terminal_handle t = liftM (TerminalHandle t) initial_terminal_state
3939
4040data TerminalState = TerminalState
41+ { -- | The current terminal display attributes or Nothing if they are not known.
42+ current_attr :: Maybe FixedAttr
43+ }
4144
4245initial_terminal_state :: IO TerminalState
43−initial_terminal_state = return $ TerminalState
46+initial_terminal_state = return $ TerminalState Nothing
4447
4548class Terminal t where
4649 -- | Text identifier for the terminal. Used for debugging.
@@ -50,7 +53,7 @@ class Terminal t where
5053 -- | Clear the display and initialize the terminal to some initial display state.
5154 --
5255 -- The expectation of a program is that the display starts in some initial state.
53− -- The initial state would consist of fixed values
56+ -- The initial state would consist of fixed values:
5457 -- - cursor at top left
5558 -- - UTF-8 character encoding
5659 -- - drawing characteristics are the default
@@ -58,7 +61,6 @@ class Terminal t where
5861 -- access to a display such that:
5962 -- - The previous state cannot be determined
6063 -- - When exclusive access to a display is release the display returns to the previous state.
61− --
6264 reserve_display :: t -> IO ()
6365
6466 -- | Return the display to the state before reserve_display
@@ -136,8 +138,8 @@ class DisplayTerminal d where
136138 -- attributes. In order to support this the currently applied display attributes are required.
137139 -- In addition it may be possible to optimize the state changes based off the currently applied
138140 -- display attributes.
139− attr_required_bytes :: d -> FixedAttr -> Attr -> DisplayAttrDiffs -> Word
140− serialize_set_attr :: d -> FixedAttr -> Attr -> DisplayAttrDiffs -> OutputBuffer -> IO OutputBuffer
141+ attr_required_bytes :: d -> FixedAttr -> Attr -> DisplayAttrDiff -> Word
142+ serialize_set_attr :: d -> FixedAttr -> Attr -> DisplayAttrDiff -> OutputBuffer -> IO OutputBuffer
141143
142144 -- | Reset the display attributes to the default display attributes
143145 default_attr_required_bytes :: d -> Word
@@ -315,7 +317,8 @@ serialize_span_op :: DisplayTerminal d
315317serialize_span_op d (AttributeChange attr) out_ptr fattr = do
316318 let attr' = limit_attr_for_display d attr
317319 fattr' = fix_display_attr fattr attr'
318− out_ptr' <- serialize_set_attr d fattr attr' (display_attr_diffs fattr fattr') out_ptr
320+ diffs = display_attr_diffs fattr fattr'
321+ out_ptr' <- serialize_set_attr d fattr attr' diffs out_ptr
319322 return (out_ptr', fattr')
320323serialize_span_op _d (TextSpan _ _ str) out_ptr fattr = do
321324 out_ptr' <- serialize_utf8_text str out_ptr
test/interactive_terminal_test.hs−1
@@ -852,7 +852,6 @@ inline_test_0 = Test
852852 , test_ID = "inline_test_0"
853853 , test_action = do
854854 t <- terminal_handle
855− d <- display_bounds t >>= display_context t
856855 putStrLn "line 0."
857856 put_attr_change t $ back_color red >> style underline
858857 putStrLn "line 1."