CDExtraCommands.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, July 11, 1983 3:42 pm
last edited Christian Jacobi, May 9, 1985 10:56:36 am PDT
DIRECTORY
CD,
CDApplications,
CDBasics,
CDCallSpecific,
CDCommandOps,
CDExtras,
CDSequencer,
CDOps,
CDPanel,
CDProperties,
CDValue,
CDViewer,
Rope,
TerminalIO,
ViewerClasses USING [Viewer];
CDExtraCommands: CEDAR PROGRAM
IMPORTS CDApplications, CDCommandOps, CDBasics, CDOps, CDPanel, CDProperties, CDSequencer, CDValue, TerminalIO, CDCallSpecific, CDExtras, CDViewer, Rope =
BEGIN
verbosity: INT ← 1;
WriteInLambda: PROC [n: CD.Number] =
BEGIN
TerminalIO.WriteRope[CDExtras.ToLambda[n]]
END;
CoordinatesCommand: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Coordinates [\024]"]; -- \024 prints as greek lambda
TerminalIO.WriteRope[" down: ("];
WriteInLambda[comm.sPos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.sPos.y];
TerminalIO.WriteRope[") up: ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[") dist: ("];
WriteInLambda[comm.pos.x-comm.sPos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y-comm.sPos.y];
TerminalIO.WriteRope[")\n"];
END;
SetArrow: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["set arrow at ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[")\024\n"];
CDViewer.ShowArrow[comm.design, comm.pos];
END;
RemoveArrow: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["remove arrow\n"];
CDViewer.RemoveArrow[comm.design];
END;
ArrowInformation: PROC [comm: CDSequencer.Command] =
BEGIN
WITH CDValue.Fetch[comm.design, $arrow, design] SELECT FROM
p: REF CD.DesignPosition => {
TerminalIO.WriteRope[" arrow at: ("];
WriteInLambda[p.x];
TerminalIO.WriteRope[","];
WriteInLambda[p.y];
TerminalIO.WriteRope[") up: ("];
WriteInLambda[comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[comm.pos.y];
TerminalIO.WriteRope[") dist: ("];
WriteInLambda[p.x-comm.pos.x];
TerminalIO.WriteRope[","];
WriteInLambda[p.y-comm.pos.y];
TerminalIO.WriteRope[")\n"];
}
ENDCASE => NULL;
END;
StatisticCommand: PROC [comm: CDSequencer.Command] =
BEGIN
countTot: INT ← 0;
countSel: INT ← 0;
countInvis: INT ← 0;
isDesign: BOOL FALSE;
rect: CD.DesignRect ← CDBasics.universe;
v: ViewerClasses.Viewer ← CDViewer.GetViewer[comm];
aptr: CD.ApplicationPtr;
TerminalIO.WriteRope["statistic"];
IF v#NIL THEN rect ← CDViewer.VisibleRect[v];
IF ~CDBasics.NonEmpty[rect] THEN rect ← CDBasics.universe;
FOR l: CD.ApplicationList ← CDOps.AppList[comm.design], l.rest WHILE l#NIL DO
countTot ← countTot+1;
IF l.first.selected THEN {
IF ~CDBasics.Intersect[rect, CDApplications.ARectI[l.first]] THEN countInvis ← countInvis+1;
countSel ← countSel+1;
aptr ← l.first
}
ENDLOOP;
TerminalIO.WriteInt[countTot]; TerminalIO.WriteRope[" objects;"];
TerminalIO.WriteInt[countSel]; TerminalIO.WriteRope[" selected"];
TerminalIO.WriteLn[];
IF countSel=1 THEN {
CDCommandOps.WriteInfo[aptr, verbosity];
IF verbosity>0 THEN {
TerminalIO.WriteRope[" at: ("];
WriteInLambda[aptr.location.x];
TerminalIO.WriteRope[","];
WriteInLambda[aptr.location.y];
TerminalIO.WriteRope[")\024 size: ("]; --\024 prints as greek lambda
WriteInLambda[aptr.ob.size.x];
TerminalIO.WriteRope[","];
WriteInLambda[aptr.ob.size.y];
TerminalIO.WriteRope[")\024 orientation-code:"]; --\024 prints as greek lambda
TerminalIO.WriteInt[aptr.orientation];
};
TerminalIO.WriteLn[];
};
ArrowInformation[comm];
IF countInvis#0 THEN {
TerminalIO.WriteRope[" **** "]; TerminalIO.WriteInt[countInvis];
TerminalIO.WriteRope[" invisible selected object(s)"];
TerminalIO.WriteLn[];
};
END;
SelectIfLayer: CDCallSpecific.CallProc =
BEGIN
IF aptr.ob.layer#NARROW[x, REF CD.Layer]^ THEN {done←FALSE; RETURN};
IF aptr.selected THEN RETURN;
aptr.selected ← TRUE;
repaintMe ← TRUE
END;
AddSelectLayer: PROC [comm: CDSequencer.Command] =
BEGIN
n: INT;
reflev: REF CD.Layer ← NEW[CD.Layer�Panel.FetchDefaultLayer[comm.design]];
TerminalIO.WriteRope["select all of current layer: ("];
n ← CDCallSpecific.CallForAll[design: comm.design, whatElse: SelectIfLayer, x: reflev];
TerminalIO.WriteInt[n];
TerminalIO.WriteRope[") objects\n"];
END;
SpecifyAlter: PROC [] RETURNS [code: ATOM←NIL, x: REF←NIL] =
BEGIN
step: CD.DesignNumber = CD.lambda;
SELECT TerminalIO.RequestSelection["alter", LIST["dec w", "dec l", "inc w", "inc l", "dec par", "inc par"]] FROM
1 => {code ← $ChangeExt; x ← NEW[CD.DesignPosition←[-step, 0]]};
2 => {code ← $ChangeExt; x ← NEW[CD.DesignPosition←[0, -step]]};
3 => {code ← $ChangeExt; x ← NEW[CD.DesignPosition←[step, 0]]};
4 => {code ← $ChangeExt; x ← NEW[CD.DesignPosition←[0, step]]};
5 => {code ← $ChangeParam; x ← NEW[CD.DesignNumber←-step]};
6 => {code ← $ChangeParam; x ← NEW[CD.DesignNumber←step]};
ENDCASE => {code ← NIL}
END;
AlterSelected: PROC [comm: CDSequencer.Command] =
BEGIN
code: ATOM;
x: REF;
n: CARDINAL;
TerminalIO.WriteRope["alter selected: "];
[code, x] ← SpecifyAlter[];
n ← CDCallSpecific.CallForSelected[design: comm.design, objectSpecific: code, x: x];
TerminalIO.WriteInt[n]; TerminalIO.WriteRope[" objects altered\n"];
END;
SetLayerCommand: PROC [comm: CDSequencer.Command] =
BEGIN
app: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Set default layer"];
IF app#NIL THEN {
layer: CD.Layer = app.ob.layer;
IF app.ob.p.wireTyped AND CDProperties.GetPropFromLayer[layer, $DontUse]=NIL THEN {
TerminalIO.WriteRope[Rope.Cat[" ", CDOps.LayerName[layer], "\n"]];
CDPanel.StoreDefaultLayer[comm.design, layer];
}
ELSE TerminalIO.WriteRope[" NOT DONE\n"];
CDOps.ReOrderApplication[comm.design, app]
}
END;
EnforcePanel: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["enforce a control panel\n"];
[] ← CDPanel.CreatePanel[comm.design]
END;
CDSequencer.ImplementCommand[$SetLayerP, SetLayerCommand,, doQueue];
CDSequencer.ImplementCommand[$AddSelectLayer, AddSelectLayer,, doQueue];
CDSequencer.ImplementCommand[$Coordinates, CoordinatesCommand,, doQueue];
CDSequencer.ImplementCommand[$Statistic, StatisticCommand,, doQueue];
CDSequencer.ImplementCommand[$SetArrow, SetArrow,, doQueue];
CDSequencer.ImplementCommand[$RemoveArrow, RemoveArrow,, doQueue];
CDSequencer.ImplementCommand[$AlterS, AlterSelected];
CDSequencer.ImplementCommand[$EnforcePanel, EnforcePanel,, doQueue];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Expand, useFor: "SPFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Widen", useFor: "SPFXA", x: NEW[CD.DesignPosition←[CD.lambda, 0]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Narrow", useFor: "SPFXA", x: NEW[CD.DesignPosition←[-CD.lambda, 0]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Shorten", useFor: "SPFXA", x: NEW[CD.DesignPosition←[0, -CD.lambda]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Lengthen, tipBase: "Lengthen", useFor: "SPFXA", x: NEW[CD.DesignPosition←[0, CD.lambda]]];
CDCommandOps.ImplementSpecificCommand[specificAtom: $Default, useFor: "SPFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $IncCount, text: "Inc count", useFor: "SPFXA"];
CDCommandOps.ImplementSpecificCommand[specificAtom: $DecCount, text: "Dec count", useFor: "SPFXA"];
END.