--File: IPMVStackOpsImpl.mesa
Last Edited by: CSChow, January 12, 1985 10:25:12 am PST
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: BOOLFALSE, refreshFlag: BOOLTRUE] ={
prevTrack ← oldPrevTrack; --default
SELECT command FROM
$Undo =>{noOfSteps: NATTIO.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: INTTIO.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: NATTIO.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.