DIRECTORY TerminalIO, CD, CDDirectory, CDCells, CDSequencer, CDOps, CDCommandOps, CDBasics, CDMenus USING [CreateEntry], CDMarks, Rope; CDPushByNameCommands: CEDAR PROGRAM IMPORTS TerminalIO, CD, CDCells, CDDirectory, CDMarks, CDMenus, CDSequencer, CDOps, CDCommandOps = BEGIN foundAndStop: SIGNAL = CODE; stopFlag: REF BOOLEAN = NEW[BOOLEAN]; iDidIt: BOOL; gMark: CDMarks.MarkRange; cell: CD.Object; drawStack: CD.InstanceList; MyDrawChild: CD.DrawProc = BEGIN IF inst.ob=cell THEN { drawStack _ CONS[inst, drawStack]; iDidIt _ TRUE; SIGNAL foundAndStop }; WITH inst.ob.specificRef SELECT FROM cp: CD.CellPtr => { IF inst.ob.marked#gMark THEN { inst.ob.marked _ gMark; drawStack _ CONS[inst, drawStack]; inst.ob.class.drawMe[inst: inst, pos: inst.location, orient: inst.orientation, pr: pr]; drawStack _ drawStack.rest; }; }; ENDCASE => NULL; END; ProtectedPushNamedCellComm: PROCEDURE [comm: CDSequencer.Command] = BEGIN pushStack: CD.InstanceList _ NIL; --will be draw stack in reversed order name: Rope.ROPE; design: CD.Design _ comm.design; myDrawRef: CD.DrawRef; DoWithMark: PROC [mark: CDMarks.MarkRange] = BEGIN gMark _ mark; design.actual.first.dummyCell.ob.class.drawMe[inst: design.actual.first.dummyCell, pos: [0, 0], orient: CD.original, pr: myDrawRef ! foundAndStop => CONTINUE]; END; drawStack _ NIL; iDidIt _ FALSE; name _ TerminalIO.RequestRope["cell name >"]; cell _ CDDirectory.Fetch[design, name].object; IF cell=NIL THEN { TerminalIO.WriteRope["design, does not have this cell\n"]; RETURN }; IF ~ISTYPE[cell.specificRef, CD.CellPtr] THEN { TerminalIO.WriteRope["object is not a cell\n"]; RETURN }; FOR pl: LIST OF CD.PushRec _ design.actual, pl.rest WHILE pl#NIL DO IF pl.first.mightReplace#NIL AND pl.first.mightReplace.ob=cell THEN { TerminalIO.WriteRope["design is already pushed in\n"]; RETURN } ENDLOOP; myDrawRef _ CD.CreateDrawRef[[ design: design, interestClip: CDBasics.universe, drawChild: MyDrawChild ]]; CDMarks.DoWithMark[comm.design, DoWithMark ! CDMarks.MarkOccupied => GOTO markError]; IF ~iDidIt THEN { TerminalIO.WriteRope["sorry, cell not found in accessible position\n"]; RETURN }; WHILE drawStack#NIL DO pushStack _ CONS[drawStack.first, pushStack]; drawStack _ drawStack.rest ENDLOOP; WHILE pushStack#NIL DO inst: CD.Instance _ NIL; FOR il: CD.InstanceList _ CDOps.InstList[design], il.rest WHILE il#NIL DO IF il.first.ob=pushStack.first.ob THEN { inst _ il.first; EXIT }; REPEAT FINISHED => { TerminalIO.WriteRope["finding cell failed\n"]; RETURN } ENDLOOP; IF ~CDCells.PushInCellInstance[design, inst] THEN { TerminalIO.WriteRope["push failed\n"]; RETURN }; pushStack _ pushStack.rest ENDLOOP; CDSequencer.ExecuteCommand[$ResetScaleTop, design, dontQueue, comm]; TerminalIO.WriteRope["done\n"]; myDrawRef _ NIL; pushStack _ drawStack _ NIL; EXITS markError => { TerminalIO.WriteRope["**inconsistent use of mark\n"]; } END; PushNamedCellComm: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Push into cell by name\n"]; [] _ CDCommandOps.CallWithResource[ProtectedPushNamedCellComm, comm, $myDrawRef, stopFlag]; END; CDMenus.CreateEntry[menu: $CellMenu, entry: "push named", key: $PushNamedCell]; CDSequencer.ImplementCommand[$PushNamedCell, PushNamedCellComm,, doQueue]; END. ϊCDPushByNameCommands.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. by: Ch. Jacobi, February 16, 1985 6:55:29 pm PST Last Edited by: Ch. Jacobi, March 13, 1986 4:30:35 pm PST --the global variables mare monitored using CDCommandOps.CallWithResource; --these variables are global so they can b used by MyDrawChild --PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: REF CD.DrawInformation] --draw only from pushed in cell point in hierarchy --get name, find if cell really exists --if we are already pushed in, it would not harm the program, --but it is checked because it would confuse the designer --check if a path to the cell exists, and build the path --there is a path --make pushStack in push order; (reverse order as drawStack) --do the pushes --select exclusively the application we want to push in --pushing in makes a copy of the application list! check for the right object --we are successully pushed in --position the viewer --help the garbage collector Κ+˜code™Kšœ Οmœ1™™>K˜Kš œ žœžœžœžœ˜%Kšœžœ˜ Kšœ˜Kšœ˜Kšœ žœ˜K˜šΟb œžœ ˜Kšœa™aKšž˜šžœžœ˜Kšœ žœ˜"Kšœžœ˜Kšžœ ˜K˜—šžœžœž˜$šœžœ ˜šžœžœ˜Kšœ˜Kšœ žœ˜"KšœX˜XKšœ˜Kšœ˜—K˜—Kšžœžœ˜—Kšžœ˜—K˜šΟnœž œ˜DKšž˜Kšœ žœžœΟc&˜HKšœ žœ˜Kšœžœ˜ Kšœ žœ ˜K™š‘ œžœ˜,Kšž˜Kšœ ˜ Kšœ2™2Kšœhžœ+žœ˜ŸKšžœ˜—K˜šœ&™&Kšœ žœ˜Kšœ žœ˜Kšœ-˜-Kšœ.˜.šžœžœžœ˜Kšœ:˜:Kšž˜K˜—šžœžœžœ žœ˜/Kšœ/˜/Kšž˜K˜—Kš’>™>Kšœ’7™9š žœžœžœžœ"žœžœž˜Cšžœžœžœžœ˜EKšœ6˜6Kšž˜K˜—Kšžœ˜——šœ9™9šœ žœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜—KšœEžœ ˜Ušžœ žœ˜KšœG˜GKšž˜K˜——Kš’™šœ<™<šžœ žœž˜Kšœ žœ˜-Kšœ˜Kšžœ˜——šœ™šžœ žœž˜Kšœ7™7™MK˜š žœžœ0žœžœž˜Išžœ žœ˜(Kšœ˜Kšž˜K˜—šžœžœ˜Kšœ.˜.Kšž˜K˜—Kšžœ˜——šžœ+žœ˜3Kšœ&˜&Kšž˜K˜—Kšœ˜Kšžœ˜——Kšœ™šœ™KšœD˜DKšœ˜—šœ™Kšœ žœ˜Kšœžœ˜—šž˜šœ˜Kšœ5˜5K˜——Kšžœ˜—K™š‘œžœ˜5Kšžœ˜Kšœ2˜2Kšœ[˜[Kšžœ˜K˜—KšœO˜OKšœJ˜JKšžœ˜K˜—…— ΄Ω