DIRECTORY BasicTime, CD, CDBasics, CDCommandOps, CDInstances, CDSimpleOps, CDOps, CDOrient, CDRects, CDSequencer, TerminalIO; CDBasicCommands: CEDAR PROGRAM IMPORTS BasicTime, CDCommandOps, CDInstances, CDSimpleOps, CDOps, CDSequencer, TerminalIO, CDRects, CDBasics = BEGIN AddARect: PROC[design: CD.Design, r: CD.Rect, l: CD.Layer] = BEGIN ob: CD.Object; sz: CD.Position _ CDBasics.SizeOfRect[r]; orient: CD.Orientation _ CDOrient.original; IF sz.y=start.x-wireWidth AND (stop.ystart.y+wireWidth) THEN { --crazy vertical wire IF ABS[start.y-stop.y]=start.y AND stop.y<=start.y+wireWidth THEN { --horizontal wire stop.y _ start.y+wireWidth; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l] } ELSE { --L shaped (firsthorizontal) IF start.x<=stop.x THEN {stop.x _ stop.x+wireWidth} ELSE {t: CD.Number=stop.x; stop.x _ start.x; start.x _ t}; stop.y _ start.y+wireWidth; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l]; IF firstOnly THEN RETURN; start.x _ comm.pos.x; stop.y _ comm.pos.y; stop.x _ start.x+wireWidth; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l]; } } ELSE { -- NOT firstHorizontalVC -- IF stop.y<=start.y AND stop.y>=start.y-wireWidth AND (stop.xstart.x+wireWidth) THEN { --crazy horizontal wire IF ABS[stop.x-start.x]=start.x AND stop.x<=start.x+wireWidth THEN { --vertical wire stop.x _ start.x+wireWidth; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l] } ELSE { --L shaped (firstVertical) IF start.y<=stop.y THEN {stop.y _ stop.y+wireWidth} ELSE {t: CD.Number = stop.y; stop.y _ start.y; start.y _ t}; stop.x _ start.x+wireWidth; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l]; IF firstOnly THEN RETURN; start.y _ comm.pos.y; stop.y _ start.y+wireWidth; stop.x _ comm.pos.x; AddARect[comm.design, CDBasics.ToRect[start, stop], comm.l]; } } END; DeleteSelected: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Delete selected "]; CDSimpleOps.DeleteSelected[comm.design]; TerminalIO.WriteLn[]; END; Undelete: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Undelete\n"]; CDSimpleOps.Undelete[comm.design] END; AbortCommand: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Try to abort current command\n"]; CDSequencer.AbortTheCommand[comm.design] END; SelectExclusive: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Select pointed"]; CDSimpleOps.DeselectAll[comm.design]; CDSimpleOps.Select[comm.design, comm.pos]; TerminalIO.WriteLn[]; END; ReSelectExclusive: PROC [design: CD.Design, pos: CD.Position, verbose: BOOL_TRUE] RETURNS [done: BOOL_TRUE] = BEGIN Deselect: PROC[a: CD.Instance] = INLINE BEGIN IF a.selected THEN { a.selected _ FALSE; CDCommandOps.RedrawInstance[design, a] } END; DeselectList: PROC[list: CD.InstanceList] = BEGIN FOR w: CD.InstanceList _ list, w.rest WHILE w#NIL DO Deselect[w.first] ENDLOOP END; ap: CD.Instance _ NIL; --any application where pos points to FOR w: CD.InstanceList _ CDOps.InstList[design], w.rest WHILE w#NIL DO IF CDInstances.PointToI[pos, w.first] THEN { IF w.first.selected THEN { DeselectList[w.rest]; CDOps.ReOrderInstance[design, w.first]; IF verbose THEN CDCommandOps.WriteInfo[w.first]; RETURN } ELSE IF ap=NIL THEN ap _ w.first } ELSE Deselect[w.first] ENDLOOP; IF ap#NIL THEN { ap.selected _ TRUE; CDOps.ReOrderInstance[design, ap]; CDCommandOps.RedrawInstance[design, ap, FALSE]; IF verbose THEN CDCommandOps.WriteInfo[ap] } ELSE { done _ FALSE; IF verbose THEN TerminalIO.WriteRope[" (no object)"]; } END; RectDist: PROC[pos: CD.Position, r: CD.Rect] RETURNS [CD.Number] = BEGIN RETURN [MAX[ (IF pos.xr.x2 THEN (pos.x-r.x2) ELSE 0), (IF pos.yr.y2 THEN (pos.y-r.y2) ELSE 0) ]] END; CloseReSelectExclusive: PROC [design: CD.Design, pos: CD.Position, verbose: BOOL_TRUE, dist: CD.Number_100] = BEGIN IF ~ReSelectExclusive[design, pos, verbose] THEN { ap: CD.Instance _ NIL; FOR w: CD.InstanceList _ CDOps.InstList[design], w.rest WHILE w#NIL DO d: CD.Number = RectDist[pos, CDInstances.InstRectI[w.first]]; IF dšžœ˜K˜1KšœI˜IK˜—Kšžœ˜—K˜šŸœžœ˜9Kšž˜K˜5KšœJžœ˜OKšžœ˜—K˜šŸœžœ˜2Kšž˜K˜'Kšœ%˜%KšœI˜IKšžœ˜—K˜šŸ œžœ˜-Kšœ™Kšž˜K˜#Kšžœžœ,˜FKšžœM˜QKšœ˜Kšžœ˜—K˜šŸ œžœ˜0Kšž˜K˜)KšœK˜KKšžœ˜—K˜šŸœžœ˜8Kšž˜K˜-KšœLžœ˜QKšžœ˜—K˜J˜J˜JšœF˜FJ˜1Jšœ1˜1J˜:J˜7J˜/KšœF˜FKšœN˜NKšœO˜OKšœB˜BK˜KšœJ˜JKšœE˜EKšœ@˜@Kšœ>˜>KšœH˜HKšœN˜NK˜KšœF˜FKšœV˜VKšœH˜HKšœN˜NK˜KšœD˜DKšœT˜TKšœ>˜>Jšžœ˜—…—.’@Φ