@@ -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