<> <> <> <<>> 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; <> 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 <> <<-- 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]; <> 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: BOOL _ FALSE; 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; <> [] _ 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.