3import Graphics.Vty hiding ( pad )
5import Control.Concurrent( threadDelay )
6import Control.Monad( liftM2 )
11import System.Environment( getArgs )
17 let fixed_gen = mkStdGen 0
21 [] -> mkVty >>= liftM2 (>>) (run $ Just 0) shutdown
22 ["--delay"] -> mkVty >>= liftM2 (>>) (run $ Just 1000000) shutdown
23 ["--slow"] -> mkVty >>= liftM2 (>>) (run Nothing ) shutdown
24 _ -> fail "usage: ./Bench [--slow|--delay]"
26run (Just delay) vt = mapM_ (\p -> update vt p >> threadDelay delay) . benchgen =<< display_bounds (terminal vt)
27run Nothing vt = mapM_ (update vt) (benchgen $ DisplayRegion 200 100)
29-- Currently, we just do scrolling.
30takem :: (a -> Word) -> Word -> [a] -> ([a],[a])
31takem len n [] = ([],[])
32takem len n (x:xs) | lx > n = ([], x:xs)
33 | True = let (tk,dp) = takem len (n - lx) xs in (x:tk,dp)
36fold :: (a -> Word) -> [Word] -> [a] -> [[a]]
38fold len (ll:lls) xs = let (tk,dp) = takem len ll xs in tk : fold len lls dp
40lengths :: Word -> StdGen -> [Word]
42 let (x,g2) = randomR (0,fromEnum ml) g
43 (y,g3) = randomR (0,x) g2
44 in (toEnum y) : lengths ml g3
46nums :: StdGen -> [(Attr, String)]
47nums g = let (x,g2) = (random g :: (Int, StdGen))
49 in ( if c then def_attr `with_fore_color` red else def_attr
53pad :: Word -> Image -> Image
54pad ml img = img <|> char_fill def_attr ' ' (ml - image_width img) 1
56clines :: StdGen -> Word -> [Image]
57clines g maxll = map (pad maxll . horiz_cat . map (uncurry string)) $ fold (toEnum . length . snd) (lengths maxll g1) (nums g2)
58 where (g1,g2) = split g
60benchgen :: DisplayRegion -> [Picture]
61benchgen (DisplayRegion w h) = take 500 $ map ((\i -> pic_for_image i) . vert_cat . take (fromEnum h)) $ tails $ clines (mkStdGen 42) w
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list