@@ -1,4 +1,4 @@
1−module Main where
1+module BenchVerticalScroll where
3import Graphics.Vty hiding ( pad )
3import Graphics.Vty hiding ( pad )
@@ -16,15 +16,9 @@ import System.Random
17 let fixed_gen = mkStdGen 0
17 let fixed_gen = mkStdGen 0
18 setStdGen fixed_gen
18 setStdGen fixed_gen
21− [] -> mkVty >>= liftM2 (>>) (run $ Just 0) shutdown
19+ mkVty >>= liftM2 (>>) run shutdown
22− ["--delay"] -> mkVty >>= liftM2 (>>) (run $ Just 1000000) shutdown
23− ["--slow"] -> mkVty >>= liftM2 (>>) (run Nothing ) shutdown
24− _ -> fail "usage: ./Bench [--slow|--delay]"
26−run (Just delay) vt = mapM_ (\p -> update vt p >> threadDelay delay) . benchgen =<< display_bounds (terminal vt)
21+run vt = mapM_ (\p -> update vt p) . benchgen =<< display_bounds (terminal vt)
27−run Nothing vt = mapM_ (update vt) (benchgen $ DisplayRegion 200 100)
29-- Currently, we just do scrolling.
23-- Currently, we just do scrolling.
30takem :: (a -> Word) -> Word -> [a] -> ([a],[a])
24takem :: (a -> Word) -> Word -> [a] -> ([a],[a])
@@ -54,9 +48,13 @@ pad :: Word -> Image -> Image
54pad ml img = img <|> char_fill def_attr ' ' (ml - image_width img) 1
48pad ml img = img <|> char_fill def_attr ' ' (ml - image_width img) 1
56clines :: StdGen -> Word -> [Image]
50clines :: StdGen -> Word -> [Image]
57−clines g maxll = map (pad maxll . horiz_cat . map (uncurry string)) $ fold (toEnum . length . snd) (lengths maxll g1) (nums g2)
51+clines g maxll = map (pad maxll . horiz_cat . map (uncurry string))
52+ $ fold (toEnum . length . snd) (lengths maxll g1) (nums g2)
58 where (g1,g2) = split g
53 where (g1,g2) = split g
60benchgen :: DisplayRegion -> [Picture]
55benchgen :: DisplayRegion -> [Picture]
56+benchgen (DisplayRegion w h)
61−benchgen (DisplayRegion w h) = take 500 $ map ((\i -> pic_for_image i) . vert_cat . take (fromEnum h)) $ tails $ clines (mkStdGen 42) w
57+ = take 2000 $ map ((\i -> pic_for_image i) . vert_cat . take (fromEnum h))
59+ $ clines (mkStdGen 80) w