SEXCommandsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reversed.
Louis Monier November 1, 1985 2:23:06 pm PST
DIRECTORY
CD, CDCells, CDCommandOps, CDMenus, CDOps, CDProperties, CDSequencer, CDTexts, CoreOps, Rope, SEX, TerminalIO;
SEXCommandsImpl: CEDAR PROGRAM
IMPORTS CDCells, CDCommandOps, CDMenus, CDOps, CDProperties, CDSequencer, CoreOps, Rope, SEX, TerminalIO
= BEGIN OPEN SEX;
Properties
iconNameProp: PUBLIC ATOM = $IconNameProp; -- name of CD.Object or StructureProc
forContextProp: PUBLIC ATOM = $ForContextProp; -- list of props for context
cacheNameProp: PUBLIC ATOM = $CacheNameProp; -- entry in cellType cache
satellitesProp: PUBLIC ATOM = $SatellitesProp;  -- list of instances (text) or props (pairs)
isSatelliteOfProp: PUBLIC ATOM = $IsSatelliteOfProp; -- CD.Instance (master)
sinixSchKey: PUBLIC ATOM = $SinixSch;  -- used for avoiding double reg. error
Commands
-- Prompt for a rope and set the property iconNameProp on the instance;
-- Also put as property a special extraction procedure IconExtractObj
AssociateIconCommand: PROC [comm: CDSequencer.Command] =
BEGIN
name: ROPE;
inst: CD.Instance ← CDCommandOps.TheInstance[comm, "Circuit Extractor"];
IF inst=NIL THEN RETURN;
IF ~CDCells.IsCell[inst.ob] THEN {TerminalIO.WriteRope["Should be a cell\n"]; RETURN};
name ← TerminalIO.RequestRope["Is Iconic Cell for: "];
IF Rope.Equal[name, NIL] THEN {TerminalIO.WriteRope["Ignored\n"]}
ELSE {
CDProperties.PutPropOnObject[inst.ob, iconNameProp, name];
CDProperties.PutPropOnObject[inst.ob, extractObjProcProp, NEW[ExtractObjProc ← IconExtractObj]];
TerminalIO.WriteRopes["The cell '", NARROW[inst.ob.specificRef, CD.CellPtr].name, "' is iconic for '"];
TerminalIO.WriteRopes[name, "'\n"];
};
END;
-- Given several (at least two) selected instances, all text but one, it binds them in a group
BindSatellitesCommand: PROC [comm: CDSequencer.Command] =
BEGIN
master: CD.Instance ← NIL; sats: CD.InstanceList ← NIL; multiple: BOOLFALSE;
IF ~CDOps.SelectedInstance[comm.design].multiple THEN {TerminalIO.WriteRope["not done\n"]; RETURN};
-- find the master
FOR list: CD.InstanceList ← CDOps.InstList[comm.design], list.rest WHILE list#NIL DO
IF list.first.selected THEN {
WITH list.first.ob.specificRef SELECT FROM
t: CDTexts.TextPtr => {sats ← CONS[list.first, sats];};
ENDCASE => {
IF ~multiple THEN {master ← list.first; multiple ← TRUE;}
ELSE {TerminalIO.WriteRope["not done\n"]; RETURN};
};
};
ENDLOOP;
-- on master: list of instances (text)
CDProperties.PutPropOnInstance[master, satellitesProp, sats];
-- on satallites: master
FOR list: CD.InstanceList ← sats, list.rest WHILE list#NIL DO
CDProperties.PutPropOnInstance[list.first, isSatelliteOfProp, master];
ENDLOOP;
END;
-- Given one selected instance, it selets all the members of the group
SelectGroupCommand: PROC [comm: CDSequencer.Command] =
BEGIN
multiple: BOOL; ref: REF;
sel, master: CD.Instance;
sats: CD.InstanceList;
[sel, multiple] ← CDOps.SelectedInstance[comm.design];
IF multiple THEN {TerminalIO.WriteRope["multiple selected\n"]; RETURN};
IF ISTYPE[sel.ob.specificRef, CDTexts.TextPtr] THEN-- up to the master
master ← NARROW[CDProperties.GetPropFromInstance[sel, isSatelliteOfProp]]
ELSE master ← sel;
ref ← CDProperties.GetPropFromInstance[master, satellitesProp];
IF ref=NIL THEN {TerminalIO.WriteRope["not done\n"]; RETURN};
sats ← NARROW[ref];
-- display master and all satellites selected
master.selected ← TRUE;
CDCommandOps.RedrawInstance[comm.design, master];
FOR list: CD.InstanceList ← sats, list.rest WHILE list#NIL DO
list.first.selected ← TRUE;
CDCommandOps.RedrawInstance[comm.design, list.first];
ENDLOOP;
END;
ExtractCommand: PROC [comm: CDSequencer.Command] =
BEGIN
inst: CD.Instance ← CDOps.SelectedInstance[comm.design].first;
context: Context;
cellType: CellType ← ExtractInst[inst, context].cellType;
CoreOps.PrintCellType[cellType, TerminalIO.TOS[]];
-- The extracted cellType is put as a property of the instance.
END;
Initialization
[] ← CDProperties.RegisterProperty[iconNameProp, sexKey];
[] ← CDProperties.RegisterProperty[forContextProp, sexKey];
[] ← CDProperties.RegisterProperty[cacheNameProp, sexKey];
[] ← CDProperties.RegisterProperty[satellitesProp, sexKey];
[] ← CDProperties.RegisterProperty[isSatelliteOfProp, sexKey];
[] ← CDProperties.RegisterProperty[$AssociateIcon, sexKey];
[] ← CDProperties.RegisterProperty[$BindSatellites, sexKey];
[] ← CDProperties.RegisterProperty[$SelectGroup, sexKey];
[] ← CDProperties.RegisterProperty[$Extract, sexKey];
CDSequencer.ImplementCommand[
a: $AssociateIcon, p: AssociateIconCommand, queue: doQueue];
CDSequencer.ImplementCommand[
a: $BindSatellites, p: BindSatellitesCommand, queue: doQueue];
CDSequencer.ImplementCommand[
a: $SelectGroup, p: SelectGroupCommand, queue: doQueue];
CDSequencer.ImplementCommand[a: $Extract, p: ExtractCommand, queue: doQueue];
CDMenus.CreateEntry[
menu: $ProgramMenu, entry: "Associate Icon", key: $AssociateIcon];
CDMenus.CreateEntry[
menu: $ProgramMenu, entry: "Bind Satellites", key: $BindSatellites];
CDMenus.CreateEntry[
menu: $ProgramMenu, entry: "Select Group", key: $SelectGroup];
CDMenus.CreateEntry[menu: $ProgramMenu, entry: "Schematics Extraction", key: $Extract];
END.