CDExtraCommands.mesa (part of Chipndale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi July 11, 1983 3:42 pm
last edited Christian Jacobi February 14, 1984 4:05 pm
DIRECTORY
Atom,
CD,
CDBasics,
CDCallSpecific,
CDCommandOps,
CDExtras,
CDSequencer,
CDOrient,
CDOps,
CDPanel,
CDProperties,
CDViewer USING [DesignOf],
Rope,
TerminalIO,
ViewerClasses USING [Viewer];
CDExtraCommands:
CEDAR
PROGRAM
IMPORTS Atom, CD, CDCommandOps, CDBasics, CDOps, CDOrient, CDPanel, CDProperties, CDSequencer, TerminalIO, CDCallSpecific, CDExtras, CDViewer, Rope =
BEGIN
verbose: BOOL ← TRUE;
WriteInLambda:
PROC [n:
CD.Number] = {TerminalIO.WriteRope[CDExtras.ToLambda[n]]};
CoordinatesCommand:
PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Coordinates"];
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;
WriteInfo:
PROC[aptr:
CD.ApplicationPtr] =
-- copied from CDOps
BEGIN
x: REF ~ CDProperties.GetPropFromApplication[aptr, $SignalName];
TerminalIO.WriteRope[" ("];
TerminalIO.WriteRope[CDOps.Info[aptr.ob]];
IF x#
NIL
THEN
WITH x
SELECT
FROM
r: Rope.ROPE => TerminalIO.WriteRope[Rope.Concat[" ", r]];
a: ATOM => TerminalIO.WriteRope[Rope.Concat[" ", Atom.GetPName[a]]];
ENDCASE => NULL;
TerminalIO.WriteRope[")"];
END;
PersonalizedApplicationRect:
PROC [aptr:
CD.ApplicationPtr]
RETURNS [
CD.DesignRect] =
--should be in CDApplications
INLINE BEGIN
RETURN [
CDOrient.MapRect[
itemInCell: aptr.ob.p.insideRect[aptr.ob],
cellSize: aptr.ob.size,
cellInstOrient: aptr.orientation,
cellInstPos: aptr.location
]
]
END;
StatisticCommand:
PROC [comm: CDSequencer.Command] =
BEGIN
countTot: INT ← 0;
countSel: INT ← 0;
countInvis: INT ← 0;
isDesign: BOOL ← FALSE;
rect: CD.DesignRect;
aptr: CD.ApplicationPtr;
TerminalIO.WriteRope["Statistic"];
IF
ISTYPE[comm.ref, ViewerClasses.Viewer]
THEN
[isDesign, , rect] ← CDViewer.DesignOf[NARROW[comm.ref]];
IF ~isDesign 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, PersonalizedApplicationRect[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"];
IF countSel=1
THEN {
WriteInfo[aptr];
IF verbose
THEN {
TerminalIO.WriteRope[" at: ("];
TerminalIO.WriteInt[aptr.location.x];
TerminalIO.WriteRope[","];
TerminalIO.WriteInt[aptr.location.y];
TerminalIO.WriteRope[") size: ("];
TerminalIO.WriteInt[aptr.ob.size.x];
TerminalIO.WriteRope[","];
TerminalIO.WriteInt[aptr.ob.size.y];
TerminalIO.WriteRope[") orientation-code:"];
TerminalIO.WriteInt[aptr.orientation];
}
};
IF countInvis#0
THEN {
TerminalIO.WriteRope["\n **** "]; TerminalIO.WriteInt[countInvis];
TerminalIO.WriteRope[" invisible selected objects"];
};
TerminalIO.WriteLn[];
END;
SelectIfLevel: CDCallSpecific.CallProc =
BEGIN
IF aptr.ob.level#NARROW[x, REF CD.Level]^ THEN {done←FALSE; RETURN};
IF aptr.selected THEN RETURN;
aptr.selected ← TRUE;
repaintMe ← TRUE
END;
AddSelectLevel:
PROC [comm: CDSequencer.Command] =
BEGIN
n: INT;
reflev: REF CD.Level ← NEW[CD.LevelPanel.FetchDefaultLevel[comm.design]];
TerminalIO.WriteRope["Select all of current layer: ("];
n ← CDCallSpecific.CallForAll[design: comm.design, whatElse: SelectIfLevel, 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;
AlterPointed:
PROC [comm: CDSequencer.Command] =
BEGIN
code: ATOM;
x: REF;
n: CARDINAL;
TerminalIO.WriteRope["alter pointed: "];
[code, x] ← SpecifyAlter[];
n ← CDCallSpecific.CallForPointed[design: comm.design, point: comm.pos, objectSpecific: code, x: x];
TerminalIO.WriteInt[n]; TerminalIO.WriteRope[" objects altered\n"];
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;
LevelName:
PROC [lev:
CD.Level]
RETURNS [Rope.
ROPE] =
BEGIN
RETURN[Atom.GetPName[CD.LevelKey[lev]]];
END;
SetLayerCommand:
PROC [comm: CDSequencer.Command] =
BEGIN
app: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Set default layer"];
IF app#
NIL
THEN {
layer: CD.Level = app.ob.level;
IF app.ob.p.wireTyped
AND CDProperties.GetPropFromLevel[layer, $DontUse]=
NIL
THEN {
TerminalIO.WriteRope[Rope.Cat[" ", LevelName[layer], "\n"]];
CDPanel.StoreDefaultLevel[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[$AddSelectLevel, AddSelectLevel,, doQueue];
CDSequencer.ImplementCommand[$Coordinates, CoordinatesCommand,, doQueue];
CDSequencer.ImplementCommand[$Statistic, StatisticCommand,, doQueue];
CDSequencer.ImplementCommand[$AlterP, AlterPointed];
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.