home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 876 / hugs.sis / AnsiScreen.hs < prev    next >
Encoding:
Text File  |  2000-09-21  |  933 b   |  34 lines

  1. -----------------------------------------------------------------------------
  2. -- Library of escape sequences for ANSI compatible screen I/O:
  3. --
  4. -- Suitable for use with Hugs 98
  5. -----------------------------------------------------------------------------
  6.  
  7. module AnsiScreen(
  8.     Pos(..),
  9.     cls,
  10.     goto, at, home, 
  11.     highlight
  12.     ) where
  13.  
  14. -- Basic screen control codes:
  15.  
  16. type Pos           = (Int,Int)
  17.  
  18. at        :: Pos -> String -> String
  19. highlight :: String -> String
  20. goto      :: Int -> Int -> String
  21. home      :: String
  22. cls       :: String
  23.  
  24. at (x,y) s  = goto x y ++ s
  25. highlight s = "\ESC[7m"++s++"\ESC[0m"
  26. goto x y    = '\ESC':'[':(show y ++(';':show x ++ "H"))
  27. home        = goto 1 1
  28.  
  29. -- Choose whichever of the following lines is suitable for your system:
  30. cls         = "\ESC[2J"     -- for PC with ANSI.SYS
  31. --cls         = "\^L"         -- for Sun window
  32.  
  33. -----------------------------------------------------------------------------
  34.