1 -- LML original: Sandra Foubister, 1990 2 -- Haskell translation: Colin Runciman, May 1991 3 4 module Mgrfuns( 5 aligntext, bitcopy, circle, clear, clearevent, 6 clearmode, destroywin, dragcircle, dragline, 7 dragrect, font, func, go, highlight, 8 line, mapevent, newwin, rcircle, 9 selectwin, setevent, setmode, shapewindow, standend, 10 stringto, standout, textregion, textreset) where 11 12 import Diff 13 14 --CR should try to generalise this to cope with more (all?) commands 15 escom :: [Char] -> [Int] -> [Char] 16 escom str ns = '\ESC' : foldr f "" ns 17 where 18 f n "" = show n ++ str 19 f n s = show n ++ "," ++ s 20 21 aligntext = '\ESC' : "l" 22 23 bitcopy = escom "b" -- xd yd w h xs ys 24 25 circle = escom "o" -- x y r 26 27 clear = "\FF" 28 29 clearevent event = escom "e" [mapevent event] 30 31 clearmode mode = escom "s" [mode] 32 33 destroywin n = escom ",OZ" [n] 34 35 dragcircle [x1,y1,x2,y2] = 36 circle [x1,y1,r] 37 where 38 r = bcroot (square (diff x1 x2) + square (diff y1 y2)) 39 40 dragline = "%l\n" 41 42 dragrect = "%r\n" 43 44 font x = escom "F" [x] 45 46 func mode = escom "b" [mode] 47 48 go = escom "g" -- x y 49 50 highlight = escom "H" -- x y w h 51 52 line = escom "l" -- x0 y0 x1 y1 53 54 --CR explanation or abstraction needed for numeric literals here 55 mapevent event = if event == 3 || event == 4 then 2-event else event 56 57 newwin = escom "Z" -- x y w h 58 59 rcircle r = escom "o" [r] 60 61 selectwin n = escom "Z" [n] 62 63 setevent event str = escom ("e"++str) [mapevent event, length str] 64 65 setmode mode = escom "S" [mode] 66 67 shapewindow = escom "W" -- x y w h 68 69 standend = '\ESC':",n" 70 71 standout = '\ESC':"i" -- OK 72 73 stringto win x y str = escom ("."++str) [win,x,y,length str] 74 75 textregion = escom "t" -- x y wide high 76 77 textreset = '\ESC':"t" -- OK 78 79 80