@@ -53,7 +53,7 @@ data DisplayAttrCaps = DisplayAttrCaps
53 , enter_bold_mode :: Maybe CapExpression
53 , enter_bold_mode :: Maybe CapExpression
56−marshall_cap_to_terminal :: MonadIO m => Term -> (Term -> CapExpression) -> [CapParam] -> m ()
56+marshall_cap_to_terminal :: Term -> (Term -> CapExpression) -> [CapParam] -> IO ()
57marshall_cap_to_terminal t cap_selector cap_params = do
57marshall_cap_to_terminal t cap_selector cap_params = do
58 marshall_to_terminal t ( cap_expression_required_bytes (cap_selector t) cap_params )
58 marshall_to_terminal t ( cap_expression_required_bytes (cap_selector t) cap_params )
59 ( serialize_cap_expression (cap_selector t) cap_params )
59 ( serialize_cap_expression (cap_selector t) cap_params )
@@ -128,25 +128,25 @@ instance Terminal Term where
128 terminal_ID t = term_info_ID t ++ " :: TerminfoBased"
128 terminal_ID t = term_info_ID t ++ " :: TerminfoBased"
130 release_terminal t = do
130 release_terminal t = do
131− marshall_cap_to_terminal t set_default_attr []
131+ liftIO $ marshall_cap_to_terminal t set_default_attr []
132− marshall_cap_to_terminal t cnorm []
132+ liftIO $ marshall_cap_to_terminal t cnorm []
133 return ()
133 return ()
135 reserve_display t = do
135 reserve_display t = do
136 if (isJust $ smcup t)
136 if (isJust $ smcup t)
137− then marshall_cap_to_terminal t (fromJust . smcup) []
137+ then liftIO $ marshall_cap_to_terminal t (fromJust . smcup) []
138 else return ()
138 else return ()
139 -- Screen on OS X does not appear to support smcup?
139 -- Screen on OS X does not appear to support smcup?
140 -- To approximate the expected behavior: clear the screen and then move the mouse to the
140 -- To approximate the expected behavior: clear the screen and then move the mouse to the
141 -- home position.
141 -- home position.
142− marshall_cap_to_terminal t clear_screen []
142+ liftIO $ marshall_cap_to_terminal t clear_screen []
143 return ()
143 return ()
145 release_display t = do
145 release_display t = do
146 if (isJust $ rmcup t)
146 if (isJust $ rmcup t)
147− then marshall_cap_to_terminal t (fromJust . rmcup) []
147+ then liftIO $ marshall_cap_to_terminal t (fromJust . rmcup) []
148 else return ()
148 else return ()
149− marshall_cap_to_terminal t cnorm []
149+ liftIO $ marshall_cap_to_terminal t cnorm []
150 return ()
150 return ()
152 display_terminal_instance t b c = do
152 display_terminal_instance t b c = do
@@ -166,8 +166,8 @@ instance Terminal Term where
166 output_byte_buffer _t out_ptr out_byte_count = do
166 output_byte_buffer _t out_ptr out_byte_count = do
167 if out_byte_count == 0
167 if out_byte_count == 0
168 then return ()
168 then return ()
169− else liftIO $ hPutBuf stdout out_ptr (fromEnum out_byte_count)
169+ else hPutBuf stdout out_ptr (fromEnum out_byte_count)
170− liftIO $ hFlush stdout
170+ hFlush stdout
172foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size :: IO CLong
172foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size :: IO CLong
@@ -190,17 +190,17 @@ instance DisplayTerminal DisplayContext where
190 move_cursor_required_bytes d x y
190 move_cursor_required_bytes d x y
191 = cap_expression_required_bytes (cup $ term d) [y, x]
191 = cap_expression_required_bytes (cup $ term d) [y, x]
192 serialize_move_cursor d x y out_ptr
192 serialize_move_cursor d x y out_ptr
193− = serialize_cap_expression (cup $ term d) [y, x] out_ptr
193+ = liftIO $ serialize_cap_expression (cup $ term d) [y, x] out_ptr
195 show_cursor_required_bytes d
195 show_cursor_required_bytes d
196 = cap_expression_required_bytes (cnorm $ term d) []
196 = cap_expression_required_bytes (cnorm $ term d) []
197 serialize_show_cursor d out_ptr
197 serialize_show_cursor d out_ptr
198− = serialize_cap_expression (cnorm $ term d) [] out_ptr
198+ = liftIO $ serialize_cap_expression (cnorm $ term d) [] out_ptr
200 hide_cursor_required_bytes d
200 hide_cursor_required_bytes d
201 = cap_expression_required_bytes (civis $ term d) []
201 = cap_expression_required_bytes (civis $ term d) []
202 serialize_hide_cursor d out_ptr
202 serialize_hide_cursor d out_ptr
203− = serialize_cap_expression (civis $ term d) [] out_ptr
203+ = liftIO $ serialize_cap_expression (civis $ term d) [] out_ptr
205 -- Instead of evaluating all the rules related to setting display attributes twice (once in
205 -- Instead of evaluating all the rules related to setting display attributes twice (once in
206 -- required bytes and again in serialize) or some memoization scheme just return a size
206 -- required bytes and again in serialize) or some memoization scheme just return a size
@@ -242,16 +242,16 @@ instance DisplayTerminal DisplayContext where
242 EnterExitSeq caps
242 EnterExitSeq caps
243 -- only way to reset a color to the defaults
243 -- only way to reset a color to the defaults
244 -> serialize_default_attr d out_ptr
244 -> serialize_default_attr d out_ptr
245− >>= (\out_ptr' -> foldM (\ptr cap -> serialize_cap_expression cap [] ptr) out_ptr' caps)
245+ >>= (\out_ptr' -> liftIO $ foldM (\ptr cap -> serialize_cap_expression cap [] ptr) out_ptr' caps)
246 >>= set_colors
246 >>= set_colors
247 SetState state
247 SetState state
248 -- implicitly resets the colors to the defaults
248 -- implicitly resets the colors to the defaults
249− -> serialize_cap_expression ( fromJust $ set_attr_states
249+ -> liftIO $ serialize_cap_expression ( fromJust $ set_attr_states
250 $ display_attr_caps
250 $ display_attr_caps
251 $ term d
251 $ term d
253− ( sgr_args_for_state state )
253+ ( sgr_args_for_state state )
255 >>= set_colors
255 >>= set_colors
256 -- Otherwise the display colors are not changing or changing between two non-default
256 -- Otherwise the display colors are not changing or changing between two non-default
257 -- points.
257 -- points.
@@ -268,28 +268,28 @@ instance DisplayTerminal DisplayContext where
268 -- Changes the style and color states according to the differences with the
268 -- Changes the style and color states according to the differences with the
269 -- currently applied states.
269 -- currently applied states.
270 EnterExitSeq caps
270 EnterExitSeq caps
271− -> foldM (\ptr cap -> serialize_cap_expression cap [] ptr) out_ptr caps
271+ -> liftIO ( foldM (\ptr cap -> serialize_cap_expression cap [] ptr) out_ptr caps )
272 >>= apply_color_diff set_fore_color ( fore_color_diff diffs )
272 >>= apply_color_diff set_fore_color ( fore_color_diff diffs )
273 >>= apply_color_diff set_back_color ( back_color_diff diffs )
273 >>= apply_color_diff set_back_color ( back_color_diff diffs )
274 SetState state
274 SetState state
275 -- implicitly resets the colors to the defaults
275 -- implicitly resets the colors to the defaults
276− -> serialize_cap_expression ( fromJust $ set_attr_states
276+ -> liftIO $ serialize_cap_expression ( fromJust $ set_attr_states
277− $ display_attr_caps
277+ $ display_attr_caps
278− $ term d
278+ $ term d
280− ( sgr_args_for_state state )
280+ ( sgr_args_for_state state )
282 >>= set_colors
282 >>= set_colors
284 attr = fix_display_attr prev_attr req_attr
284 attr = fix_display_attr prev_attr req_attr
285 set_colors ptr = do
285 set_colors ptr = do
286 ptr' <- case fixed_fore_color attr of
286 ptr' <- case fixed_fore_color attr of
287− Just c -> serialize_cap_expression ( set_fore_color $ term d )
287+ Just c -> liftIO $ serialize_cap_expression ( set_fore_color $ term d )
288 [ ansi_color_index c ]
288 [ ansi_color_index c ]
290 Nothing -> return ptr
290 Nothing -> return ptr
291 ptr'' <- case fixed_back_color attr of
291 ptr'' <- case fixed_back_color attr of
292− Just c -> serialize_cap_expression ( set_back_color $ term d )
292+ Just c -> liftIO $ serialize_cap_expression ( set_back_color $ term d )
293 [ ansi_color_index c ]
293 [ ansi_color_index c ]
295 Nothing -> return ptr'
295 Nothing -> return ptr'
@@ -299,14 +299,14 @@ instance DisplayTerminal DisplayContext where
299 apply_color_diff _f ColorToDefault _ptr
299 apply_color_diff _f ColorToDefault _ptr
300 = fail "ColorToDefault is not a possible case for apply_color_diffs"
300 = fail "ColorToDefault is not a possible case for apply_color_diffs"
301 apply_color_diff f ( SetColor c ) ptr
301 apply_color_diff f ( SetColor c ) ptr
302− = serialize_cap_expression ( f $ term d )
302+ = liftIO $ serialize_cap_expression ( f $ term d )
303− [ ansi_color_index c ]
303+ [ ansi_color_index c ]
306 default_attr_required_bytes d
306 default_attr_required_bytes d
307 = cap_expression_required_bytes (set_default_attr $ term d) []
307 = cap_expression_required_bytes (set_default_attr $ term d) []
308 serialize_default_attr d out_ptr = do
308 serialize_default_attr d out_ptr = do
309− serialize_cap_expression ( set_default_attr $ term d ) [] out_ptr
309+ liftIO $ serialize_cap_expression ( set_default_attr $ term d ) [] out_ptr
311ansi_color_index :: Color -> Word
311ansi_color_index :: Color -> Word
312ansi_color_index (ISOColor v) = toEnum $ fromEnum v
312ansi_color_index (ISOColor v) = toEnum $ fromEnum v