CDConditionsCommands.mesa (part of Chipndale)
by Christian Jacobi July 11, 1983 3:42 pm
last edited Christian Jacobi November 2, 1983 4:06 pm
DIRECTORY
CD,
CDCommandOps,
CDConditions,
CDOps,
CDOrient,
CDProperties,
CDSequencer,
Rope,
TerminalIO;
CDConditionsCommands:
CEDAR
PROGRAM
IMPORTS CDCommandOps, CDConditions, CDProperties, CDSequencer, CDOps, TerminalIO =
BEGIN
ChangeCondition:
PROC [comm: CDSequencer.Command] =
BEGIN
fileName, procedureText: Rope.ROPE;
ob: CD.ObPtr;
first: CD.ApplicationPtr;
multiple: BOOL;
TerminalIO.WriteRope["make object conditional\n"];
[first, multiple] ← CDOps.SelectedApplication[comm.design];
IF first=NIL THEN {TerminalIO.WriteRope[" no selected object\n"]; RETURN};
IF multiple
THEN {
TerminalIO.WriteRope[" multiple selection; not done for now\n"]; RETURN;
--[done: multiple, cellOb: ob] ← CDCells.CreateCellSelected[comm.design, "-dummy"];
--IF NOT multiple THEN {TerminalIO.WriteRope["not done\n"]; RETURN};
};
IF
ISTYPE[first.ob.specificRef, CDConditions.CondPtr]
THEN {
cp: CDConditions.CondPtr ← NARROW[first.ob.specificRef];
ob ← first.ob;
TerminalIO.WriteRope[" object already conditional: ["];
TerminalIO.WriteRope[cp.procName];
TerminalIO.WriteRope["] on "];
TerminalIO.WriteRope[cp.fileName];
TerminalIO.WriteRope[" you may change procedure or abort\n"];
}
ELSE {
ob ← CDConditions.CreateCondition[design: comm.design, ob: first.ob, condition: NIL, data: NIL];
IF ob=
NIL
THEN {
TerminalIO.WriteRope[" not done\n"];
RETURN
};
first.ob ← ob;
TerminalIO.WriteRope[" object made conditional; now input procedure\n"];
};
fileName ← TerminalIO.RequestRope[" filename > "];
procedureText ← TerminalIO.RequestRope[" (module.)procedure > "];
IF CDConditions.ChangeCondition[design: comm.design, ob: ob, procName: procedureText, fileName: fileName, data: NIL] THEN TerminalIO.WriteRope[" done\n"]
ELSE TerminalIO.WriteRope[" procedure not found, but object is conditional\n"]
END;
CheckConditions:
PROC [comm: CDSequencer.Command] =
BEGIN
all, done: BOOL ← FALSE;
TerminalIO.WriteRope["check conditional objects\n"];
IF comm.a=$CheckAllConditions THEN all ← TRUE
ELSE IF comm.a=$CheckUnloadedConditions THEN all ← FALSE
ELSE all ← TerminalIO.RequestSelection[
label: "load conditional code",
choice: LIST["all", "unloaded only"]]=1;
IF all THEN TerminalIO.WriteRope[" reload all conditionals\n"]
ELSE TerminalIO.WriteRope[" load unloaded conditionals\n"];
done ← CDConditions.UpdateConditions[comm.design, all];
IF done
THEN {
TerminalIO.WriteRope[" successfull; but:"] ;
TerminalIO.WriteRope[" Warning: Imported designs are not checked; a reloading of conditionals can be forced by re-importing the designs\n"] ;
}
ELSE TerminalIO.WriteRope[" not successfull\n"];
END;
UndoCondition:
PROC [comm: CDSequencer.Command] =
BEGIN
app: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "remove condition"];
IF app#
NIL
THEN
IF ~
ISTYPE[app.ob.specificRef, CDConditions.CondPtr]
THEN
TerminalIO.WriteRope["selected ob not a condition"]
ELSE {
cp: CDConditions.CondPtr = NARROW[app.ob.specificRef];
app.ob ← cp.app.ob;
TerminalIO.WriteRope[" done\n"]
};
END;
PropagationMenuSP:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr:
CD.ApplicationPtr = CDCommandOps.TheApplication[comm,
"propagation of conditional procedures input"];
IF aptr#
NIL
THEN {
TerminalIO.WriteRope[" trough "];
CDCommandOps.WriteInfo[aptr];
IF ~aptr.ob.p.inDirectory THEN TerminalIO.WriteRope[" has no children; command not possible\n"]
ELSE
IF ~
ISTYPE[aptr.ob.specificRef,
CD.CellPtr]
THEN {
TerminalIO.WriteRope[" is not cell; propagates unconditional; command not possible\n"]
}
ELSE {
IF CDProperties.GetPropFromObject[aptr.ob, $CDxPropagate]#$CDxPropagate
THEN
TerminalIO.WriteRope[" (now stops propagation)\n"]
ELSE TerminalIO.WriteRope[" (now lets propagation trough)\n"];
SELECT TerminalIO.RequestSelection[
label: "propagation",
choice: LIST["stop", "continue trough"]
]
FROM
1 => {
CDProperties.PutPropOnObject[onto: aptr.ob, prop: $CDxPropagate, val: NIL];
TerminalIO.WriteRope[" propagation will stop\n"];
CDOps.DelayedRedraw[comm.design];
};
2 => {
CDProperties.PutPropOnObject[onto: aptr.ob, prop: $CDxPropagate, val: $CDxPropagate];
TerminalIO.WriteRope[" propagation will continue trough\n"];
CDOps.DelayedRedraw[comm.design];
};
ENDCASE => TerminalIO.WriteRope["skipped\n"];
};
}
END;
CDSequencer.ImplementCommand[$CheckConditions, CheckConditions];
CDSequencer.ImplementCommand[$CheckUnloadedConditions, CheckConditions];
CDSequencer.ImplementCommand[$CheckAllConditions, CheckConditions];
CDSequencer.ImplementCommand[$DrawConditionS, ChangeCondition];
CDSequencer.ImplementCommand[$RemoveConditionS, UndoCondition];
CDSequencer.ImplementCommand[$CPropagationMenuS, PropagationMenuSP];
END.