DIRECTORY TerminalIO, Rope, Convert, Menus, OrderedRefArray, IO, IPTop, IPTopOps, IPMVStackOps; IPMVStackOpsImpl: CEDAR PROGRAM IMPORTS TerminalIO, Rope, Convert, OrderedRefArray, IPTopOps, IO EXPORTS IPMVStackOps = BEGIN OPEN 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 _ TerminalIO.RequestInt["Number of Steps to Undo: "]; TerminalIO.PutRope[Rope.Cat["Undoing ", Convert.RopeFromInt[noOfSteps], " steps..."]]; WHILE noOfSteps # 0 DO prevTrack _ CONS[IPTopOps.Undo1[top], prevTrack]; noOfSteps _ noOfSteps.PRED; ENDLOOP; reGeom _ TRUE}; $Un1 =>{ TerminalIO.PutRope["Undo previous step..."]; prevTrack _ CONS[IPTopOps.Undo1[top], prevTrack]; reGeom _ TRUE}; $ToSoln =>{ IF trialSolns = NIL THEN {TerminalIO.PutRope["No Solutions .. doing nothing"]; RETURN} ELSE { solnNum: INT _ TerminalIO.RequestInt[Rope.Cat[ "Select a solution in [1..", Convert.RopeFromInt[OrderedRefArray.Size[trialSolns]], "]: "]]; value: INT; soln: REF; TerminalIO.PutRope["GettingSolution... this solution has value"]; [soln, value] _ OrderedRefArray.Fetch[trialSolns, solnNum]; prevTrack _ IPTopOps.Undo[top, IPTopOps.StackSize[top]]; IPTopOps.Redo[top, NARROW[soln]]; TerminalIO.PutF1["%g", IO.int[value]];}; reGeom _ TRUE}; $Redo =>{which: NAT _ TerminalIO.RequestSelection["OneOf: ", LIST["Previous Track", "Go to the track kept"]]; TerminalIO.PutRope["Redoing.."]; SELECT which FROM 1 => { oldPrevTrack: LIST OF REF _ prevTrack; IF prevTrack = NIL THEN {TerminalIO.PutRope["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 => TerminalIO.PutRope["..Nothing to do"]; reGeom _ TRUE}; $Re1 =>{ TerminalIO.PutRope["Redoing ..."]; IF prevTrack = NIL THEN {TerminalIO.PutRope["nothing...Done"]; RETURN} ELSE {TerminalIO.PutRope["1 step.."]; IPTopOps.Redo1[top, prevTrack.first];}; prevTrack _ prevTrack.rest; reGeom _ TRUE}; $KepTrk =>{ TerminalIO.PutRope["KeepingTrack.."]; trackKept _ IPTopOps.GetTrack[top]; refreshFlag _ FALSE;}; $ClrStks => { TerminalIO.PutRope["Clear undo and redo stacks.."]; prevTrack _ IPTopOps.GetTrack[top]; trackKept _ NIL; --What was there is now meaningless-- IPTopOps.ResetStacks[top]; refreshFlag _ FALSE; }; $StkSz =>{ TerminalIO.PutRope[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šÏc™Jšœ5Ïk™8J™šž ˜ J˜ Icodešœ˜K˜J˜Jšœ˜Jšžœ˜Jšœ˜Jšœ ˜ Jšœ ˜ —J˜šÏnœžœžÏa˜ Kšžœ7ž˜@Kšžœ˜Iunitšžœžœ˜J˜š Ÿœžœžœ+žœžœžœ žœ,žœ#žœ žœžœžœ žœžœžœžœ˜ÿKšœ ˜#šžœ ž˜šœžœ6˜MJšœV˜Všžœž˜Kšœ žœ!˜1Kšœžœ˜Kšžœ˜—Jšœ žœ˜—šœ˜Jšœ,˜,Jšœ žœ!˜1Kšœ žœ˜—˜ šžœžœ˜Kšžœ7žœ˜Bšžœ˜šœ žœ"˜.Kšœ˜Kšœ8˜8Kšœ˜—Kšœžœ˜ Kšœžœ˜ KšœA˜AKšœ;˜;Kšœ8˜8Kšœžœ˜!Kšœžœ˜(——Jšœ žœ˜—šœžœ*žœ,˜mJšœ ˜ šžœž˜šœ˜Jšœžœžœžœ ˜&šžœ žœ˜Kšžœ5žœ˜@šžœ:˜>Kšœ"˜"—Kšœ˜——šœ˜Kšœ8˜8Kšœ ˜ —Kšžœ*˜1—Kšœ žœ˜—šœ˜Jšœ"˜"šžœ žœ˜Kšžœ(žœ˜3KšžœI˜M—Jšœ˜Jšœ žœ˜—˜ Jšœ%˜%Jšœ#˜#Jšœžœ˜—˜ Kšœ3˜3Jšœ#˜#Jšœ žœ%˜6Jšœ˜Jšœžœ˜Jšœ˜—šœ ˜ Jšœi˜iJšœžœ˜—Kšžœžœ˜—K˜Kšœ ˜ —J˜Jšžœ˜——…— ôÖ