DIRECTORY Atom, Buttons, Graphs, GraphBrowsers, HierarchicalDisplays, IO, List, Menus, MessageWindow, OrderedSymbolTableRef, Rope, Rosemary, RoseConditions, RoseDisplayInsides, Trees, VFonts, ViewerClasses, ViewerOps, ViewerTools, ViewRec; RoseDisplayBrowsing: PROGRAM IMPORTS Atom, GraphBrowsers, HD: HierarchicalDisplays, List, OrderedSymbolTableRef, MessageWindow, Rope, Rosemary, RoseDisplayInsides, VF:VFonts, VO: ViewerOps, VR: ViewRec EXPORTS RoseDisplayInsides = BEGIN OPEN RoseDisplayInsides; nodeDisplaysProp: PUBLIC ATOM _ Atom.Gensym[]; cellStateDisplayProp: PUBLIC ATOM _ Atom.Gensym[]; cellStateClass: PUBLIC HD.ChildClass _ NEW [HD.ChildClassRep _ [ buttonProc: CellStateButtonProc, NotifyOnRemove: NoticeCellStateRemoval]]; roseType: Graphs.NodeType _ NEW [Graphs.NodeTypeRep _ [ Expand: RoseExpand, NameNeighbors: NIL, GetNamedNeighbor: NIL, GetIndexedNeighbor: NIL, GetNeighborCount: RoseNeighborCount, View: NIL]]; rosemaryBrowser: GraphBrowsers.BrowserClass _ NEW [GraphBrowsers.BrowserClassRep _ [ cmds: [ GraphBrowsers.basicBrowserClass.cmds[red], ALL[ALL[[BrowserClick]]], ALL[ALL[[BrowserClick]]]] ]]; BrowseDisplay: PROC [display: Display, info: ViewerClasses.ViewerRec _ [], paint: BOOLEAN _ TRUE] RETURNS [v: ViewerClasses.Viewer] = BEGIN v _ GraphBrowsers.Browse[node: CellNode[display.rootCell, display, NIL], browserClass: rosemaryBrowser, browserData: display, viewerInit: info, paint: paint].BrowserQuaViewer[]; END; CellNode: PROC [cell: Cell, display: Display, parent: CellBrowser] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: NEW [CellBrowserRep _ [cell, display, parent]]]]}; StateNode: PROC [cb: CellBrowser] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: NEW [CellStateRep _ [cb]]]]}; InterfaceNode: PROC [cb: CellBrowser] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: NEW [InterfaceNodesRep _ [cb]]]]}; InternalNode: PROC [cb: CellBrowser] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: NEW [InternalNodesRep _ [cb]]]]}; ComponentsNode: PROC [cb: CellBrowser] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: NEW [ComponentsRep _ [cb]]]]}; NodeNode: PROC [ne: NodeElt] RETURNS [node: Graphs.Node] = {node _ NEW [Graphs.NodeRep _ [type: roseType, rep: ne]]}; RoseNeighborCount: Graphs.NeighborCountProc--PROC [node: Node] RETURNS [neighborCount: INT]-- = CHECKED BEGIN WITH node.rep SELECT FROM cb: CellBrowser => RETURN[4]; in: InterfaceNodes => RETURN[in.cb1.cell.class.ports.length]; in: InternalNodes => RETURN[in.cb2.cell.internalNodes.Size[]]; components: Components => RETURN[components.cb3.cell.components.Size[]]; cs: CellState => RETURN [0]; ne: NodeElt => RETURN [0]; ENDCASE => ERROR; END; RoseExpand: Graphs.ExpandProc--PROC [node: Node, consume: LinkConsumer]-- = TRUSTED BEGIN WITH node.rep SELECT FROM cb: CellBrowser => EnumerateCell[cb, consume]; in: InterfaceNodes => EnumerateInterfaceNodes[in, consume]; in: InternalNodes => EnumerateInternalNodes[in, consume]; components: Components => EnumerateComponents[components, consume]; cs: CellState => NULL; ne: NodeElt => NULL; ENDCASE => ERROR; END; EnumerateCell: PROC [cb: CellBrowser, to: Graphs.LinkConsumer, interf, intern: BOOLEAN _ TRUE] = BEGIN canInterf: BOOLEAN _ cb.cell.interfaceNodes.length > 0; canIntern: BOOLEAN _ cb.cell.internalNodes.Size[] > 0; canBoth: BOOLEAN _ canInterf AND canIntern; interf _ interf OR NOT canBoth; intern _ intern OR NOT canBoth; IF canInterf AND interf THEN to.proc[["Interface Nodes", InterfaceNode[cb]], to.data]; IF canIntern AND intern THEN to.proc[["Internal Nodes", InternalNode[cb]], to.data]; IF cb.cell.components.Size[] > 0 THEN to.proc[["Components", ComponentsNode[cb]], to.data]; IF (IF cb.cell.realCellStuff = NIL THEN FALSE ELSE IF cb.cell.realCellStuff.state = NIL THEN FALSE ELSE NOT ISTYPE[cb.cell.realCellStuff.state, Rosemary.Structure]) THEN to.proc[["State", StateNode[cb]], to.data]; END; EnumerateInterfaceNodes: PROC [in: InterfaceNodes, to: Graphs.LinkConsumer] = BEGIN FOR ni: CARDINAL IN [0 .. in.cb1.cell.class.ports.length) DO port: Rosemary.Port _ in.cb1.cell.class.ports[ni]; node: Node _ in.cb1.cell.interfaceNodes[ni]; ne: NodeElt _ NEW [NodeEltRep _ [node: node, name: port.name, org: [display: in.cb1.display, cell: in.cb1.cell], interfaceIndex: ni, interfaceNode: TRUE, parent: in.cb1]]; to.proc[[port.name, NodeNode[ne]], to.data]; ENDLOOP; END; EnumerateInternalNodes: PROC [in: InternalNodes, to: Graphs.LinkConsumer] = BEGIN FOR node: Node _ in.cb2.cell.firstInternalNode, node.next WHILE node # NIL DO ne: NodeElt _ NEW [NodeEltRep _ [node: node, name: node.name, org: [display: in.cb2.display, cell: in.cb2.cell], interfaceIndex: notLookedFor, parent: in.cb2]]; to.proc[[node.name, NodeNode[ne]], to.data]; ENDLOOP; END; notFound: CARDINAL = Rosemary.notFound; notLookedFor: CARDINAL = notFound - 1; EnumerateComponents: PROC [components: Components, to: Graphs.LinkConsumer] = BEGIN FOR cell: Cell _ components.cb3.cell.leftChild, cell.rightSibling WHILE cell # NIL DO cb: CellBrowser _ NEW [CellBrowserRep _ [cell: cell, display: components.cb3.display, parent: components.cb3]]; to.proc[[cell.name, CellNode[cell: cell, display: components.cb3.display, parent: components.cb3]], to.data]; ENDLOOP; END; NDLSearch: PUBLIC PROC [ndl: NodeDisplayList, org: NodeOrigin, remove: BOOLEAN] RETURNS [newdl: NodeDisplayList, nd: NodeDisplay, found: BOOLEAN] = BEGIN prev: NodeDisplayList _ NIL; newdl _ ndl; found _ FALSE; FOR ndl _ ndl, ndl.rest WHILE ndl # NIL DO IF ndl.first.org = org THEN BEGIN IF found THEN ERROR ELSE found _ TRUE; nd _ ndl.first; IF remove THEN {IF prev = NIL THEN newdl _ ndl.rest ELSE prev.rest _ ndl.rest}; RETURN; END; prev _ ndl; ENDLOOP; END; whatToDo: ARRAY Menus.MouseButton[yellow .. blue] OF ARRAY BOOLEAN OF Graphs.LinkConsumerProc _ ALL[ALL[NIL]]; BrowserClick: GraphBrowsers.BrowserCmdProc--PROC [pane: Pane, index: CARDINAL- -origin 0- -, cmdData, browserData: REF ANY, button: Menus.MouseButton, ctl, shift, paint: BOOLEAN]-- = CHECKED BEGIN whatToDo[button][shift][[pane.GetChildName[index], pane.GetChildNode[index]], NIL]; END; DisplayAllButState: Graphs.LinkConsumerProc = TRUSTED BEGIN WITH link.otherSide.rep SELECT FROM ne: NodeElt => DisplayNode[ne, FALSE]; cs: CellState => NULL; cb: CellBrowser => EnumerateCell[cb: cb, to: [DisplayAllButState], interf: FALSE]; in: InterfaceNodes => EnumerateInterfaceNodes[in, [DisplayAllButState]]; in: InternalNodes => EnumerateInternalNodes[in, [DisplayAllButState]]; components: Components => EnumerateComponents[components, [DisplayAllButState]]; ENDCASE => ERROR; END; UnDisplayAll: Graphs.LinkConsumerProc = TRUSTED BEGIN WITH link.otherSide.rep SELECT FROM ne: NodeElt => UnDisplayNode[ne, FALSE]; cs: CellState => UnDisplayCellState[cs]; cb: CellBrowser => UnDisplayCell[cb]; in: InterfaceNodes => EnumerateInterfaceNodes[in, [UnDisplayAll]]; in: InternalNodes => EnumerateInternalNodes[in, [UnDisplayAll]]; components: Components => EnumerateComponents[components, [UnDisplayAll]]; ENDCASE => ERROR; END; DisplayAllState: Graphs.LinkConsumerProc = TRUSTED BEGIN WITH link.otherSide.rep SELECT FROM ne: NodeElt => NULL; cs: CellState => DisplayCellState[cs]; cb: CellBrowser => EnumerateCell[cb: cb, to: [DisplayAllState], interf: FALSE]; in: InterfaceNodes => NULL; in: InternalNodes => NULL; components: Components => EnumerateComponents[components, [DisplayAllState]]; ENDCASE => ERROR; END; UnDisplayAllState: Graphs.LinkConsumerProc = TRUSTED BEGIN WITH link.otherSide.rep SELECT FROM ne: NodeElt => NULL; cs: CellState => UnDisplayCellState[cs]; cb: CellBrowser => EnumerateCell[cb: cb, to: [UnDisplayAllState], interf: FALSE]; in: InterfaceNodes => NULL; in: InternalNodes => NULL; components: Components => EnumerateComponents[components, [UnDisplayAllState]]; ENDCASE => ERROR; END; DisplayCellState: PROC [cs: CellState] = BEGIN dl: HD.Leaf _ NARROW[List.Assoc[key: cellStateDisplayProp, aList: cs.cb0.cell.other]]; IF dl = NIL THEN BEGIN CreateValue: HD.ValueCreater --PROC [leaf: Leaf] RETURNS [value: Viewer]-- = CHECKED BEGIN value _ VR.ViewRef[ agg: cs.cb0.cell.realCellStuff.state, viewerInit: [ parent: leaf.container, wx: 10, wy: leaf.nameButton.wy + leaf.nameButton.wh + 2, ww: MAX[100, leaf.container.cw - 10], wh: VF.FontHeight[] + 5, iconic: FALSE, border: TRUE, scrollable: FALSE], createOptions: [feedBackHeight: 0], parent: cs.cb0.display.rv, paint: FALSE].RVQuaViewer[]; END; dp: HD.Parent _ EnsureDisplay[cs.cb0]; name: ROPE _ cs.cb0.cell.name.Cat["'s state:"]; dl _ HD.AddLeaf[parent: dp, before: NextCellChild[cs.cb0.display, cs.cb0.cell.leftChild], name: name, class: cellStateClass, instanceData: cs, CreateValue: CreateValue, paint: FALSE]; cs.cb0.cell.other _ List.PutAssoc[key: cellStateDisplayProp, val: dl, aList: cs.cb0.cell.other]; END; END; UnDisplayCellState: PROC [cs: CellState] = BEGIN dl: HD.Leaf _ NARROW[List.Assoc[key: cellStateDisplayProp, aList: cs.cb0.cell.other]]; IF dl # NIL THEN HD.Remove[dl]; END; NoticeCellStateRemoval: HD.ChildNotifyProc -- PROC [child: Child]-- = CHECKED BEGIN cs: CellState _ NARROW[child.instanceData]; cs.cb0.cell.other _ List.PutAssoc[key: cellStateDisplayProp, val: NIL, aList: cs.cb0.cell.other]; END; CellStateButtonProc: Buttons.ButtonProc = CHECKED BEGIN MessageWindow.Append[message: "Don't do that", clearFirst: TRUE]; END; UnDisplayNode: PROC [ne: NodeElt, noisy: BOOLEAN] = BEGIN displays: NodeDisplayList _ NARROW[List.Assoc[key: nodeDisplaysProp, aList: ne.node.other]]; nd: NodeDisplay; found: BOOLEAN; [displays, nd, found] _ NDLSearch[ndl: displays, org: ne.org, remove: FALSE]; IF NOT found THEN {IF noisy THEN ne.org.display.rv.DisplayMessage[msg: "not displayed!"]} ELSE BEGIN HD.Remove[nd.dc]; IF noisy THEN ne.org.display.rv.DisplayMessage[msg: "ok"]; END; END; EnsureInterfaceIndex: PROC [ne: NodeElt] = { IF ne.interfaceIndex = notLookedFor THEN ne.interfaceIndex _ Rosemary.GetIndex[ne.org.cell.class.ports, ne.name]}; DisplayNode: PROC [ne: NodeElt, noisy: BOOLEAN] = BEGIN displays: NodeDisplayList _ NARROW[List.Assoc[key: nodeDisplaysProp, aList: ne.node.other]]; nd: NodeDisplay; found: BOOLEAN; [, nd, found] _ NDLSearch[ndl: displays, org: ne.org, remove: FALSE]; IF found THEN {IF noisy THEN ne.org.display.rv.DisplayMessage[msg: "already displayed!"]} ELSE IF ne.node.visible.cell # NIL THEN BEGIN CreateValue: HD.ValueCreater = TRUSTED BEGIN value _ VO.CreateViewer[flavor: $Text, paint: FALSE, info: [parent: leaf.container, data: IF ne.org.display.ctlPanel.mode = Value THEN ne.node.type.toRope[ where: ne.node.visible.SocketToWP[], typeData: ne.node.type.typeData] ELSE ne.node.type.unParseTest[ testProc: ne.testProc, testData: ne.testData, typeData: ne.node.type.typeData, subject: NIL], wx: leaf.nameButton.wx + leaf.nameButton.ww + 2, ww: ne.node.type.maxWidth[ne.node.type.typeData, VF.defaultFont] + 20, wh: VF.FontHeight[] + 5, iconic: FALSE, border: FALSE, scrollable: FALSE]]; VO.AddProp[viewer: value, prop: leafProp, val: leaf]; END; dp: HD.Parent _ EnsureDisplay[ne.parent]; dc: HD.Leaf; name: ROPE _ ne.name; IF NOT ne.interfaceNode THEN name _ name.Concat[":"]; EnsureInterfaceIndex[ne]; IF ne.interfaceIndex # notFound THEN BEGIN name _ name.Concat[SELECT (IF ne.org.cell.class.ports[ne.interfaceIndex].input THEN 1 ELSE 0) + (IF ne.org.cell.class.ports[ne.interfaceIndex].output THEN 2 ELSE 0) FROM 1 => "<", 2 => ">", 3 => "=", ENDCASE => ERROR]; END; dc _ HD.AddLeaf[parent: dp, before: NextNodeChild[ne], name: name, class: nodeClass, instanceData: ne, CreateValue: CreateValue, paint: FALSE]; displays _ CONS[[ne.org, dc], displays]; ne.node.other _ List.PutAssoc[key: nodeDisplaysProp, val: displays, aList: ne.node.other]; Rosemary.AddNodeWatcher[node: ne.node, watcher: [NotifyNodeView, dc], priority: 1]; IF noisy THEN ne.org.display.rv.DisplayMessage[msg: "ok"]; END ELSE ne.org.display.rv.DisplayMessage[ne.name.Cat[" can't be displayed"]]; END; NextNodeChild: PROC [ne: NodeElt] RETURNS [child: HD.Child] = BEGIN Displayed: PROC [node: Node] RETURNS [BOOLEAN] = BEGIN displays: NodeDisplayList _ NARROW[List.Assoc[key: nodeDisplaysProp, aList: node.other]]; nd: NodeDisplay; found: BOOLEAN; [, nd, found] _ NDLSearch[ndl: displays, org: ne.org, remove: FALSE]; IF found THEN child _ nd.dc; RETURN [found]; END; node: Node _ ne.node.next; IF ne.interfaceNode THEN BEGIN FOR c: CARDINAL IN (ne.interfaceIndex .. ne.org.cell.interfaceNodes.length) DO IF Displayed[ne.org.cell.interfaceNodes[c]] THEN RETURN; ENDLOOP; node _ ne.org.cell.firstInternalNode; END; FOR node _ node, node.next WHILE node # NIL DO IF Displayed[node] THEN RETURN ENDLOOP; child _ NARROW[List.Assoc[key: cellStateDisplayProp, aList: ne.org.cell.other]]; IF child # NIL THEN RETURN; child _ NextCellChild[ne.org.display, ne.org.cell.leftChild]; END; UnDisplayCell: PROC [cb: CellBrowser] = BEGIN dpAsAny: REF ANY _ List.Assoc[aList: cb.cell.other, key: cb.display]; IF dpAsAny # NIL THEN BEGIN dp: HD.Parent _ NARROW[dpAsAny]; IF dp.asChild # NIL THEN BEGIN HD.Remove[dp.asChild]; END; END; END; NextCellChild: PROC [display: Display, start: Cell] RETURNS [child: HD.Child] = BEGIN FOR cell: Cell _ start, cell.rightSibling WHILE cell # NIL DO nextDPAsAny: REF ANY _ List.Assoc[aList: cell.other, key: display]; IF nextDPAsAny # NIL THEN {child _ NARROW[nextDPAsAny, HD.Parent].asChild; EXIT}; ENDLOOP; END; EnsureDisplay: PROC [cb: CellBrowser] RETURNS [dp: HD.Parent] = BEGIN dpAsAny: REF ANY _ List.Assoc[aList: cb.cell.other, key: cb.display]; IF dpAsAny = NIL THEN BEGIN pdp: HD.Parent _ IF cb.parent = NIL THEN cb.display.rootDisplay ELSE EnsureDisplay[cb.parent]; dc: HD.Child; dp _ (dc _ HD.AddInternalNode[parent: pdp, before: NextCellChild[cb.display, cb.cell.rightSibling], name: cb.cell.name.Cat[": "], class: cellClass, instanceData: cb, paint: FALSE]).asParent; cb.cell.other _ List.PutAssoc[key: cb.display, val: dp, aList: cb.cell.other]; IF cb.cell.type = Real THEN BEGIN Rosemary.AddCellEventWatcher[cb.cell, $Schedule, [NotifyCellView, dc]]; NotifyCellView[cb.cell, dc]; END; END ELSE dp _ NARROW[dpAsAny]; END; Setup: PROC = BEGIN whatToDo[yellow][FALSE] _ DisplayAllButState; whatToDo[yellow][TRUE] _ UnDisplayAll; whatToDo[blue][FALSE] _ DisplayAllState; whatToDo[blue][TRUE] _ UnDisplayAllState; END; Setup[]; END. PRoseDisplayBrowsing.Mesa Last Edited by: Spreitzer, July 18, 1983 9:23 pm ΚΤ˜J™J™0J˜codešΟk ˜ Kšœ<œ§˜ε—K˜šΠbxœ˜Kš œœhœ œ œ ˜¬Kšœ˜—K˜Kšœœ˜K˜Kšœœœ˜.Kšœœœ˜2K˜š œœœœœ˜@K˜ K˜)—K˜šœœ˜7K˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœ$˜$Kšœœ˜ —K˜šœ-˜-šœ#˜&šœ˜Kšœ*˜*Kšœœ˜Kšœœ˜———K˜š Οn œœ?œœœ˜…Kš˜KšœCœk˜±Kšœ˜—K˜šŸœœ5œ˜`Kšœœ)œ/˜f—K˜šŸ œœœ˜?Kšœœ)œ˜Q—K˜šŸ œœœ˜CKšœœ)œ˜V—K˜šŸ œœœ˜BKšœœ)œ˜U—K˜šŸœœœ˜DKšœœ)œ˜R—K˜šŸœœœ˜:Kšœœ/˜:—K˜K˜šŸœΟc2œ˜gKš˜šœ œ˜Kšœœ˜Kšœœ!˜=Kšœœ#˜>Kšœœ(˜HKšœœ˜Kšœœ˜Kšœœ˜—Kšœ˜—K˜šŸ œ ,œ˜SKš˜šœ œ˜Kšœ.˜.Kšœ;˜;Kšœ9˜9KšœC˜CKšœœ˜Kšœœ˜Kšœœ˜—Kšœ˜—K˜šŸ œœ<œœ˜`Kš˜Kšœ œ%˜7Kšœ œ$˜6Kšœ œ œ ˜+Kšœœœ ˜Kšœœœ ˜Kšœ œœ:˜VKšœ œœ8˜TKšœœ6˜[Kšœœœœœœœœœœœœœ3œ,˜ΥKšœ˜—K˜šŸœœ0˜MKš˜šœœœ'˜œ˜Ešœ˜ Kšœœœ=˜K—š œœœœ˜-š‘ œœ˜&Kš˜šœœ$œ˜4˜šœœ%˜-šœ˜Kšœ$˜$Kšœ ˜ —šœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ œ˜——K˜0Kšœ1œ˜FKšœœ˜Kšœœ˜Kšœœ˜Kšœ œ˜——Kšœ3˜5Kšœ˜—Kšœœ#˜)Kšœœ˜ Kšœœ ˜Kšœœœ˜5K˜šœ˜$Kš˜Kšœœœ2œœœ3œœœœœ˜ΪKšœ˜—Kšœœœ˜Kšœ œ˜(K˜ZK˜SKšœœ-˜:Kš˜—KšœF˜JKšœ˜—K˜šŸ œœœ œ ˜=Kš˜šŸ œœœœ˜0Kš˜Kšœœ7˜YK˜Kšœœ˜Kšœ>œ˜EKšœœ˜Kšœ ˜Kšœ˜—K˜šœ˜Kš˜šœœœ:˜NKšœ*œœ˜8Kšœ˜—K˜%Kšœ˜—šœœœ˜.Kšœœœœ˜'—KšœœB˜PKšœ œœœ˜K˜=Kšœ˜—K˜šŸ œœ˜'Kš˜Kšœ œœ5˜Ešœ œ˜Kš˜Kšœœ œ ˜ šœœ˜Kš˜Kšœ˜Kšœ˜—Kšœ˜—Kšœ˜—K˜šŸ œœ!œ œ ˜OKš˜šœ'œœ˜=Kšœ œœ/˜Cšœœ˜Kšœ œœœ˜7—Kšœ˜—Kšœ˜—K˜šŸ œœœœ ˜?Kš˜Kšœ œœ5˜Ešœ œ˜Kš˜Kš œœ œ œœœ˜^Kšœœ˜ Kšœ œ œ ˜ΎKšœN˜Nšœ˜Kš˜KšœG˜GK˜Kšœ˜—Kš˜—Kšœœ ˜Kšœ˜—K˜šŸœœ˜ Kš˜Kšœœ˜-Kšœœ˜&Kšœœ˜(Kšœœ˜)Kšœ˜—K˜K˜ Kšœ˜—…—8rH–