vty/test/vty_issue_18.hs
coreyoconnor 7b38759846 use alloca instead of mallocBytes for exception safety
Ignore-this: 1d31bef2e227fefafe8bb4b6f9511e1d

darcs-hash:20090904172928-f0a0d-987b6931294fd33f7825eddc0adf04c81716a4dd.gz
2009-09-04 10:29:28 -07:00

44 lines
942 B
Haskell

module Main
where
import Graphics.Vty
import Graphics.Vty.Debug
import System.IO
main :: IO ()
main = do
vty <- mkVty
(sx, sy) <- getSize vty
play vty sx sy
play :: Vty -> Int -> Int -> IO ()
play vty sx sy =
let
testScreen = pic {
pCursor = NoCursor
, pImage = box 10 10 }
in do
update vty testScreen
getEvent vty
shutdown vty
return ()
{-
k <- getEvent vty
case k of
EvKey KEsc [] -> shutdown vty >> return ()
EvResize nx ny -> play vty nx ny
_ -> shutdown vty
-}
box :: Int -> Int -> Image
box w h =
let
corner = renderChar attr '+'
vertLine = renderFill attr '|' 1 (h - 2)
horizLine = corner <|> renderHFill attr '-' (w - 2) <|> corner
centerArea = vertLine <|> renderFill attr 'X' (w - 2) (h - 2) <|> vertLine
in
horizLine <-> centerArea <-> horizLine