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;