DIRECTORY Rope USING [ROPE], Rosary USING [ROSARY]; TextNode: CEDAR DEFINITIONS = BEGIN MaxLen: INT = LAST[INT]; ROPE: TYPE = Rope.ROPE; ROSARY: TYPE = Rosary.ROSARY; Node: TYPE = REF NodeRep; Ref: TYPE = Node; -- for compatibility NodeRep: TYPE = RECORD [ next: Node, -- points to next sibling, or if last=true, to parent child: Node, -- points to first child, if any, of this node props: NodeProps, -- points to node property list formatName: ATOM _ NIL, -- name of format for the node last: BOOL _ FALSE, -- true if this is last sibling hasstyledef: BOOL _ FALSE, -- true if node has StyleDef prop (accelerator) hasprefix: BOOL _ FALSE, -- true if node has Prefix prop (accelerator) haspostfix: BOOL _ FALSE, -- true if node has Postfix prop (accelerator) hasartwork: BOOL _ FALSE, -- true if node has Artwork prop (accelerator) hasactive: BOOL _ FALSE, -- true if node has Active prop (accelerator) deleted: BOOL _ FALSE, -- true if has been deleted or is root pending delete dirty: BOOL _ FALSE, -- true if has been edited (contents, or children moved, inserted, ...) new: BOOL _ FALSE, -- true if created during this editing session (i.e., not from file) comment: BOOL _ FALSE, -- true if node is a comment rope: ROPE, charSets: ROSARY--OF REF CharSet--, charLooks: ROSARY--OF REF Looks--, charProps: ROSARY--OF PropList-- ]; Location: TYPE = RECORD [node: Node, where: INT]; NodeItself: INT = -1; nullLocation: Location = [node: NIL, where: NodeItself]; MakeNodeLoc: PROC [n: Node] RETURNS [Location]; Span: TYPE = RECORD [start, end: Location _ nullLocation]; nullSpan: Span = [nullLocation,nullLocation]; MakeNodeSpan: PROC [first, last: Node] RETURNS [Span]; NodeList: TYPE = REF NodeListBody; NodeListBody: TYPE = RECORD [node: Node, next: NodeList]; NodeProps: TYPE = REF NodePropsBody; NodePropsBody: TYPE; -- exported by NodePropsImpl NewTextNode: PROC RETURNS [txt: Node]; Parent: PROC [n: Node] RETURNS [Node]; Root: PROC [n: Node] RETURNS [Node]; Next: PROC [n: Node] RETURNS [Node]; Previous: PROC [n: Node, parent: Node _ NIL] RETURNS [nx: Node]; Forward: PROC [node: Node] RETURNS [nx: Node, levelDelta: INTEGER]; Backward: PROC [node: Node, parent: Node _ NIL] RETURNS [back, backparent: Node, levelDelta: INTEGER]; StepForward: PROC [node: Node] RETURNS [Node]; StepBackward: PROC [node: Node, parent: Node _ NIL] RETURNS [Node]; Level: PROC [node: Node] RETURNS [level: INTEGER]; ForwardClipped: PROC [node: Node, maxLevel: INTEGER, nodeLevel: INTEGER _ 0] RETURNS [nx: Node, nxLevel: INTEGER]; BackwardClipped: PROC [node: Node, maxLevel: INTEGER, parent: Node _ NIL, nodeLevel: INTEGER _ 0] RETURNS [back, backparent: Node, backLevel: INTEGER]; LocRelative: PROC [location: Location, count: INT, break: NAT _ 1, skipCommentNodes: BOOL _ FALSE] RETURNS [Location]; LocWithin: PROC [n: Node, count: INT, break: NAT _ 1, skipCommentNodes: BOOL _ FALSE] RETURNS [Location]; LocOffset: PROC [loc1, loc2: Location, break: NAT _ 1, skipCommentNodes: BOOL _ FALSE] RETURNS [count: INT]; BadArgs: ERROR; LocNumber: PROC [at: Location, break: NAT _ 1, skipCommentNodes: BOOL _ FALSE] RETURNS [count: INT]; FirstSibling: PROC [n: Node] RETURNS [Node]; LastSibling: PROC [n: Node] RETURNS [Node]; LastWithin: PROC [n: Node] RETURNS [Node]; LastLocWithin: PROC [n: Node] RETURNS [Location]; FirstChild: PROC [n: Node] RETURNS [Node]; LastChild: PROC [n: Node] RETURNS [Node]; NthChild: PROC [n: Node, location: INT _ 0] RETURNS [child: Node]; NthSibling: PROC [n: Node, cnt: INT _ 0] RETURNS [Node]; CountChildren: PROC [n: Node] RETURNS [count: INT]; CountFollowing: PROC [n: Node] RETURNS [count: INT]; CountToParent: PROC [n: Node] RETURNS [count: INT, parent: Node]; CountToChild: PROC [parent, child: Node] RETURNS [count: INT]; NodeFormat: PROC [n: Node] RETURNS [ATOM]; IsLastSibling: PROC [n: Node] RETURNS [BOOL]; EndPos: PROC [n: Node] RETURNS [INT]; END. lTextNode.mesa Copyright Σ 1985, 1986, 1988 by Xerox Corporation. All rights reserved. written by Bill Paxton. December 1980 last written by Paxton. December 21, 1982 9:46 am Last Edited by: Maxwell, January 5, 1983 12:37 pm Rick Beach, March 27, 1985 1:08:21 pm PST Michael Plass, March 26, 1985 12:18:42 pm PST Doug Wyatt, February 17, 1988 5:18:08 pm PST where >= length of text means at end where = loc in [0..length) means before that character e.g., where = 0 means at start of text where = NodeItself means location is the node itself rather than in its contents start.node can equal end.node in which case either both start.where and end.where = NodeItself, or neither do and start.where <= end.where otherwise, end.node should follow start.node in the tree nodes need not be siblings no restrictions on start.where or end.where returns next sibling of n returns NIL if n is last sibling returns previous sibling of n returns NIL if n is first sibling runs faster if can supply parent returns next node in standard tree walk order levelDelta is level(node)-level(nx), where level is depth in tree levelDelta = 0 if nx and node are siblings levelDelta = 1 if nx is child of node levelDelta < 0 if do Parent* and Next to reach nx from node for backing through tree runs faster if can supply parent levelDelta same as for Forward returns next node in standard tree walk order returns preceding node in standard tree walk order Level[Root[x]] == 0; Level[FirstChild[n]]=Level[n]+1 like Forward, but limits how deep will go in tree if pass nodeLevel=0, correct value will be computed nxLevel = Level[nx] <= MAX[maxLevel,Level[node]] like Backward, but limits how deep will go in tree backLevel = Level[back] <= MAX[maxLevel,Level[node]] count is interpreted as a character offset from given location returns location corresponding to count adds in break at the end of each text subnode if skipCommentNodes is true, then ignores them in walking the tree returns character offset of location2 relative to location1 loc1 and loc2 can be in same node but loc2 must not be in node before loc1 or get ERROR BadArgs if skipCommentNodes is true, then ignores them in walking the tree returns character offset of location relative to root returns the last node within the branch i.e., goes to last child of last child of last child ... until no child returns the last location within the branch Κp˜codešœ ™ KšœH™HKšœ%™%Kšœ1™1K™1K™)K™-K™,—K˜šΟk ˜ Kšœœœ˜Kšœœœ˜—K˜KšΠblœœ ˜Kšœ˜˜Kšœœœœ˜Kšœœœ˜Kšœœ œ˜K˜Kšœœœ ˜Kšœœ Οc˜&šœ œœ˜Kšœ Ÿ5˜AKšœ Ÿ.˜;KšœŸ˜1Kšœ œœŸ˜6KšœœœŸ˜3Kšœ œœŸ/˜JKšœ œœŸ-˜FKšœ œœŸ.˜HKšœ œœŸ.˜HKšœ œœŸ-˜FKšœ œœŸ5˜LKšœœœŸG˜\KšœœœŸD˜WKšœ œœŸ˜3Kšœœ˜ Kš œ ŸœœŸœ˜#Kš œ ŸœœŸœ˜"Kšœ Ÿœ Ÿ˜ šœ˜K˜——šœ œœœ˜1Kšœ$™$šœ6™6Kšœ&™&—KšœP™PK˜—Kšœ œ˜K˜Kšœ œ˜8K˜KšΟn œœ œ ˜/K˜šœœœ'˜:šœ™KšœD™DKšœ'™'—šœ8™8Kšœ™Kšœ+™+K˜——K˜-K˜š  œœœ˜6K˜—Kšœ œœ˜"Kšœœœ˜9K˜Kšœ œœ˜$KšœœŸ˜1K˜š  œœœ ˜&K˜—š œœ œ˜&K˜—š œœ œ˜$K˜—š œœ œ˜$Kšœ™Kšœœ™ K˜—š œœœœ ˜@Kšœ™Kšœœ™!Kšœ ™ K˜—š œœœœ˜CKšœ-™-šœA™AKšœ*™*Kšœ%™%Kšœ;™;K˜——š œœœ˜/Kšœ&œ˜6Kšœ™Kšœ ™ Kšœ™K˜—š  œœœ˜.Kšœ-™-K˜—š  œœœœ˜CKšœ2™2K˜—K˜š œœœ œ˜2Kšœ4™4K˜—š  œœœ œœœ˜rKšœ1™1Kšœ4™4Kšœœ™0K˜—š œœœœœœ%œ˜˜Kšœ2™2Kšœœ™4K˜—K˜š  œœœ œœœœ ˜wKšœ>™>Kšœ5™5Kšœ-™-KšœB™BK˜—š  œœœ œœœœ ˜iK˜—š  œœœœœœ œ˜lKšœ;™;Kšœ!™!Kšœ0œ™=KšœB™BK˜—šœ œ˜K˜—š  œœœœœœ œ˜dKšœ5™5K˜—K˜š  œœ œ˜,K˜—š  œœ œ˜+K˜—š  œœ œ˜*Kšœ(™(KšœG™GK˜—š  œœ œ ˜1Kšœ,™,K˜—K˜š  œœ œ˜*K˜—š  œœ œ˜)K˜—š œœœœ˜BK˜—š  œœœœ˜8K˜—K˜š  œœ œ œ˜3K˜—š œœ œ œ˜4K˜—š  œœ œ œ˜AK˜—š  œœœ œ˜>K˜—K˜š  œœ œœ˜*K˜—š  œœ œœ˜-K˜—š œœ œœ˜%K˜——Kšœ˜—…—^ :