on master help sign in
Merge remote-tracking branch 'origin/master' into refactor-input
commit7b97c7a2cec1ab3072044a5c1468a754bd7f4188 authorCorey O'Connor <corey@ooyala.com> dateThu 16 Jan 2014, 00:03 (13 years ago) parent0bbc339fe5195d
6 files changed+29−29
test/BenchImageFuzz.hs+1−1 test/BenchNoDiffOpt.hs+1−1 test/BenchRenderChar.hs+2−2 test/BenchVerticalScroll.hs+1−1 test/Rouge.hs+1−1 test/interactive_terminal_test.hs+23−23
test/BenchImageFuzz.hs+1−1
@@ -20,7 +20,7 @@ random_picture = pic_for_image <$> random_image
2020
2121bench_0 = do
2222 vty <- mkVty
23− (w,h) <- display_bounds $ terminal vty
23+ (w,h) <- display_bounds $ output_iface vty
2424 let pictures = replicateM 3000 random_picture
2525 bench ps = do
2626 forM ps (update vty)
test/BenchNoDiffOpt.hs+1−1
@@ -19,7 +19,7 @@ bench_0 = do
1919 let fixed_gen = mkStdGen 0
2020 setStdGen fixed_gen
2121 vty <- mkVty
22− (w,h) <- display_bounds $ terminal vty
22+ (w,h) <- display_bounds $ output_iface vty
2323 let images = return $ (image_0, image_1)
2424 image_0 = char_fill def_attr 'X' w h
2525 image_1 = char_fill def_attr '0' w h
test/BenchRenderChar.hs+2−2
@@ -11,7 +11,7 @@ import Control.Monad ( forM_ )
1111
1212bench_0 = do
1313 vty <- mkVty
14− (w,h) <- display_bounds $ terminal vty
14+ (w,h) <- display_bounds $ output_iface vty
1515 let test_chars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
1616 bench d = do
1717 forM_ d $ \test_char -> do
@@ -27,7 +27,7 @@ test_image_using_char c w h
2727
2828bench_1 = do
2929 vty <- mkVty
30− (w,h) <- display_bounds $ terminal vty
30+ (w,h) <- display_bounds $ output_iface vty
3131 let test_chars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
3232 bench d = do
3333 forM_ d $ \test_char -> do
test/BenchVerticalScroll.hs+1−1
@@ -18,7 +18,7 @@ bench_0 = do
1818 setStdGen fixed_gen
1919 return $ Bench (return ()) (\() -> mkVty >>= liftM2 (>>) run shutdown)
2020
21−run vt = mapM_ (\p -> update vt p) . benchgen =<< display_bounds (terminal vt)
21+run vt = mapM_ (\p -> update vt p) . benchgen =<< display_bounds (output_iface vt)
2222
2323-- Currently, we just do scrolling.
2424takem :: (a -> Int) -> Int -> [a] -> ([a],[a])
test/Rouge.hs+1−1
@@ -116,7 +116,7 @@ update_display :: Game ()
116116update_display = do
117117 let info = string def_attr "Move with the arrows keys. Press ESC to exit."
118118 -- determine offsets to place the dude in the center of the level.
119− (w,h) <- asks terminal >>= liftIO . display_bounds
119+ (w,h) <- asks output_iface >>= liftIO . display_bounds
120120 the_dude <- gets dude
121121 let ox = (w `div` 2) - dude_x the_dude
122122 oy = (h `div` 2) - dude_y the_dude
test/interactive_terminal_test.hs+23−23
@@ -77,7 +77,7 @@ failure".
7777 ( \ (_ :: SomeException) -> return (env_name, "") )
7878 )
7979 [ "TERM", "COLORTERM", "LANG", "TERM_PROGRAM", "XTERM_VERSION" ]
80− t <- current_terminal
80+ t <- output_for_current_terminal
8181 let results_txt = show env_attributes ++ "\n"
8282 ++ terminal_ID t ++ "\n"
8383 ++ show results ++ "\n"
@@ -188,7 +188,7 @@ reserve_output_test = Test
188188 { test_name = "Initialize and reserve terminal output then restore previous state."
189189 , test_ID = "reserve_output_test"
190190 , test_action = do
191− t <- current_terminal
191+ t <- output_for_current_terminal
192192 reserve_display t
193193 putStrLn "Line 1"
194194 putStrLn "Line 2"
@@ -221,7 +221,7 @@ display_bounds_test_0 = Test
221221 { test_name = "Verify display bounds are correct test 0: Using spaces."
222222 , test_ID = "display_bounds_test_0"
223223 , test_action = do
224− t <- current_terminal
224+ t <- output_for_current_terminal
225225 reserve_display t
226226 (w,h) <- display_bounds t
227227 let row_0 = replicate (fromEnum w) 'X' ++ "\n"
@@ -242,7 +242,7 @@ display_bounds_test_1 = Test
242242 { test_name = "Verify display bounds are correct test 0: Using cursor movement."
243243 , test_ID = "display_bounds_test_1"
244244 , test_action = do
245− t <- current_terminal
245+ t <- output_for_current_terminal
246246 reserve_display t
247247 (w,h) <- display_bounds t
248248 set_cursor_pos t 0 0
@@ -271,7 +271,7 @@ display_bounds_test_2 = Test
271271 { test_name = "Verify display bounds are correct test 0: Using Image ops."
272272 , test_ID = "display_bounds_test_2"
273273 , test_action = do
274− t <- current_terminal
274+ t <- output_for_current_terminal
275275 reserve_display t
276276 bounds@(w,h) <- display_bounds t
277277 let first_row = horiz_cat $ replicate (fromEnum w) (char def_attr 'X')
@@ -294,7 +294,7 @@ display_bounds_test_3 = Test
294294 { test_name = "Verify display bounds are correct test 0: Hide cursor; Set cursor pos."
295295 , test_ID = "display_bounds_test_3"
296296 , test_action = do
297− t <- current_terminal
297+ t <- output_for_current_terminal
298298 reserve_display t
299299 (w,h) <- display_bounds t
300300 hide_cursor t
@@ -406,7 +406,7 @@ unicode_single_width_0 = Test
406406 { test_name = "Verify terminal can display unicode single-width characters. (Direct UTF-8)"
407407 , test_ID = "unicode_single_width_0"
408408 , test_action = do
409− t <- current_terminal
409+ t <- output_for_current_terminal
410410 reserve_display t
411411 hide_cursor t
412412 withArrayLen (concat utf8_txt_0) (flip $ hPutBuf stdout)
@@ -425,7 +425,7 @@ unicode_single_width_1 = Test
425425 { test_name = "Verify terminal can display unicode single-width characters. (Image ops)"
426426 , test_ID = "unicode_single_width_1"
427427 , test_action = do
428− t <- current_terminal
428+ t <- output_for_current_terminal
429429 reserve_display t
430430 let pic = pic_for_image image
431431 image = line_0 <-> line_1
@@ -488,7 +488,7 @@ unicode_double_width_0 = Test
488488 { test_name = "Verify terminal can display unicode double-width characters. (Direct UTF-8)"
489489 , test_ID = "unicode_double_width_0"
490490 , test_action = do
491− t <- current_terminal
491+ t <- output_for_current_terminal
492492 reserve_display t
493493 hide_cursor t
494494 withArrayLen (concat utf8_txt_1) (flip $ hPutBuf stdout)
@@ -507,7 +507,7 @@ unicode_double_width_1 = Test
507507 { test_name = "Verify terminal can display unicode double-width characters. (Image ops)"
508508 , test_ID = "unicode_double_width_1"
509509 , test_action = do
510− t <- current_terminal
510+ t <- output_for_current_terminal
511511 reserve_display t
512512 let pic = pic_for_image image
513513 image = line_0 <-> line_1
@@ -561,7 +561,7 @@ attributes_test_0 = Test
561561 { test_name = "Character attributes: foreground colors."
562562 , test_ID = "attributes_test_0"
563563 , test_action = do
564− t <- current_terminal
564+ t <- output_for_current_terminal
565565 reserve_display t
566566 let pic = pic_for_image image
567567 image = border <|> column_0 <|> border <|> column_1 <|> border
@@ -607,7 +607,7 @@ attributes_test_1 = Test
607607 { test_name = "Character attributes: background colors."
608608 , test_ID = "attributes_test_1"
609609 , test_action = do
610− t <- current_terminal
610+ t <- output_for_current_terminal
611611 reserve_display t
612612 let pic = pic_for_image image
613613 image = border <|> column_0 <|> border <|> column_1 <|> border
@@ -662,7 +662,7 @@ attributes_test_2 = Test
662662 { test_name = "Character attributes: Vivid foreground colors."
663663 , test_ID = "attributes_test_2"
664664 , test_action = do
665− t <- current_terminal
665+ t <- output_for_current_terminal
666666 reserve_display t
667667 let pic = pic_for_image image
668668 image = horiz_cat [border, column_0, border, column_1, border, column_2, border]
@@ -721,7 +721,7 @@ attributes_test_3 = Test
721721 { test_name = "Character attributes: Vivid background colors."
722722 , test_ID = "attributes_test_3"
723723 , test_action = do
724− t <- current_terminal
724+ t <- output_for_current_terminal
725725 reserve_display t
726726 let pic = pic_for_image image
727727 image = horiz_cat [border, column_0, border, column_1, border, column_2, border]
@@ -799,7 +799,7 @@ attributes_test_4 = Test
799799 { test_name = "Character attributes: Bold; Blink; Underline."
800800 , test_ID = "attributes_test_4"
801801 , test_action = do
802− t <- current_terminal
802+ t <- output_for_current_terminal
803803 reserve_display t
804804 let pic = pic_for_image image
805805 image = horiz_cat [border, column_0, border, column_1, border]
@@ -851,7 +851,7 @@ attributes_test_5 = Test
851851 { test_name = "Character attributes: 240 color palette"
852852 , test_ID = "attributes_test_5"
853853 , test_action = do
854− t <- current_terminal
854+ t <- output_for_current_terminal
855855 reserve_display t
856856 let pic = pic_for_image image
857857 image = vert_cat $ map horiz_cat $ split_color_images color_images
@@ -938,10 +938,10 @@ cursor_hide_test_0 = Test
938938 , test_ID = "cursor_hide_test_0"
939939 , test_action = do
940940 vty <- mkVty
941− show_cursor $ terminal vty
942− set_cursor_pos (terminal vty) 5 5
941+ show_cursor $ output_iface vty
942+ set_cursor_pos (output_iface vty) 5 5
943943 next_event vty
944− hide_cursor $ terminal vty
944+ hide_cursor $ output_iface vty
945945 next_event vty
946946 shutdown vty
947947 return ()
@@ -962,7 +962,7 @@ output_image_and_wait image = do
962962
963963output_pic_and_wait :: Picture -> IO ()
964964output_pic_and_wait pic = do
965− t <- current_terminal
965+ t <- output_for_current_terminal
966966 reserve_display t
967967 d <- display_bounds t >>= display_context t
968968 output_picture d pic
@@ -1145,13 +1145,13 @@ layer_1 = Test
11451145
11461146cheesy_anim_0 :: Image -> [Image] -> IO ()
11471147cheesy_anim_0 i background = do
1148− t <- current_terminal
1148+ t <- output_for_current_terminal
11491149 reserve_display t
11501150 bounds <- display_bounds t
11511151 d <- display_context t bounds
11521152 forM_ [0..100] $ \t -> do
1153− let i_offset = translate (t `mod` region_width bounds)
1154− (t `div` 2 `mod` region_height bounds)
1153+ let i_offset = translate (t `mod` fst bounds)
1154+ (t `div` 2 `mod` snd bounds)
11551155 i
11561156 let pic = pic_for_layers $ i_offset : background
11571157 output_picture d pic