summaryrefslogtreecommitdiff
path: root/src/ch3/SimpleGraphics.hs
blob: 5e160a734eb5c3a99cab5793588426f7a895fe78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module SimpleGraphics where

import Graphics.SOE

main0 = runGraphics (
        do w <- openWindow "My First Graphics Program" (300,300)
           drawInWindow w (text (100,200) "HelloGraphicsWolrd")
           spaceClose w
        )

spaceClose :: Window -> IO ()
spaceClose w = do k <- getKey w
                  if k == ' ' then closeWindow w
                             else spaceClose w
getLine :: IO String
getLine = do c <- getChar
             if c == '\n' then return ""
                          else do v <- SimpleGraphics.getLine
                                  return (c:v)

putStr :: String -> IO ()
putStr [] = return ()
putStr (x:xs) = do putChar x
                   SimpleGraphics.putStr xs