DIRECTORY Rope USING [ROPE], TiogaLooks USING [Looks, Runs], TiogaNode, TiogaItemClass, TiogaBasicClass; TiogaNodeOps: CEDAR DEFINITIONS = BEGIN OPEN Rope, TiogaNode, TiogaItemClass, TiogaBasicClass; RegisterItemClass: PROC [classRec: ItemClassRec, OKToOverwritePrevious: BOOL --_ FALSE--] RETURNS [ItemClassID]; LookupItemID: PROC [flavor: ItemFlavor, buildNewClassIfLookupFails: BOOL --_ FALSE--] RETURNS [ItemClassID]; FetchItemClass: PROC [id: ItemClassID] RETURNS [ItemClass]; RegisterBasicClass: PROC [classRec: BasicClassRec, OKToOverwritePrevious: BOOL --_ FALSE--] RETURNS [BasicClassID]; LookupBasicID: PROC [flavor: BasicFlavor, buildNewClassIfLookupFails: BOOL --_ FALSE--] RETURNS [BasicClassID]; FetchBasicClass: PROC [id: BasicClassID] RETURNS [BasicClass]; NewBranchNode: PROC RETURNS [br: RefBranchNode]; NewTextNode: PROC [class: ItemClassID] RETURNS [tx: RefTextNode]; NewListNode: PROC [class: ItemClassID] RETURNS [ls: RefListNode]; NewBoxNode: PROC [class: ItemClassID] RETURNS [bx: RefBoxNode]; NewBasicNode: PROC [class: BasicClassID] RETURNS [bs: RefBasicNode]; FetchChar: PROC [text: RefTextNode, index: Offset] RETURNS [CHAR]; FetchLooks: PROC [text: RefTextNode, index: Offset] RETURNS [TiogaLooks.Looks]; Fetch: PROC [text: RefTextNode, index: Offset] RETURNS [CHAR, TiogaLooks.Looks]; GetRope, NodeRope: PROC [text: RefTextNode] RETURNS [ROPE]; GetRuns, NodeRuns: PROC [text: RefTextNode] RETURNS [TiogaLooks.Runs]; Size: PROC [text: RefTextNode] RETURNS [Offset]; FromRope: PROC [rope: ROPE, class: ItemClassID _ defaultTextClassID] RETURNS [RefTextNode]; FromString: PROC [string: REF READONLY TEXT, class: ItemClassID _ defaultTextClassID] RETURNS [RefTextNode]; DocFromNode: PROC [child: RefItemNode] RETURNS [root: RefBranchNode]; FreeTree: PROC [root: RefBranchNode]; IsBranch: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefBranchNode]]}; IsItem: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefItemNode]]}; IsText: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefTextNode]]}; IsList: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefListNode]]}; IsBox: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefBoxNode]]}; IsBasic: PROC [n: Ref] RETURNS [BOOL] = INLINE {RETURN[n#NIL AND ISTYPE[n, RefBasicNode]]}; NarrowToBranchNode: PROC [n: Ref] RETURNS [RefBranchNode] = INLINE {RETURN [WITH n SELECT FROM br: RefBranchNode => br, ENDCASE => NIL] }; NarrowToItemNode: PROC [n: Ref] RETURNS [RefItemNode] = INLINE {RETURN [WITH n SELECT FROM it: RefItemNode => it, ENDCASE => NIL] }; NarrowToTextNode: PROC [n: Ref] RETURNS [RefTextNode] = INLINE {RETURN [WITH n SELECT FROM tx: RefTextNode => tx, ENDCASE => NIL] }; NarrowToListNode: PROC [n: Ref] RETURNS [ls: RefListNode] = INLINE {RETURN [WITH n SELECT FROM ls: RefListNode => ls, ENDCASE => NIL] }; NarrowToBoxNode: PROC [n: Ref] RETURNS [RefBoxNode] = INLINE {RETURN [WITH n SELECT FROM bx: RefBoxNode => bx, ENDCASE => NIL] }; NarrowToBasicNode: PROC [n: Ref] RETURNS [RefBasicNode] = INLINE {RETURN [WITH n SELECT FROM bs: RefBasicNode => bs, ENDCASE => NIL] }; MakeNodeLoc: PROC [n: Ref] RETURNS [Location]; MakeNodeSpan: PROC [first, last: Ref] RETURNS [Span]; NodeSpan: PROC [span: Span] RETURNS [Span] = INLINE { RETURN [[[span.start.path,NodeItself],[span.end.path,NodeItself]]] }; NodeLoc: PROC [loc: Location] RETURNS [Location] = INLINE { RETURN [[loc.path,NodeItself]] }; EndPos: PROC [n: RefTextNode] RETURNS [Offset]; -- gives offset at end of text node END. òTiogaNodeOps.mesa; Written by McGregor, February 1983 edited by McGregor, August 17, 1983 5:02 pm edited by Paxton, August 10, 1983 4:26 pm Item Node Class registration and operations Register a new item class implementation. Iff OKToOverwritePrevious is TRUE then the registry will permit a new implementation to replace another with the same ItemFlavor. Given the name for a item node class, fetch the class ID. Will return invalidItemID if the given class is not registered and buildNewClassIfLookupFails is FALSE. If buildNewClassIfLookupFails is TRUE then a new class will be generated that performs read/write operations as well as a default display. Given the unique class ID for a item node class, fetch the class information. Will return NIL if the given class is not registered. Basic Node Class registration and operations Register a new item class implementation. Iff OKToOverwritePrevious is TRUE then the registry will permit a new implementation to replace another with the same BasicFlavor Given the name for a basic node class, fetch the class ID. Will return invalidBasicID if the given class is not registered. If buildNewClassIfLookupFails is TRUE then a new class will be generated that performs read/write operations as well as a default display. Given the unique class ID for a basic node class, fetch the class information. Will return NIL if the given class is not registered. Creating new nodes Text node operations fetches the indexed information returns the looks for the character at the given location use reader's if getting looks for sequence of locations fetches the indexed information Operations to create a text node from a rope or a string create a text node with looks from a normal rope copies the contents of the string Operation to create a document from an item node child typically created by FromRope or FromString Operation to free a tree by clearing all REF's Node predicates Node narrowing Return the requested type of node if possible, else return NIL Miscellaneous Êv˜Jšœ5™5Jšœ+™+Jšœ)™)J˜šÏk ˜ Jšœœœ˜Jšœ œ˜Jšœ ˜ Jšœ˜Jšœ˜J˜—Jšœœ œ˜'Jšœ2˜6J˜™+J˜procš Ïnœœ1œÏcÐckŸœœ˜pKšœHœ`™¬K˜—š ž œœ2œŸ Ÿœœ˜lKšœ6œdœ™®K™—šžœœœ ˜;Kšœ[œ&™„—J˜—™,J˜š žœœ2œŸ Ÿœœ˜sKšœHœ`™¬K˜—š ž œœ3œŸ Ÿœœ˜oKšœ7œÏ™ˆK™—šžœœœ˜>Kšœ\œ&™…—J˜—™J˜šž œœœ˜0J˜—šž œœœ˜AJ˜—šž œœœ˜AJ˜—šž œœœ˜?J˜—Jšž œœœ˜DJ˜—™J˜šž œœ$œœ˜BJšŸ™J˜—šž œœ$œ˜OJšŸ9™9JšŸ7™7J˜—šžœœ$œœ˜PJšŸ™J˜—Jšžœœœœ˜;J˜Jšžœœœ˜FJ˜Jšžœœœ ˜0J˜—šŸ8™8J˜šžœœœ*˜DJšœ˜JšŸ0™0J˜—š ž œœ œœœ*˜UJšœ˜JšŸ!™!J˜——šŸ0™0J™šž œœœ˜EJšŸ1™1J˜——šŸ.™.J™šžœœ˜%J˜——™J˜š žœœ œœ˜/Jš œœœœœ˜-J˜—š žœœ œœ˜-Jš œœœœœ˜+J˜—š žœœ œœ˜-Jš œœœœœ˜+J˜—š žœœ œœ˜-Jš œœœœœ˜+J˜—š žœœ œœ˜,Jš œœœœœ˜*J˜—š žœœ œœ˜.Jš œœœœœ˜,J˜—J˜—™J˜™>J˜—šžœœ œ˜BJš œœœœœœœ˜GJ˜—šžœœ œ˜>Jš œœœœœœœ˜EJ˜—šžœœ œ˜>Jš œœœœœœœ˜EJ˜—šžœœ œ˜BJš œœœœœœœ˜EJ˜—šžœœ œ˜J˜—šžœœœ˜9Jšœœ˜#J˜—Jšžœœœ Ÿ#˜SJ˜J˜—Jšœ˜J˜J˜—…— ˆ