DIRECTORY TerminalIO, Rope, Convert, Menus, OrderedRefArray, IPTop, IPTopOps, IPMVStackOps; IPMVStackOpsImpl: CEDAR PROGRAM IMPORTS TerminalIO, Rope, Convert, OrderedRefArray, IPTopOps EXPORTS IPMVStackOps = BEGIN OPEN TIO: TerminalIO, IPMVStackOps; MenuHit: PUBLIC PROC [top: IPTop.Ref, oldPrevTrack, trackKept: LIST OF REF, command: ATOM, mouse: Menus.MouseButton, shift, control: BOOL, trialSolns: OrderedRefArray.Ref] RETURNS [prevTrack: LIST OF REF, reGeom: BOOL _ FALSE, refreshFlag: BOOL _ TRUE] ={ prevTrack _ oldPrevTrack; --default SELECT command FROM $Undo =>{noOfSteps: NAT _ TIO.RequestInt["Number of Steps to Undo: "]; TIO.WriteRope[Rope.Cat["Undoing ", Convert.RopeFromInt[noOfSteps], " steps..."]]; WHILE noOfSteps # 0 DO prevTrack _ CONS[IPTopOps.Undo1[top], prevTrack]; noOfSteps _ noOfSteps.PRED; ENDLOOP; reGeom _ TRUE}; $Un1 =>{ TIO.WriteRope["Undo previous step..."]; prevTrack _ CONS[IPTopOps.Undo1[top], prevTrack]; reGeom _ TRUE}; $ToSoln =>{ IF trialSolns = NIL THEN {TIO.WriteRope["No Solutions .. doing nothing"]; RETURN} ELSE { solnNum: INT _ TIO.RequestInt[Rope.Cat[ "Select a solution in [1..", Convert.RopeFromInt[OrderedRefArray.Size[trialSolns]], "]: "]]; value: INT; soln: REF; TIO.WriteRope["GettingSolution... this solution has value"]; [soln, value] _ OrderedRefArray.Fetch[trialSolns, solnNum]; prevTrack _ IPTopOps.Undo[top, IPTopOps.StackSize[top]]; IPTopOps.Redo[top, NARROW[soln]]; TIO.WriteInt[value];}; reGeom _ TRUE}; $Redo =>{which: NAT _ TIO.RequestSelection["OneOf: ", LIST["Previous Track", "Go to the track kept"]]; TIO.WriteRope["Redoing.."]; SELECT which FROM 1 => { oldPrevTrack: LIST OF REF _ prevTrack; IF prevTrack = NIL THEN {TIO.WriteRope["previous track empty...Done"]; RETURN} ELSE {prevTrack _ IPTopOps.Undo[top, IPTopOps.StackSize[top]]; IPTopOps.Redo[top, oldPrevTrack]}; }; 2 => { prevTrack _ IPTopOps.Undo[top, IPTopOps.StackSize[top]]; IPTopOps.Redo[top, trackKept];}; ENDCASE => TIO.WriteRope["..Nothing to do"]; reGeom _ TRUE}; $Re1 =>{ TIO.WriteRope["Redoing ..."]; IF prevTrack = NIL THEN {TIO.WriteRope["nothing...Done"]; RETURN} ELSE {TIO.WriteRope["1 step.."]; IPTopOps.Redo1[top, prevTrack.first];}; prevTrack _ prevTrack.rest; reGeom _ TRUE}; $KepTrk =>{ TIO.WriteRope["KeepingTrack.."]; trackKept _ IPTopOps.GetTrack[top]; refreshFlag _ FALSE;}; $ClrStks => { TIO.WriteRope["Clear undo and redo stacks.."]; prevTrack _ IPTopOps.GetTrack[top]; trackKept _ NIL; --What was there is now meaningless-- IPTopOps.ResetStacks[top]; refreshFlag _ FALSE; }; $StkSz =>{ TIO.WriteRope[Rope.Cat["The Stacks size is: ", Convert.RopeFromInt[IPTopOps.StackSize[top]], "\n"]]; refreshFlag _ FALSE;}; ENDCASE => ERROR; }; --MenuHit END. ^--File: IPMVStackOpsImpl.mesa Last Edited by: CSChow, January 12, 1985 10:25:12 am PST Ê™˜Jšœ™J™8J™šÏk ˜ J˜ Icodešœ˜K˜J˜Jšœ˜Jšœ˜Jšœ ˜ Jšœ ˜ —J˜šœœÏa˜ Kšœ8˜?Kšœ˜Iunitšœœœ˜)J˜š Ïnœœœ+œœœ œ,œ#œ œœœ œœœœ˜ÿKšœÏc ˜#šœ ˜šœœœ)˜FJšœN˜Qšœ˜Kšœ œ!˜1Kšœœ˜Kšœ˜—Jšœ œ˜—šœ˜Jšœ$˜'Jšœ œ!˜1Kšœ œ˜—˜ šœœ˜Kšœœ-œ˜=šœ˜šœ œœ˜'Kšœ˜Kšœ8˜8Kšœ˜—K˜ Kšœœ˜ K˜Kšœ"˜"—Kšœ˜——šœ˜Kšœ8˜8Kšœ ˜ —Kšœœ˜,—Kšœ œ˜—šœ˜Jšœ˜šœ œ˜Kšœœœ˜.Kšœœ?˜H—Jšœ˜Jšœ œ˜—˜ Jšœ˜ Jšœ#˜#Jšœœ˜—˜ Kšœ+˜.Jšœ#˜#Jšœ œ %˜6Jšœ˜Jšœœ˜Jšœ˜—šœ ˜ Jšœa˜dJšœœ˜—Kšœœ˜—K˜Kšœ  ˜ —J˜Jšœ˜——…— ˜