@@ -6,7 +6,8 @@ import Graphics.Vty
66import Graphics.Vty.Attributes
77import Graphics.Vty.Inline
88import Graphics.Vty.Picture
9−import Graphics.Vty.Output
9+import Graphics.Vty.Terminal
10+import Graphics.Vty.DisplayRegion
1011
1112import Control.Concurrent (threadDelay)
1213import Control.Exception
@@ -18,18 +19,18 @@ import Data.Monoid
1819import Data.String.QQ
1920import Data.Word
2021
21−import Foreign.Marshal.Array
22+import Foreign.Marshal.Array
2223
2324import qualified System.Environment as Env
2425
2526import System.IO ( hFlush, hPutStr, hPutBuf, stdout )
2627
2728main = do
28− printIntro
29+ print_intro
2930
30−outputFilePath = "test_results.list"
31+output_file_path = "test_results.list"
3132
32−printIntro = do
33+print_intro = do
3334 putStr $ [s|
3435This is an interactive verification program for the terminal input and output
3536support of the VTY library. This will ask a series of questions about what you
@@ -37,7 +38,7 @@ see on screen. The goal is to verify that VTY's output and input support
3738performs as expected with your terminal.
3839
3940This program produces a file named
40− |] ++ outputFilePath ++ [s|
41+ |] ++ output_file_path ++ [s|
4142in the current directory that contains the results for each test assertion. This
4243can be emailed to coreyoconnor@gmail.com and used by the VTY authors to improve
4344support for your terminal. No personal information is contained in the report.
@@ -66,40 +67,41 @@ All the tests assume the following about the terminal display:
6667Thanks for the help! :-D
6768To exit the test early enter "q" anytime at the following menu screen.
6869
69−If any test fails then please post an issue to
70+If any test failed then please post an issue to
7071 https://github.com/coreyoconnor/vty/issues
71−with the test_results.list file pasted into the issue. A suitable summary is:
72−"interactive terminal test failure".
72+with the test_results.list file pasted into the issue. The issue summary can
73+mention the specific tests that failed or just say "interactive terminal test
74+failure".
7375|]
74− waitForReturn
75− results <- doTestMenu 1
76− envAttributes <- mapM ( \envName -> Control.Exception.catch ( Env.getEnv envName >>= return . (,) envName )
77− ( \ (_ :: SomeException) -> return (envName, "") )
78− )
79− [ "TERM", "COLORTERM", "LANG", "TERM_PROGRAM", "XTERM_VERSION" ]
80− t <- standardIOConfig >>= outputForConfig
81− let resultsTxt = show envAttributes ++ "\n"
82− ++ terminalID t ++ "\n"
83− ++ show results ++ "\n"
84− releaseTerminal t
85− writeFile outputFilePath resultsTxt
86−
87−waitForReturn = do
76+ wait_for_return
77+ results <- do_test_menu 1
78+ env_attributes <- mapM ( \env_name -> Control.Exception.catch ( Env.getEnv env_name >>= return . (,) env_name )
79+ ( \ (_ :: SomeException) -> return (env_name, "") )
80+ )
81+ [ "TERM", "COLORTERM", "LANG", "TERM_PROGRAM", "XTERM_VERSION" ]
82+ t <- current_terminal
83+ let results_txt = show env_attributes ++ "\n"
84+ ++ terminal_ID t ++ "\n"
85+ ++ show results ++ "\n"
86+ release_terminal t
87+ writeFile output_file_path results_txt
88+
89+wait_for_return = do
8890 putStr "\n(press return to continue)"
8991 hFlush stdout
9092 getLine
9193
92−testMenu :: [(String, Test)]
93−testMenu = zip (map show [1..]) allTests
94+test_menu :: [(String, Test)]
95+test_menu = zip (map show [1..]) all_tests
9496
95−doTestMenu :: Int -> IO [(String, Bool)]
96−doTestMenu nextID
97− | nextID > length allTests = do
98− putStrLn $ "Done! Please email the " ++ outputFilePath ++ " file to coreyoconnor@gmail.com"
97+do_test_menu :: Int -> IO [(String, Bool)]
98+do_test_menu next_ID
99+ | next_ID > length all_tests = do
100+ putStrLn $ "Done! Please email the " ++ output_file_path ++ " file to coreyoconnor@gmail.com"
99101 return []
100102 | otherwise = do
101− displayTestMenu
102− putStrLn $ "Press return to start with #" ++ show nextID ++ "."
103+ display_test_menu
104+ putStrLn $ "Press return to start with #" ++ show next_ID ++ "."
103105 putStrLn "Enter a test number to perform only that test."
104106 putStrLn "q (or control-C) to quit."
105107 putStr "> "
@@ -107,102 +109,102 @@ doTestMenu nextID
107109 s <- getLine >>= return . filter (/= '\n')
108110 case s of
109111 "q" -> return mempty
110− "" -> do
111− r <- runTest $ show nextID
112− rs <- doTestMenu ( nextID + 1 )
112+ "" -> do
113+ r <- run_test $ show next_ID
114+ rs <- do_test_menu ( next_ID + 1 )
113115 return $ r : rs
114− i | isJust ( lookup i testMenu ) -> do
115− r <- runTest i
116− rs <- doTestMenu ( read i + 1 )
116+ i | isJust ( lookup i test_menu ) -> do
117+ r <- run_test i
118+ rs <- do_test_menu ( read i + 1 )
117119 return $ r : rs
118120 where
119− displayTestMenu
120− = mapM_ displayTestMenu' testMenu
121− displayTestMenu' ( i, t )
122− = putStrLn $ ( if i == show nextID
123− then "> "
121+ display_test_menu
122+ = mapM_ display_test_menu' test_menu
123+ display_test_menu' ( i, t )
124+ = putStrLn $ ( if i == show next_ID
125+ then "> "
124126 else " "
125− ) ++ i ++ ". " ++ testName t
126−
127−runTest :: String -> IO (String, Bool)
128−runTest i = do
129− let t = fromJust $ lookup i testMenu
130− printSummary t
131− waitForReturn
132− testAction t
133− r <- confirmResults t
134− return (testID t, r)
135−
136−defaultSuccessConfirmResults = do
127+ ) ++ i ++ ". " ++ test_name t
128+
129+run_test :: String -> IO (String, Bool)
130+run_test i = do
131+ let t = fromJust $ lookup i test_menu
132+ print_summary t
133+ wait_for_return
134+ test_action t
135+ r <- confirm_results t
136+ return (test_ID t, r)
137+
138+default_success_confirm_results = do
137139 putStr "\n"
138140 putStr "[Y/n] "
139141 hFlush stdout
140142 r <- getLine
141143 case r of
142− "" -> return True
144+ "" -> return True
143145 "y" -> return True
144146 "Y" -> return True
145147 "n" -> return False
146148
147149data Test = Test
148− { testName :: String
149− , testID :: String
150− , testAction :: IO ()
151− , printSummary :: IO ()
152− , confirmResults :: IO Bool
150+ { test_name :: String
151+ , test_ID :: String
152+ , test_action :: IO ()
153+ , print_summary :: IO ()
154+ , confirm_results :: IO Bool
153155 }
154156
155−allTests
156− = [ reserveOutputTest
157− , displayBoundsTest0
158− , displayBoundsTest1
159− , displayBoundsTest2
160− , displayBoundsTest3
161− , unicodeSingleWidth0
162− , unicodeSingleWidth1
163− , unicodeDoubleWidth0
164− , unicodeDoubleWidth1
165− , attributesTest0
166− , attributesTest1
167− , attributesTest2
168− , attributesTest3
169− , attributesTest4
170− , attributesTest5
171− , inlineTest0
172− , inlineTest1
173− , inlineTest2
174− , cursorHideTest0
175− , vertCropTest0
176− , vertCropTest1
177− , vertCropTest2
178− , vertCropTest3
179− , horizCropTest0
180− , horizCropTest1
181− , horizCropTest2
182− , horizCropTest3
183− , layer0
184− , layer1
157+all_tests
158+ = [ reserve_output_test
159+ , display_bounds_test_0
160+ , display_bounds_test_1
161+ , display_bounds_test_2
162+ , display_bounds_test_3
163+ , unicode_single_width_0
164+ , unicode_single_width_1
165+ , unicode_double_width_0
166+ , unicode_double_width_1
167+ , attributes_test_0
168+ , attributes_test_1
169+ , attributes_test_2
170+ , attributes_test_3
171+ , attributes_test_4
172+ , attributes_test_5
173+ , inline_test_0
174+ , inline_test_1
175+ , inline_test_2
176+ , cursor_hide_test_0
177+ , vert_crop_test_0
178+ , vert_crop_test_1
179+ , vert_crop_test_2
180+ , vert_crop_test_3
181+ , horiz_crop_test_0
182+ , horiz_crop_test_1
183+ , horiz_crop_test_2
184+ , horiz_crop_test_3
185+ , layer_0
186+ , layer_1
185187 ]
186188
187−reserveOutputTest = Test
188− { testName = "Initialize and reserve terminal output then restore previous state."
189− , testID = "reserveOutputTest"
190− , testAction = do
191− t <- standardIOConfig >>= outputForConfig
192− reserveDisplay t
189+reserve_output_test = Test
190+ { test_name = "Initialize and reserve terminal output then restore previous state."
191+ , test_ID = "reserve_output_test"
192+ , test_action = do
193+ t <- current_terminal
194+ reserve_display t
193195 putStrLn "Line 1"
194196 putStrLn "Line 2"
195197 putStrLn "Line 3"
196198 putStrLn "Line 4 (press return)"
197199 hFlush stdout
198200 getLine
199− releaseDisplay t
200− releaseTerminal t
201+ release_display t
202+ release_terminal t
201203 return ()
202− , printSummary = do
204+ , print_summary = do
203205 putStr $ [s|
204206Once return is pressed:
205− 0. The screen will be cleared.
207+ 0. The screen will be cleared.
206208 1. Four lines of text should be visible.
207209 1. The cursor should be visible and at the start of the fifth line.
208210
@@ -210,123 +212,123 @@ After return is pressed for the second time this test then:
210212 * The screen containing the test summary should be restored;
211213 * The cursor is visible.
212214|]
213− , confirmResults = do
215+ , confirm_results = do
214216 putStr $ [s|
215217Did the test output match the description?
216218|]
217− defaultSuccessConfirmResults
219+ default_success_confirm_results
218220 }
219221
220−displayBoundsTest0 = Test
221− { testName = "Verify display bounds are correct test 0: Using spaces."
222− , testID = "displayBoundsTest0"
223− , testAction = do
224− t <- standardIOConfig >>= outputForConfig
225− reserveDisplay t
226− (w,h) <- displayBounds t
227− let row0 = replicate (fromEnum w) 'X' ++ "\n"
228− rowH = replicate (fromEnum w - 1) 'X'
229− rowN = "X" ++ replicate (fromEnum w - 2) ' ' ++ "X\n"
230− image = row0 ++ (concat $ replicate (fromEnum h - 2) rowN) ++ rowH
222+display_bounds_test_0 = Test
223+ { test_name = "Verify display bounds are correct test 0: Using spaces."
224+ , test_ID = "display_bounds_test_0"
225+ , test_action = do
226+ t <- current_terminal
227+ reserve_display t
228+ DisplayRegion w h <- display_bounds t
229+ let row_0 = replicate (fromEnum w) 'X' ++ "\n"
230+ row_h = replicate (fromEnum w - 1) 'X'
231+ row_n = "X" ++ replicate (fromEnum w - 2) ' ' ++ "X\n"
232+ image = row_0 ++ (concat $ replicate (fromEnum h - 2) row_n) ++ row_h
231233 putStr image
232234 hFlush stdout
233235 getLine
234− releaseDisplay t
235− releaseTerminal t
236+ release_display t
237+ release_terminal t
236238 return ()
237− , printSummary = displayBoundsTestSummary True
238− , confirmResults = genericOutputMatchConfirm
239+ , print_summary = display_bounds_test_summary True
240+ , confirm_results = generic_output_match_confirm
239241 }
240242
241−displayBoundsTest1 = Test
242− { testName = "Verify display bounds are correct test 0: Using cursor movement."
243− , testID = "displayBoundsTest1"
244− , testAction = do
245− t <- standardIOConfig >>= outputForConfig
246− reserveDisplay t
247− (w,h) <- displayBounds t
248− setCursorPos t 0 0
249− let row0 = replicate (fromEnum w) 'X' ++ "\n"
250− putStr row0
243+display_bounds_test_1 = Test
244+ { test_name = "Verify display bounds are correct test 0: Using cursor movement."
245+ , test_ID = "display_bounds_test_1"
246+ , test_action = do
247+ t <- current_terminal
248+ reserve_display t
249+ DisplayRegion w h <- display_bounds t
250+ set_cursor_pos t 0 0
251+ let row_0 = replicate (fromEnum w) 'X' ++ "\n"
252+ putStr row_0
251253 forM_ [1 .. h - 2] $ \y -> do
252− setCursorPos t 0 y
254+ set_cursor_pos t 0 y
253255 putStr "X"
254256 hFlush stdout
255− setCursorPos t (w - 1) y
257+ set_cursor_pos t (w - 1) y
256258 putStr "X"
257259 hFlush stdout
258− setCursorPos t 0 (h - 1)
259− let rowH = replicate (fromEnum w - 1) 'X'
260− putStr rowH
260+ set_cursor_pos t 0 (h - 1)
261+ let row_h = replicate (fromEnum w - 1) 'X'
262+ putStr row_h
261263 hFlush stdout
262264 getLine
263− releaseDisplay t
264− releaseTerminal t
265+ release_display t
266+ release_terminal t
265267 return ()
266− , printSummary = displayBoundsTestSummary True
267− , confirmResults = genericOutputMatchConfirm
268+ , print_summary = display_bounds_test_summary True
269+ , confirm_results = generic_output_match_confirm
268270 }
269271
270−displayBoundsTest2 = Test
271− { testName = "Verify display bounds are correct test 0: Using Image ops."
272− , testID = "displayBoundsTest2"
273− , testAction = do
274− t <- standardIOConfig >>= outputForConfig
275− reserveDisplay t
276− bounds@(w,h) <- displayBounds t
277− let firstRow = horizCat $ replicate (fromEnum w) (char defAttr 'X')
278− middleRows = vertCat $ replicate (fromEnum h - 2) middleRow
279− middleRow = (char defAttr 'X') <|> backgroundFill (w - 2) 1 <|> (char defAttr 'X')
280− endRow = firstRow
281− image = firstRow <-> middleRows <-> endRow
282− pic = (picForImage image) { picCursor = Cursor (w - 1) (h - 1) }
283− d <- displayContext t bounds
284− outputPicture d pic
272+display_bounds_test_2 = Test
273+ { test_name = "Verify display bounds are correct test 0: Using Image ops."
274+ , test_ID = "display_bounds_test_2"
275+ , test_action = do
276+ t <- current_terminal
277+ reserve_display t
278+ bounds@(DisplayRegion w h) <- display_bounds t
279+ let first_row = horiz_cat $ replicate (fromEnum w) (char def_attr 'X')
280+ middle_rows = vert_cat $ replicate (fromEnum h - 2) middle_row
281+ middle_row = (char def_attr 'X') <|> background_fill (w - 2) 1 <|> (char def_attr 'X')
282+ end_row = first_row
283+ image = first_row <-> middle_rows <-> end_row
284+ pic = (pic_for_image image) { pic_cursor = Cursor (w - 1) (h - 1) }
285+ d <- display_context t bounds
286+ output_picture d pic
285287 getLine
286− releaseDisplay t
287− releaseTerminal t
288+ release_display t
289+ release_terminal t
288290 return ()
289− , printSummary = displayBoundsTestSummary True
290− , confirmResults = genericOutputMatchConfirm
291+ , print_summary = display_bounds_test_summary True
292+ , confirm_results = generic_output_match_confirm
291293 }
292294
293−displayBoundsTest3 = Test
294− { testName = "Verify display bounds are correct test 0: Hide cursor; Set cursor pos."
295− , testID = "displayBoundsTest3"
296− , testAction = do
297− t <- standardIOConfig >>= outputForConfig
298− reserveDisplay t
299− (w,h) <- displayBounds t
300− hideCursor t
301− setCursorPos t 0 0
302− let row0 = replicate (fromEnum w) 'X'
303− putStrLn row0
295+display_bounds_test_3 = Test
296+ { test_name = "Verify display bounds are correct test 0: Hide cursor; Set cursor pos."
297+ , test_ID = "display_bounds_test_3"
298+ , test_action = do
299+ t <- current_terminal
300+ reserve_display t
301+ DisplayRegion w h <- display_bounds t
302+ hide_cursor t
303+ set_cursor_pos t 0 0
304+ let row_0 = replicate (fromEnum w) 'X'
305+ putStrLn row_0
304306 forM_ [1 .. h - 2] $ \y -> do
305− setCursorPos t 0 y
307+ set_cursor_pos t 0 y
306308 putStr "X"
307309 hFlush stdout
308− setCursorPos t (w - 1) y
310+ set_cursor_pos t (w - 1) y
309311 putStr "X"
310312 hFlush stdout
311− setCursorPos t 0 (h - 1)
312− let rowH = row0
313− putStr rowH
313+ set_cursor_pos t 0 (h - 1)
314+ let row_h = row_0
315+ putStr row_h
314316 hFlush stdout
315317 getLine
316− showCursor t
317− releaseDisplay t
318− releaseTerminal t
318+ show_cursor t
319+ release_display t
320+ release_terminal t
319321 return ()
320− , printSummary = displayBoundsTestSummary False
321− , confirmResults = genericOutputMatchConfirm
322+ , print_summary = display_bounds_test_summary False
323+ , confirm_results = generic_output_match_confirm
322324 }
323325
324−displayBoundsTestSummary hasCursor = do
326+display_bounds_test_summary has_cursor = do
325327 putStr $ [s|
326328Once return is pressed:
327329 0. The screen will be cleared.
328330|]
329− if hasCursor
331+ if has_cursor
330332 then putStr " 1. The cursor will be visible."
331333 else putStr " 1. The cursor will NOT be visible."
332334 putStr [s|
@@ -337,7 +339,7 @@ Once return is pressed:
337339 |XXXXXXXXXXXXX|
338340 |X X||]
339341
340− if hasCursor
342+ if has_cursor
341343 then putStr $ [s|
342344
343345 |XXXXXXXXXXXXC| |]
@@ -358,13 +360,13 @@ After return is pressed for the second time:
358360 1. The cursor should be visible.
359361|]
360362
361−genericOutputMatchConfirm = do
363+generic_output_match_confirm = do
362364 putStr $ [s|
363365Did the test output match the description?
364366|]
365− defaultSuccessConfirmResults
367+ default_success_confirm_results
366368
367−-- Explicitly define the bytes that encode each example text.
369+-- Explicitely definethe bytes that encode each example text.
368370-- This avoids any issues with how the compiler represents string literals.
369371--
370372-- This document is UTF-8 encoded so the UTF-8 string is still included for
@@ -373,24 +375,24 @@ Did the test output match the description?
373375-- It's assumed the compiler will at least not barf on UTF-8 encoded text in
374376-- comments ;-)
375377--
376−-- txt0 = ↑↑↓↓←→←→BA
377−
378−utf8Txt0 :: [[Word8]]
379−utf8Txt0 = [ [ 0xe2 , 0x86 , 0x91 ]
380− , [ 0xe2 , 0x86 , 0x91 ]
381− , [ 0xe2 , 0x86 , 0x93 ]
382− , [ 0xe2 , 0x86 , 0x93 ]
383− , [ 0xe2 , 0x86 , 0x90 ]
384− , [ 0xe2 , 0x86 , 0x92 ]
385− , [ 0xe2 , 0x86 , 0x90 ]
386− , [ 0xe2 , 0x86 , 0x92 ]
387− , [ 0x42 ]
388− , [ 0x41 ]
389− ]
390−
391−iso10646Txt0 :: String
392−iso10646Txt0 = map toEnum
393− [ 8593
378+-- txt_0 = ↑↑↓↓←→←→BA
379+
380+utf8_txt_0 :: [[Word8]]
381+utf8_txt_0 = [ [ 0xe2 , 0x86 , 0x91 ]
382+ , [ 0xe2 , 0x86 , 0x91 ]
383+ , [ 0xe2 , 0x86 , 0x93 ]
384+ , [ 0xe2 , 0x86 , 0x93 ]
385+ , [ 0xe2 , 0x86 , 0x90 ]
386+ , [ 0xe2 , 0x86 , 0x92 ]
387+ , [ 0xe2 , 0x86 , 0x90 ]
388+ , [ 0xe2 , 0x86 , 0x92 ]
389+ , [ 0x42 ]
390+ , [ 0x41 ]
391+ ]
392+
393+iso_10646_txt_0 :: String
394+iso_10646_txt_0 = map toEnum
395+ [ 8593
394396 , 8593
395397 , 8595
396398 , 8595
@@ -402,46 +404,46 @@ iso10646Txt0 = map toEnum
402404 , 65
403405 ]
404406
405−unicodeSingleWidth0 = Test
406− { testName = "Verify terminal can display unicode single-width characters. (Direct UTF-8)"
407− , testID = "unicodeSingleWidth0"
408− , testAction = do
409− t <- standardIOConfig >>= outputForConfig
410− reserveDisplay t
411− hideCursor t
412− withArrayLen (concat utf8Txt0) (flip $ hPutBuf stdout)
407+unicode_single_width_0 = Test
408+ { test_name = "Verify terminal can display unicode single-width characters. (Direct UTF-8)"
409+ , test_ID = "unicode_single_width_0"
410+ , test_action = do
411+ t <- current_terminal
412+ reserve_display t
413+ hide_cursor t
414+ withArrayLen (concat utf8_txt_0) (flip $ hPutBuf stdout)
413415 hPutStr stdout "\n"
414416 hPutStr stdout "0123456789\n"
415417 hFlush stdout
416418 getLine
417− releaseDisplay t
418− releaseTerminal t
419+ release_display t
420+ release_terminal t
419421 return ()
420− , printSummary = unicodeSingleWidthSummary
421− , confirmResults = genericOutputMatchConfirm
422+ , print_summary = unicode_single_width_summary
423+ , confirm_results = generic_output_match_confirm
422424 }
423425
424−unicodeSingleWidth1 = Test
425− { testName = "Verify terminal can display unicode single-width characters. (Image ops)"
426− , testID = "unicodeSingleWidth1"
427− , testAction = do
428− t <- standardIOConfig >>= outputForConfig
429− reserveDisplay t
430− let pic = picForImage image
431− image = line0 <-> line1
432− line0 = iso10646String defAttr iso10646Txt0
433− line1 = string defAttr "0123456789"
434− d <- displayBounds t >>= displayContext t
435− outputPicture d pic
426+unicode_single_width_1 = Test
427+ { test_name = "Verify terminal can display unicode single-width characters. (Image ops)"
428+ , test_ID = "unicode_single_width_1"
429+ , test_action = do
430+ t <- current_terminal
431+ reserve_display t
432+ let pic = pic_for_image image
433+ image = line_0 <-> line_1
434+ line_0 = iso_10646_string def_attr iso_10646_txt_0
435+ line_1 = string def_attr "0123456789"
436+ d <- display_bounds t >>= display_context t
437+ output_picture d pic
436438 getLine
437− releaseDisplay t
438− releaseTerminal t
439+ release_display t
440+ release_terminal t
439441 return ()
440− , printSummary = unicodeSingleWidthSummary
441− , confirmResults = genericOutputMatchConfirm
442+ , print_summary = unicode_single_width_summary
443+ , confirm_results = generic_output_match_confirm
442444 }
443445
444−unicodeSingleWidthSummary = putStr [s|
446+unicode_single_width_summary = putStr [s|
445447Once return is pressed:
446448 0. The screen will be cleared.
447449 1. The cursor will be hidden.
@@ -475,55 +477,55 @@ After return is pressed for the second time:
475477
476478-- The second example is a unicode string containing double-width glyphs
477479-- 你好吗
478−utf8Txt1 :: [[Word8]]
479−utf8Txt1 = [ [0xe4,0xbd,0xa0]
480− , [0xe5,0xa5,0xbd]
481− , [0xe5,0x90,0x97]
482− ]
483−
484−iso10646Txt1 :: String
485−iso10646Txt1 = map toEnum [20320,22909,21527]
486−
487−unicodeDoubleWidth0 = Test
488− { testName = "Verify terminal can display unicode double-width characters. (Direct UTF-8)"
489− , testID = "unicodeDoubleWidth0"
490− , testAction = do
491− t <- standardIOConfig >>= outputForConfig
492− reserveDisplay t
493− hideCursor t
494− withArrayLen (concat utf8Txt1) (flip $ hPutBuf stdout)
480+utf8_txt_1 :: [[Word8]]
481+utf8_txt_1 = [ [0xe4,0xbd,0xa0]
482+ , [0xe5,0xa5,0xbd]
483+ , [0xe5,0x90,0x97]
484+ ]
485+
486+iso_10646_txt_1 :: String
487+iso_10646_txt_1 = map toEnum [20320,22909,21527]
488+
489+unicode_double_width_0 = Test
490+ { test_name = "Verify terminal can display unicode double-width characters. (Direct UTF-8)"
491+ , test_ID = "unicode_double_width_0"
492+ , test_action = do
493+ t <- current_terminal
494+ reserve_display t
495+ hide_cursor t
496+ withArrayLen (concat utf8_txt_1) (flip $ hPutBuf stdout)
495497 hPutStr stdout "\n"
496498 hPutStr stdout "012345\n"
497499 hFlush stdout
498500 getLine
499− releaseDisplay t
500− releaseTerminal t
501+ release_display t
502+ release_terminal t
501503 return ()
502− , printSummary = unicodeDoubleWidthSummary
503− , confirmResults = genericOutputMatchConfirm
504+ , print_summary = unicode_double_width_summary
505+ , confirm_results = generic_output_match_confirm
504506 }
505507
506−unicodeDoubleWidth1 = Test
507− { testName = "Verify terminal can display unicode double-width characters. (Image ops)"
508− , testID = "unicodeDoubleWidth1"
509− , testAction = do
510− t <- standardIOConfig >>= outputForConfig
511− reserveDisplay t
512− let pic = picForImage image
513− image = line0 <-> line1
514− line0 = iso10646String defAttr iso10646Txt1
515− line1 = string defAttr "012345"
516− d <- displayBounds t >>= displayContext t
517− outputPicture d pic
508+unicode_double_width_1 = Test
509+ { test_name = "Verify terminal can display unicode double-width characters. (Image ops)"
510+ , test_ID = "unicode_double_width_1"
511+ , test_action = do
512+ t <- current_terminal
513+ reserve_display t
514+ let pic = pic_for_image image
515+ image = line_0 <-> line_1
516+ line_0 = iso_10646_string def_attr iso_10646_txt_1
517+ line_1 = string def_attr "012345"
518+ d <- display_bounds t >>= display_context t
519+ output_picture d pic
518520 getLine
519− releaseDisplay t
520− releaseTerminal t
521+ release_display t
522+ release_terminal t
521523 return ()
522− , printSummary = unicodeDoubleWidthSummary
523− , confirmResults = genericOutputMatchConfirm
524+ , print_summary = unicode_double_width_summary
525+ , confirm_results = generic_output_match_confirm
524526 }
525527
526−unicodeDoubleWidthSummary = putStr [s|
528+unicode_double_width_summary = putStr [s|
527529Once return is pressed:
528530 0. The screen will be cleared.
529531 1. The cursor will be hidden.
@@ -550,32 +552,32 @@ After return is pressed for the second time:
550552 1. The cursor should be visible.
551553|]
552554
553−allColors = zip [ black, red, green, yellow, blue, magenta, cyan, white ]
554− [ "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" ]
555+all_colors = zip [ black, red, green, yellow, blue, magenta, cyan, white ]
556+ [ "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white" ]
555557
556−allBrightColors
557− = zip [ brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite ]
558+all_bright_colors
559+ = zip [ bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white ]
558560 [ "bright black", "bright red", "bright green", "bright yellow", "bright blue", "bright magenta", "bright cyan", "bright white" ]
559561
560−attributesTest0 = Test
561− { testName = "Character attributes: foreground colors."
562− , testID = "attributesTest0"
563− , testAction = do
564− t <- standardIOConfig >>= outputForConfig
565− reserveDisplay t
566− let pic = picForImage image
567− image = border <|> column0 <|> border <|> column1 <|> border
568− column0 = vertCat $ map lineWithColor allColors
569− border = vertCat $ replicate (length allColors) $ string defAttr " | "
570− column1 = vertCat $ map (string defAttr . snd) allColors
571− lineWithColor (c, cName) = string (defAttr `withForeColor` c) cName
572− d <- displayBounds t >>= displayContext t
573− outputPicture d pic
562+attributes_test_0 = Test
563+ { test_name = "Character attributes: foreground colors."
564+ , test_ID = "attributes_test_0"
565+ , test_action = do
566+ t <- current_terminal
567+ reserve_display t
568+ let pic = pic_for_image image
569+ image = border <|> column_0 <|> border <|> column_1 <|> border
570+ column_0 = vert_cat $ map line_with_color all_colors
571+ border = vert_cat $ replicate (length all_colors) $ string def_attr " | "
572+ column_1 = vert_cat $ map (string def_attr . snd) all_colors
573+ line_with_color (c, c_name) = string (def_attr `with_fore_color` c) c_name
574+ d <- display_bounds t >>= display_context t
575+ output_picture d pic
574576 getLine
575− releaseDisplay t
576− releaseTerminal t
577+ release_display t
578+ release_terminal t
577579 return ()
578− , printSummary = do
580+ , print_summary = do
579581 putStr $ [s|
580582Once return is pressed:
581583 0. The screen will be cleared.
@@ -596,32 +598,32 @@ After return is pressed for the second time:
596598 0. The screen containing the test summary should be restored.
597599 1. The cursor should be visible.
598600|]
599− , confirmResults = do
601+ , confirm_results = do
600602 putStr $ [s|
601603Did the test output match the description?
602604|]
603− defaultSuccessConfirmResults
605+ default_success_confirm_results
604606 }
605607
606−attributesTest1 = Test
607− { testName = "Character attributes: background colors."
608− , testID = "attributesTest1"
609− , testAction = do
610− t <- standardIOConfig >>= outputForConfig
611− reserveDisplay t
612− let pic = picForImage image
613− image = border <|> column0 <|> border <|> column1 <|> border
614− column0 = vertCat $ map lineWithColor allColors
615− border = vertCat $ replicate (length allColors) $ string defAttr " | "
616− column1 = vertCat $ map (string defAttr . snd) allColors
617− lineWithColor (c, cName) = string (defAttr `withBackColor` c) cName
618− d <- displayBounds t >>= displayContext t
619− outputPicture d pic
608+attributes_test_1 = Test
609+ { test_name = "Character attributes: background colors."
610+ , test_ID = "attributes_test_1"
611+ , test_action = do
612+ t <- current_terminal
613+ reserve_display t
614+ let pic = pic_for_image image
615+ image = border <|> column_0 <|> border <|> column_1 <|> border
616+ column_0 = vert_cat $ map line_with_color all_colors
617+ border = vert_cat $ replicate (length all_colors) $ string def_attr " | "
618+ column_1 = vert_cat $ map (string def_attr . snd) all_colors
619+ line_with_color (c, c_name) = string (def_attr `with_back_color` c) c_name
620+ d <- display_bounds t >>= display_context t
621+ output_picture d pic
620622 getLine
621− releaseDisplay t
622− releaseTerminal t
623+ release_display t
624+ release_terminal t
623625 return ()
624− , printSummary = do
626+ , print_summary = do
625627 putStr $ [s|
626628Once return is pressed:
627629 0. The screen will be cleared.
@@ -651,57 +653,57 @@ After return is pressed for the second time:
651653 0. The screen containing the test summary should be restored.
652654 1. The cursor should be visible.
653655|]
654− , confirmResults = do
656+ , confirm_results = do
655657 putStr $ [s|
656658Did the test output match the description?
657659|]
658− defaultSuccessConfirmResults
660+ default_success_confirm_results
659661 }
660662
661−attributesTest2 = Test
662− { testName = "Character attributes: Vivid foreground colors."
663− , testID = "attributesTest2"
664− , testAction = do
665− t <- standardIOConfig >>= outputForConfig
666− reserveDisplay t
667− let pic = picForImage image
668− image = horizCat [border, column0, border, column1, border, column2, border]
669− border = vertCat $ replicate (length allColors) $ string defAttr " | "
670− column0 = vertCat $ map lineWithColor0 allColors
671− column1 = vertCat $ map lineWithColor1 allBrightColors
672− column2 = vertCat $ map (string defAttr . snd) allColors
673− lineWithColor0 (c, cName) = string (defAttr `withForeColor` c) cName
674− lineWithColor1 (c, cName) = string (defAttr `withForeColor` c) cName
675− d <- displayBounds t >>= displayContext t
676− outputPicture d pic
663+attributes_test_2 = Test
664+ { test_name = "Character attributes: Vivid foreground colors."
665+ , test_ID = "attributes_test_2"
666+ , test_action = do
667+ t <- current_terminal
668+ reserve_display t
669+ let pic = pic_for_image image
670+ image = horiz_cat [border, column_0, border, column_1, border, column_2, border]
671+ border = vert_cat $ replicate (length all_colors) $ string def_attr " | "
672+ column_0 = vert_cat $ map line_with_color_0 all_colors
673+ column_1 = vert_cat $ map line_with_color_1 all_bright_colors
674+ column_2 = vert_cat $ map (string def_attr . snd) all_colors
675+ line_with_color_0 (c, c_name) = string (def_attr `with_fore_color` c) c_name
676+ line_with_color_1 (c, c_name) = string (def_attr `with_fore_color` c) c_name
677+ d <- display_bounds t >>= display_context t
678+ output_picture d pic
677679 getLine
678− releaseDisplay t
679− releaseTerminal t
680+ release_display t
681+ release_terminal t
680682 return ()
681− , printSummary = do
683+ , print_summary = do
682684 putStr $ [s|
683685Once return is pressed:
684686 0. The screen will be cleared.
685687 1. The cursor will be hidden.
686688 2. 9 lines of text in three columns will be drawn:
687689 a. The first column will be a name of a standard color (for an 8 color
688− terminal) rendered with that color as the foreground color.
690+ terminal) rendered with that color as the foreground color.
689691 b. The next column will be also be the name of a standard color rendered
690692 with that color as the foreground color but the shade used should be
691− more vivid than the shade used in the first column.
693+ more vivid than the shade used in the first column.
692694 c. The final column will be the name of a color rendered with the
693695 default attributes.
694696
695697For instance, one line will be the word "magenta" and that word should be
696−rendered in the magenta color.
698+rendered in the magenta color.
697699
698700I'm not actually sure exactly what "vivid" means in this context. For xterm the
699−vivid colors are brighter.
701+vivid colors are brighter.
700702
701−Verify:
703+Verify:
702704 * The first column: The foreground color matches the named color.
703705 * The second column: The foreground color matches the named color but is
704− more vivid than the color used in the first column.
706+ more vivid than the color used in the first column.
705707 * The third column: All text is rendered with the default attributes.
706708 * The vertical bars used in each line to mark the border of a column are
707709 lined up.
@@ -710,34 +712,34 @@ After return is pressed for the second time:
710712 0. The screen containing the test summary should be restored.
711713 1. The cursor should be visible.
712714|]
713− , confirmResults = do
715+ , confirm_results = do
714716 putStr $ [s|
715717Did the test output match the description?
716718|]
717− defaultSuccessConfirmResults
719+ default_success_confirm_results
718720 }
719721
720−attributesTest3 = Test
721− { testName = "Character attributes: Vivid background colors."
722− , testID = "attributesTest3"
723− , testAction = do
724− t <- standardIOConfig >>= outputForConfig
725− reserveDisplay t
726− let pic = picForImage image
727− image = horizCat [border, column0, border, column1, border, column2, border]
728− border = vertCat $ replicate (length allColors) $ string defAttr " | "
729− column0 = vertCat $ map lineWithColor0 allColors
730− column1 = vertCat $ map lineWithColor1 allBrightColors
731− column2 = vertCat $ map (string defAttr . snd) allColors
732− lineWithColor0 (c, cName) = string (defAttr `withBackColor` c) cName
733− lineWithColor1 (c, cName) = string (defAttr `withBackColor` c) cName
734− d <- displayBounds t >>= displayContext t
735− outputPicture d pic
722+attributes_test_3 = Test
723+ { test_name = "Character attributes: Vivid background colors."
724+ , test_ID = "attributes_test_3"
725+ , test_action = do
726+ t <- current_terminal
727+ reserve_display t
728+ let pic = pic_for_image image
729+ image = horiz_cat [border, column_0, border, column_1, border, column_2, border]
730+ border = vert_cat $ replicate (length all_colors) $ string def_attr " | "
731+ column_0 = vert_cat $ map line_with_color_0 all_colors
732+ column_1 = vert_cat $ map line_with_color_1 all_bright_colors
733+ column_2 = vert_cat $ map (string def_attr . snd) all_colors
734+ line_with_color_0 (c, c_name) = string (def_attr `with_back_color` c) c_name
735+ line_with_color_1 (c, c_name) = string (def_attr `with_back_color` c) c_name
736+ d <- display_bounds t >>= display_context t
737+ output_picture d pic
736738 getLine
737− releaseDisplay t
738− releaseTerminal t
739+ release_display t
740+ release_terminal t
739741 return ()
740− , printSummary = do
742+ , print_summary = do
741743 putStr $ [s|
742744Once return is pressed:
743745 0. The screen will be cleared.
@@ -745,23 +747,23 @@ Once return is pressed:
745747 2. 9 lines of text in three columns will be drawn:
746748 a. The first column will contain be a name of a standard color for an 8
747749 color terminal rendered with the default foreground color with a
748− background the named color.
750+ background the named color.
749751 b. The first column will contain be a name of a standard color for an 8
750752 color terminal rendered with the default foreground color with the
751− background a vivid version of the named color.
753+ background a vivid version of the named color.
752754 c. The third column will be the name of a standard color rendered with
753755 the default attributes.
754−
756+
755757For instance, one line will contain be the word "magenta" and the word should
756−be rendered in the default foreground color over a magenta background.
758+be rendered in the default foreground color over a magenta background.
757759
758760I'm not actually sure exactly what "vivid" means in this context. For xterm the
759761vivid colors are brighter.
760762
761−Verify:
763+Verify:
762764 * The first column: The background color matches the named color.
763765 * The second column: The background color matches the named color and is
764− more vivid than the color used in the first column.
766+ more vivid than the color used in the first column.
765767 * The third column column: All text is rendered with the default attributes.
766768 * The vertical bars used in each line to mark the border of a column are
767769 lined up.
@@ -777,51 +779,51 @@ After return is pressed for the second time:
777779 0. The screen containing the test summary should be restored.
778780 1. The cursor should be visible.
779781|]
780− , confirmResults = do
782+ , confirm_results = do
781783 putStr $ [s|
782784Did the test output match the description?
783785|]
784− defaultSuccessConfirmResults
786+ default_success_confirm_results
785787 }
786788
787−attrCombos =
789+attr_combos =
788790 [ ( "default", id )
789− , ( "bold", flip withStyle bold )
790− , ( "blink", flip withStyle blink )
791− , ( "underline", flip withStyle underline )
792− , ( "bold + blink", flip withStyle (bold + blink) )
793− , ( "bold + underline", flip withStyle (bold + underline) )
794− , ( "underline + blink", flip withStyle (underline + blink) )
795− , ( "bold + blink + underline", flip withStyle (bold + blink + underline) )
791+ , ( "bold", flip with_style bold )
792+ , ( "blink", flip with_style blink )
793+ , ( "underline", flip with_style underline )
794+ , ( "bold + blink", flip with_style (bold + blink) )
795+ , ( "bold + underline", flip with_style (bold + underline) )
796+ , ( "underline + blink", flip with_style (underline + blink) )
797+ , ( "bold + blink + underline", flip with_style (bold + blink + underline) )
796798 ]
797799
798−attributesTest4 = Test
799− { testName = "Character attributes: Bold; Blink; Underline."
800− , testID = "attributesTest4"
801− , testAction = do
802− t <- standardIOConfig >>= outputForConfig
803− reserveDisplay t
804− let pic = picForImage image
805− image = horizCat [border, column0, border, column1, border]
806− border = vertCat $ replicate (length attrCombos) $ string defAttr " | "
807− column0 = vertCat $ map lineWithAttrs attrCombos
808− column1 = vertCat $ map (string defAttr . fst) attrCombos
809− lineWithAttrs (desc, attrF) = string (attrF defAttr) desc
810− d <- displayBounds t >>= displayContext t
811− outputPicture d pic
800+attributes_test_4 = Test
801+ { test_name = "Character attributes: Bold; Blink; Underline."
802+ , test_ID = "attributes_test_4"
803+ , test_action = do
804+ t <- current_terminal
805+ reserve_display t
806+ let pic = pic_for_image image
807+ image = horiz_cat [border, column_0, border, column_1, border]
808+ border = vert_cat $ replicate (length attr_combos) $ string def_attr " | "
809+ column_0 = vert_cat $ map line_with_attrs attr_combos
810+ column_1 = vert_cat $ map (string def_attr . fst) attr_combos
811+ line_with_attrs (desc, attr_f) = string (attr_f def_attr) desc
812+ d <- display_bounds t >>= display_context t
813+ output_picture d pic
812814 getLine
813− releaseDisplay t
814− releaseTerminal t
815+ release_display t
816+ release_terminal t
815817 return ()
816− , printSummary = do
818+ , print_summary = do
817819 putStr $ [s|
818820Once return is pressed:
819821 0. The screen will be cleared.
820822 1. The cursor will be hidden.
821− 2. 8 rows of text in two columns.
823+ 2. 8 rows of text in two columns.
822824 The rows will contain the following text:
823825 default
824− bold
826+ bold
825827 blink
826828 underline
827829 bold + blink
@@ -830,8 +832,8 @@ Once return is pressed:
830832 bold + blink + underline
831833 The first column will be rendered with the described attributes. The second
832834 column will be rendered with the default attributes.
833−
834−Verify:
835+
836+Verify:
835837 * The vertical bars used in each line to mark the border of a column are
836838 lined up.
837839 * The text in the first column is rendered as described.
@@ -840,31 +842,31 @@ After return is pressed for the second time:
840842 0. The screen containing the test summary should be restored.
841843 1. The cursor should be visible.
842844|]
843− , confirmResults = do
845+ , confirm_results = do
844846 putStr $ [s|
845847Did the test output match the description?
846848|]
847− defaultSuccessConfirmResults
849+ default_success_confirm_results
848850 }
849851
850−attributesTest5 = Test
851− { testName = "Character attributes: 240 color palette"
852− , testID = "attributesTest5"
853− , testAction = do
854− t <- standardIOConfig >>= outputForConfig
855− reserveDisplay t
856− let pic = picForImage image
857− image = vertCat $ map horizCat $ splitColorImages colorImages
858− colorImages = map (\i -> string (currentAttr `withBackColor` Color240 i) " ") [0..239]
859− splitColorImages [] = []
860− splitColorImages is = (take 20 is ++ [string defAttr " "]) : (splitColorImages (drop 20 is))
861− d <- displayBounds t >>= displayContext t
862− outputPicture d pic
852+attributes_test_5 = Test
853+ { test_name = "Character attributes: 240 color palette"
854+ , test_ID = "attributes_test_5"
855+ , test_action = do
856+ t <- current_terminal
857+ reserve_display t
858+ let pic = pic_for_image image
859+ image = vert_cat $ map horiz_cat $ split_color_images color_images
860+ color_images = map (\i -> string (current_attr `with_back_color` Color240 i) " ") [0..239]
861+ split_color_images [] = []
862+ split_color_images is = (take 20 is ++ [string def_attr " "]) : (split_color_images (drop 20 is))
863+ d <- display_bounds t >>= display_context t
864+ output_picture d pic
863865 getLine
864− releaseDisplay t
865− releaseTerminal t
866+ release_display t
867+ release_terminal t
866868 return ()
867− , printSummary = do
869+ , print_summary = do
868870 putStr $ [s|
869871Once return is pressed:
870872 0. The screen will be cleared.
@@ -872,304 +874,296 @@ Once return is pressed:
872874 2. A 20 character wide and 12 row high block of color squares. This should look like a palette
873875 of some sort. I'm not exactly sure if all color terminals use the same palette. I doubt it...
874876
875−Verify:
877+Verify:
876878
877879After return is pressed for the second time:
878880 0. The screen containing the test summary should be restored.
879881 1. The cursor should be visible.
880882|]
881− , confirmResults = do
883+ , confirm_results = do
882884 putStr $ [s|
883885Did the test output match the description?
884886|]
885− defaultSuccessConfirmResults
887+ default_success_confirm_results
886888 }
887889
888−inlineTest0 = Test
889− { testName = "Verify styled output can be performed without clearing the screen."
890− , testID = "inlineTest0"
891− , testAction = do
890+inline_test_0 = Test
891+ { test_name = "Verify styled output can be performed without clearing the screen."
892+ , test_ID = "inline_test_0"
893+ , test_action = do
892894 putStrLn "line 1."
893− putAttrChange_ $ backColor red >> applyStyle underline
895+ put_attr_change_ $ back_color red >> apply_style underline
894896 putStrLn "line 2."
895− putAttrChange_ $ defaultAll
897+ put_attr_change_ $ default_all
896898 putStrLn "line 3."
897− , printSummary = putStr $ [s|
899+ , print_summary = putStr $ [s|
898900lines are in order.
899901The second line "line 2" should have a red background and the text underline.
900902The third line "line 3" should be drawn in the same style as the first line.
901903|]
902904
903− , confirmResults = genericOutputMatchConfirm
905+ , confirm_results = generic_output_match_confirm
904906 }
905907
906−inlineTest1 = Test
907− { testName = "Verify styled output can be performed without clearing the screen."
908− , testID = "inlineTest1"
909− , testAction = do
908+inline_test_1 = Test
909+ { test_name = "Verify styled output can be performed without clearing the screen."
910+ , test_ID = "inline_test_1"
911+ , test_action = do
910912 putStr "Not styled. "
911− putAttrChange_ $ backColor red >> applyStyle underline
913+ put_attr_change_ $ back_color red >> apply_style underline
912914 putStr " Styled! "
913− putAttrChange_ $ defaultAll
915+ put_attr_change_ $ default_all
914916 putStrLn "Not styled."
915− , printSummary = putStr $ [s|
917+ , print_summary = putStr $ [s|
916918|]
917919
918− , confirmResults = genericOutputMatchConfirm
920+ , confirm_results = generic_output_match_confirm
919921 }
920922
921−inlineTest2 = Test
922− { testName = "Verify styled output can be performed without clearing the screen."
923− , testID = "inlineTest1"
924− , testAction = do
923+inline_test_2 = Test
924+ { test_name = "Verify styled output can be performed without clearing the screen."
925+ , test_ID = "inline_test_1"
926+ , test_action = do
925927 putStr "Not styled. "
926− putAttrChange_ $ backColor red >> applyStyle underline
928+ put_attr_change_ $ back_color red >> apply_style underline
927929 putStr " Styled! "
928− putAttrChange_ $ defaultAll
930+ put_attr_change_ $ default_all
929931 putStr "Not styled.\n"
930− , printSummary = putStr $ [s|
932+ , print_summary = putStr $ [s|
931933|]
932− , confirmResults = genericOutputMatchConfirm
934+ , confirm_results = generic_output_match_confirm
933935 }
934936
935−cursorHideTest0 :: Test
936−cursorHideTest0 = Test
937− { testName = "Verify the cursor is hid and re-shown. issue #7"
938− , testID = "cursorHideTest0"
939− , testAction = do
940− vty <- mkVty defaultConfig
941− showCursor $ outputIface vty
942− setCursorPos (outputIface vty) 5 5
943− nextEvent vty
944− hideCursor $ outputIface vty
945− nextEvent vty
937+cursor_hide_test_0 :: Test
938+cursor_hide_test_0 = Test
939+ { test_name = "Verify the cursor is hid and re-shown. issue #7"
940+ , test_ID = "cursor_hide_test_0"
941+ , test_action = do
942+ vty <- mkVty
943+ show_cursor $ terminal vty
944+ set_cursor_pos (terminal vty) 5 5
945+ next_event vty
946+ hide_cursor $ terminal vty
947+ next_event vty
946948 shutdown vty
947949 return ()
948− , printSummary = putStr $ [s|
950+ , print_summary = putStr $ [s|
949951 1. verify the cursor is displayed.
950952 2. press enter
951953 3. verify the cursor is hid.
952954 4. press enter.
953955 5. the display should return to the state before the test.
954956|]
955− , confirmResults = genericOutputMatchConfirm
957+ , confirm_results = generic_output_match_confirm
956958 }
957959
958−outputImageAndWait :: Image -> IO ()
959−outputImageAndWait image = do
960− let pic = picForImage image
961− outputPicAndWait pic
962−
963−outputPicAndWait :: Picture -> IO ()
964−outputPicAndWait pic = do
965− t <- standardIOConfig >>= outputForConfig
966− reserveDisplay t
967− d <- displayBounds t >>= displayContext t
968− outputPicture d pic
960+output_image_and_wait :: Image -> IO ()
961+output_image_and_wait image = do
962+ let pic = pic_for_image image
963+ output_pic_and_wait pic
964+
965+output_pic_and_wait :: Picture -> IO ()
966+output_pic_and_wait pic = do
967+ t <- current_terminal
968+ reserve_display t
969+ d <- display_bounds t >>= display_context t
970+ output_picture d pic
969971 getLine
970− releaseDisplay t
971− releaseTerminal t
972+ release_display t
973+ release_terminal t
972974 return ()
973−
974−vertCropTest0 :: Test
975−vertCropTest0 = Test
976− { testName = "Verify bottom cropping works as expected with single column chars"
977− , testID = "cropTest0"
978− , testAction = do
979− let block0 = cropBottom 2 $ vertCat $ map (string defAttr) lorumIpsum
980− block1 = vertCat $ map (string defAttr) $ take 2 lorumIpsum
981− image = block0 <-> backgroundFill 10 2 <-> block1
982− outputImageAndWait image
983− , printSummary = putStr $ [s|
975+
976+vert_crop_test_0 :: Test
977+vert_crop_test_0 = Test
978+ { test_name = "Verify bottom cropping works as expected with single column chars"
979+ , test_ID = "crop_test_0"
980+ , test_action = do
981+ let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum
982+ block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum
983+ image = block_0 <-> background_fill 10 2 <-> block_1
984+ output_image_and_wait image
985+ , print_summary = putStr $ [s|
984986 1. Verify the two text blocks are identical.
985987 2. press enter.
986988 3. the display should return to the state before the test.
987989|]
988− , confirmResults = genericOutputMatchConfirm
990+ , confirm_results = generic_output_match_confirm
989991 }
990992
991−vertCropTest1 :: Test
992−vertCropTest1 = Test
993− { testName = "Verify bottom cropping works as expected with double column chars"
994− , testID = "cropTest0"
995− , testAction = do
996− let block0 = cropBottom 2 $ vertCat $ map (string defAttr) lorumIpsumChinese
997− block1 = vertCat $ map (string defAttr) $ take 2 lorumIpsumChinese
998− image = block0 <-> backgroundFill 10 2 <-> block1
999− outputImageAndWait image
1000− , printSummary = putStr $ [s|
993+vert_crop_test_1 :: Test
994+vert_crop_test_1 = Test
995+ { test_name = "Verify bottom cropping works as expected with double column chars"
996+ , test_ID = "crop_test_0"
997+ , test_action = do
998+ let block_0 = crop_bottom 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
999+ block_1 = vert_cat $ map (string def_attr) $ take 2 lorum_ipsum_chinese
1000+ image = block_0 <-> background_fill 10 2 <-> block_1
1001+ output_image_and_wait image
1002+ , print_summary = putStr $ [s|
10011003 1. Verify the two text blocks are identical.
10021004 2. press enter.
10031005 3. the display should return to the state before the test.
10041006|]
1005− , confirmResults = genericOutputMatchConfirm
1007+ , confirm_results = generic_output_match_confirm
10061008 }
10071009
1008−vertCropTest2 :: Test
1009−vertCropTest2 = Test
1010− { testName = "Verify top cropping works as expected with single column chars"
1011− , testID = "cropTest2"
1012− , testAction = do
1013− let block0 = cropTop 2 $ vertCat $ map (string defAttr) lorumIpsum
1014− block1 = vertCat $ map (string defAttr) $ drop (length lorumIpsum - 2) lorumIpsum
1015− image = block0 <-> backgroundFill 10 2 <-> block1
1016− outputImageAndWait image
1017− , printSummary = putStr $ [s|
1010+vert_crop_test_2 :: Test
1011+vert_crop_test_2 = Test
1012+ { test_name = "Verify top cropping works as expected with single column chars"
1013+ , test_ID = "crop_test_0"
1014+ , test_action = do
1015+ let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum
1016+ block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum - 2) lorum_ipsum
1017+ image = block_0 <-> background_fill 10 2 <-> block_1
1018+ output_image_and_wait image
1019+ , print_summary = putStr $ [s|
10181020 1. Verify the two text blocks are identical.
10191021 2. press enter.
10201022 3. the display should return to the state before the test.
10211023|]
1022− , confirmResults = genericOutputMatchConfirm
1024+ , confirm_results = generic_output_match_confirm
10231025 }
10241026
1025−vertCropTest3 :: Test
1026−vertCropTest3 = Test
1027− { testName = "Verify top cropping works as expected with double column chars"
1028− , testID = "cropTest0"
1029− , testAction = do
1030− let block0 = cropTop 2 $ vertCat $ map (string defAttr) lorumIpsumChinese
1031− block1 = vertCat $ map (string defAttr) $ drop (length lorumIpsumChinese - 2 ) lorumIpsumChinese
1032− image = block0 <-> backgroundFill 10 2 <-> block1
1033− outputImageAndWait image
1034− , printSummary = putStr $ [s|
1027+vert_crop_test_3 :: Test
1028+vert_crop_test_3 = Test
1029+ { test_name = "Verify top cropping works as expected with double column chars"
1030+ , test_ID = "crop_test_0"
1031+ , test_action = do
1032+ let block_0 = crop_top 2 $ vert_cat $ map (string def_attr) lorum_ipsum_chinese
1033+ block_1 = vert_cat $ map (string def_attr) $ drop (length lorum_ipsum_chinese - 2 ) lorum_ipsum_chinese
1034+ image = block_0 <-> background_fill 10 2 <-> block_1
1035+ output_image_and_wait image
1036+ , print_summary = putStr $ [s|
10351037 1. Verify the two text blocks are identical.
10361038 2. press enter.
10371039 3. the display should return to the state before the test.
10381040|]
1039− , confirmResults = genericOutputMatchConfirm
1041+ , confirm_results = generic_output_match_confirm
10401042 }
10411043
1042−horizCropTest0 :: Test
1043−horizCropTest0 = Test
1044− { testName = "Verify right cropping works as expected with single column chars"
1045− , testID = "cropTest0"
1046− , testAction = do
1047− let baseImage = vertCat $ map (string defAttr) lorumIpsum
1048− croppedImage = cropRight (imageWidth baseImage `div` 2) baseImage
1049− image = baseImage <-> backgroundFill 10 2 <-> croppedImage
1050− outputImageAndWait image
1051− , printSummary = putStr $ [s|
1044+horiz_crop_test_0 :: Test
1045+horiz_crop_test_0 = Test
1046+ { test_name = "Verify right cropping works as expected with single column chars"
1047+ , test_ID = "crop_test_0"
1048+ , test_action = do
1049+ let base_image = vert_cat $ map (string def_attr) lorum_ipsum
1050+ cropped_image = crop_right (image_width base_image `div` 2) base_image
1051+ image = base_image <-> background_fill 10 2 <-> cropped_image
1052+ output_image_and_wait image
1053+ , print_summary = putStr $ [s|
10521054 1. Verify the bottom text block is about half the width of the top text block.
10531055 2. press enter.
10541056 3. the display should return to the state before the test.
10551057|]
1056− , confirmResults = genericOutputMatchConfirm
1058+ , confirm_results = generic_output_match_confirm
10571059 }
10581060
1059−horizCropTest1 :: Test
1060−horizCropTest1 = Test
1061− { testName = "Verify right cropping works as expected with double column chars"
1062− , testID = "cropTest0"
1063− , testAction = do
1064− let baseImage = vertCat $ map (string defAttr) lorumIpsumChinese
1065− croppedImage = cropRight (imageWidth baseImage `div` 2) baseImage
1066− image = baseImage <-> backgroundFill 10 2 <-> croppedImage
1067− outputImageAndWait image
1068− , printSummary = putStr $ [s|
1061+horiz_crop_test_1 :: Test
1062+horiz_crop_test_1 = Test
1063+ { test_name = "Verify right cropping works as expected with double column chars"
1064+ , test_ID = "crop_test_0"
1065+ , test_action = do
1066+ let base_image = vert_cat $ map (string def_attr) lorum_ipsum_chinese
1067+ cropped_image = crop_right (image_width base_image `div` 2) base_image
1068+ image = base_image <-> background_fill 10 2 <-> cropped_image
1069+ output_image_and_wait image
1070+ , print_summary = putStr $ [s|
10691071 1. Verify the bottom text block is the left half of the top block. Ellipses on the right edge are OK.
10701072 2. press enter.
10711073 3. the display should return to the state before the test.
10721074|]
1073− , confirmResults = genericOutputMatchConfirm
1075+ , confirm_results = generic_output_match_confirm
10741076 }
10751077
1076−horizCropTest2 :: Test
1077−horizCropTest2 = Test
1078− { testName = "Verify left cropping works as expected with single column chars"
1079− , testID = "cropTest0"
1080− , testAction = do
1081− let baseImage = vertCat $ map (string defAttr) lorumIpsum
1082− croppedImage = cropLeft (imageWidth baseImage `div` 2) baseImage
1083− image = baseImage <-> backgroundFill 10 2 <-> croppedImage
1084− outputImageAndWait image
1085− , printSummary = putStr $ [s|
1078+horiz_crop_test_2 :: Test
1079+horiz_crop_test_2 = Test
1080+ { test_name = "Verify left cropping works as expected with single column chars"
1081+ , test_ID = "crop_test_0"
1082+ , test_action = do
1083+ let base_image = vert_cat $ map (string def_attr) lorum_ipsum
1084+ cropped_image = crop_left (image_width base_image `div` 2) base_image
1085+ image = base_image <-> background_fill 10 2 <-> cropped_image
1086+ output_image_and_wait image
1087+ , print_summary = putStr $ [s|
10861088 1. Verify the bottom text block is the right half of the top text block.
10871089 2. press enter.
10881090 3. the display should return to the state before the test.
10891091|]
1090− , confirmResults = genericOutputMatchConfirm
1092+ , confirm_results = generic_output_match_confirm
10911093 }
10921094
1093−horizCropTest3 :: Test
1094−horizCropTest3 = Test
1095− { testName = "Verify right cropping works as expected with double column chars"
1096− , testID = "cropTest0"
1097− , testAction = do
1098− let baseImage = vertCat $ map (string defAttr) lorumIpsumChinese
1099− croppedImage = cropLeft (imageWidth baseImage `div` 2) baseImage
1100− image = baseImage <-> backgroundFill 10 2 <-> croppedImage
1101− outputImageAndWait image
1102− , printSummary = putStr $ [s|
1095+horiz_crop_test_3 :: Test
1096+horiz_crop_test_3 = Test
1097+ { test_name = "Verify right cropping works as expected with double column chars"
1098+ , test_ID = "crop_test_0"
1099+ , test_action = do
1100+ let base_image = vert_cat $ map (string def_attr) lorum_ipsum_chinese
1101+ cropped_image = crop_left (image_width base_image `div` 2) base_image
1102+ image = base_image <-> background_fill 10 2 <-> cropped_image
1103+ output_image_and_wait image
1104+ , print_summary = putStr $ [s|
11031105 1. Verify the bottom text block is the right half of the top block. Ellipses on the left edge are OK.
11041106 2. press enter.
11051107 3. the display should return to the state before the test.
11061108|]
1107− , confirmResults = genericOutputMatchConfirm
1109+ , confirm_results = generic_output_match_confirm
11081110 }
11091111
1110−layer0 :: Test
1111−layer0 = Test
1112− { testName = "verify layer 0"
1113− , testID = "layer0"
1114− , testAction = do
1115− let upperImage = vertCat $ map (string defAttr) lorumIpsumChinese
1116− lowerImage = vertCat $ map (string defAttr) lorumIpsum
1117− p = picForLayers [upperImage, lowerImage]
1118− outputPicAndWait p
1119− , printSummary = putStr $ [s|
1112+layer_0 :: Test
1113+layer_0 = Test
1114+ { test_name = "verify layer 0"
1115+ , test_ID = "layer_0"
1116+ , test_action = do
1117+ let upper_image = vert_cat $ map (string def_attr) lorum_ipsum_chinese
1118+ lower_image = vert_cat $ map (string def_attr) lorum_ipsum
1119+ p = pic_for_layers [upper_image, lower_image]
1120+ output_pic_and_wait p
1121+ , print_summary = putStr $ [s|
11201122 1. Verify the text block appears to be Chinese text placed on top Latin text.
11211123 2. press enter.
11221124 3. the display should return to the state before the test.
11231125|]
1124− , confirmResults = genericOutputMatchConfirm
1126+ , confirm_results = generic_output_match_confirm
11251127 }
11261128
1127−layer1 :: Test
1128−layer1 = Test
1129− { testName = "verify layer 1"
1130− , testID = "layer1"
1131− , testAction = do
1132− let upperImage = vertCat $ map (string defAttr) lorumIpsumChinese
1133− block = resize 10 10 upperImage
1134− layer0 = vertCat $ map (string defAttr) lorumIpsum
1135− layer1 = charFill (defAttr `withBackColor` blue) '#' 1000 1000
1136− cheesyAnim0 block [layer0, layer1]
1137− , printSummary = putStr $ [s|
1129+layer_1 :: Test
1130+layer_1 = Test
1131+ { test_name = "verify layer 1"
1132+ , test_ID = "layer_1"
1133+ , test_action = do
1134+ let upper_image = vert_cat $ map (string def_attr) lorum_ipsum_chinese
1135+ block = resize 10 10 upper_image
1136+ layer_0 = vert_cat $ map (string def_attr) lorum_ipsum
1137+ layer_1 = char_fill (def_attr `with_back_color` blue) '#' 1000 1000
1138+ cheesy_anim_0 block [layer_0, layer_1]
1139+ , print_summary = putStr $ [s|
11381140 1. Verify the text block appears to be Chinese text moving on top a Latin text.
11391141 Which is all on a background of '#' characters over blue.
11401142 2. press enter.
11411143 3. the display should return to the state before the test.
11421144|]
1143− , confirmResults = genericOutputMatchConfirm
1145+ , confirm_results = generic_output_match_confirm
11441146 }
11451147
1146−cheesyAnim0 :: Image -> [Image] -> IO ()
1147−cheesyAnim0 i background = do
1148− t <- standardIOConfig >>= outputForConfig
1149− reserveDisplay t
1150− bounds <- displayBounds t
1151− d <- displayContext t bounds
1152− forM_ [0..2] $ \t -> do
1153− forM_ [0..100] $ \t -> do
1154− let i_offset = translate (t `mod` fst bounds)
1155− (t `div` 2 `mod` snd bounds)
1156− i
1157− let pic = picForLayers $ i_offset : background
1158− outputPicture d pic
1159− threadDelay 50000
1160− forM_ [0..100] $ \t -> do
1161− let i_offset = translate (t * (-1) `mod` fst bounds)
1162− (t * (-1) `div` 2 `mod` snd bounds)
1148+cheesy_anim_0 :: Image -> [Image] -> IO ()
1149+cheesy_anim_0 i background = do
1150+ t <- current_terminal
1151+ reserve_display t
1152+ bounds <- display_bounds t
1153+ d <- display_context t bounds
1154+ forM_ [0..100] $ \t -> do
1155+ let i_offset = translate (t `mod` region_width bounds)
1156+ (t `div` 2 `mod` region_height bounds)
11631157 i
1164− let pic = picForLayers $ i_offset : background
1165− outputPicture d pic
1158+ let pic = pic_for_layers $ i_offset : background
1159+ output_picture d pic
11661160 threadDelay 50000
1167− releaseDisplay t
1168− releaseTerminal t
1161+ release_display t
1162+ release_terminal t
11691163 return ()
11701164
1171−lorumIpsum :: [String]
1172−lorumIpsum = lines [s|
1165+lorum_ipsum :: [String]
1166+lorum_ipsum = lines [s|
11731167Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,
11741168totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae
11751169dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit,
@@ -1181,8 +1175,8 @@ commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate v
11811175molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
11821176|]
11831177
1184−lorumIpsumChinese :: [String]
1185−lorumIpsumChinese = lines [s|
1178+lorum_ipsum_chinese :: [String]
1179+lorum_ipsum_chinese = lines [s|
11861180輐銛 螷蟞覮 裌覅詵 暕 鴅噮 槶 惝掭掝 婸媥媕 耏胠臿, 汫汭沎 忕汌卣 蚡袀 僣 蒮 瀁瀎瀊 渮湸湤 緌翢,
11871181腠腶舝 糲蘥蠩 樏殣氀 蒮 蹢鎒 滍 鸄齴 櫧櫋瀩 鬄鵊鵙 莃荶衒, 毸溠 橀 簎艜薤 莃荶衒 翣聜蒢
11881182斔櫅檷 晛桼桾 拻敁柧 犿玒 膣, 墐 笓粊紒 bacon 鼀齕, 蔝蓶蓨 顊顃餭 姴怤 骱 暕 蹢鎒鎛 藒襓謥 鄻鎟霣