1signature DVI_STATE = 2sig 3 val getX : unit -> BasicTypes.dist 4 val moveX : BasicTypes.dist -> unit 5 val resetX : unit -> unit 6 7 val getY : unit -> BasicTypes.dist 8 val moveY : BasicTypes.dist -> unit 9 val resetY : unit -> unit 10 11 val sameFont : FontTypes.fontNr -> bool 12 val setFont : FontTypes.fontNr -> unit 13 val resetFont : unit -> unit 14 15 val isDefined : FontTypes.fontNr -> bool 16 val addFont : FontTypes.fontNr -> unit 17 val definedFonts : unit -> FontTypes.fontNr list 18 19 val actPage : unit -> int 20 val nextPage : unit -> unit 21 22 val prevPos : unit -> int 23 val actPos : unit -> int 24 val markPos : unit -> unit 25 26 val incLevel : unit -> unit 27 val decLevel : unit -> unit 28 val maxLevel : unit -> int 29 30 val initState : unit -> unit 31end 32(*----------*) 33 34structure DviState: DVI_STATE = 35struct 36 open BasicTypes; open FontTypes 37 open General; open Out 38 39 fun incr (n: int) r = (r := !r + n) 40 val inc = incr 1 41 val dec = incr (~1) 42 43 val xMove = ref 0 44 fun getX () = !xMove 45 fun moveX dx = incr dx xMove 46 fun resetX () = (xMove := 0) 47 48 val yMove = ref 0 49 fun getY () = !yMove 50 fun moveY dy = incr dy yMove 51 fun resetY () = (yMove := 0) 52 53 val noFont = ~1 54 val actFont = ref noFont 55 fun sameFont f = (f = !actFont) 56 fun setFont f = (actFont := f) 57 fun resetFont () = (actFont := noFont) 58 59 val fontList = ref ([]: fontNr list) 60 fun isDefined f = contains (!fontList) f 61 fun addFont f = (fontList := f :: !fontList) 62 fun definedFonts () = !fontList 63 64 val pageNr = ref 0 65 fun actPage () = !pageNr 66 fun nextPage () = inc pageNr 67 68 val oldPos = ref (~1) 69 val newPos = ref (~1) 70 fun prevPos () = !oldPos 71 fun actPos () = !newPos 72 fun markPos () = (oldPos := !newPos; newPos := outPos ()) 73 74 val ActLevel = ref 0 75 val MaxLevel = ref 0 76 fun incLevel () = (inc ActLevel; 77 if !ActLevel > !MaxLevel then inc MaxLevel else () ) 78 fun decLevel () = dec ActLevel 79 fun maxLevel () = !MaxLevel 80 81 fun initState () = 82 ( xMove := 0; 83 yMove := 0; 84 actFont := noFont; 85 fontList := []; 86 pageNr := 0; 87 oldPos := (~1); 88 newPos := (~1); 89 ActLevel := 0; 90 MaxLevel := 0 91 ) 92 93end 94