DIRECTORY TextEdit USING [CapChange], TextLooks USING [allLooks, Looks, noLooks], TextNode USING [Location, Node, nullLocation], UndoEvent USING [Event]; EditSpan: CEDAR DEFINITIONS = BEGIN Node: TYPE = TextNode.Node; Location: TYPE = TextNode.Location; nullLocation: Location = TextNode.nullLocation; Event: TYPE = UndoEvent.Event; Span: TYPE = RECORD [start, end: Location _ nullLocation]; nullSpan: Span = [nullLocation, nullLocation]; Looks: TYPE = TextLooks.Looks; noLooks: Looks = TextLooks.noLooks; allLooks: Looks = TextLooks.allLooks; ChangeLooks: PROC [root: Node, span: Span, remove, add: Looks, event: Event _ NIL]; AddLooks: PROC [root: Node, span: Span, add: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, noLooks, add, event] }; RemoveLooks: PROC [root: Node, span: Span, remove: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, remove, noLooks, event] }; SetLooks: PROC [root: Node, span: Span, new: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, allLooks, new, event] }; ClearLooks: PROC [root: Node, span: Span, event: Event _ NIL] = INLINE { ChangeLooks[root, span, allLooks, noLooks, event] }; Replace: PROC [destRoot, sourceRoot: Node, dest, source: Span, saveForPaste: BOOL _ TRUE, event: Event _ NIL] RETURNS [result: Span]; Delete: PROC [root: Node, del: Span, event: Event _ NIL, saveForPaste: BOOL _ TRUE]; SaveForPaste: PROC [span: Span, event: Event _ NIL]; SavedForPaste: PROC RETURNS [span: Span]; Place: TYPE = { before, after, sibling, child }; Copy: PROC [destRoot, sourceRoot: Node, dest: Location, source: Span, where: Place _ after, nesting: INTEGER _ 0, event: Event _ NIL] RETURNS [result: Span]; Move: PROC [destRoot, sourceRoot: Node, dest: Location, source: Span, where: Place _ after, nesting: INTEGER _ 0, event: Event _ NIL] RETURNS [result: Span]; MoveOnto: PROC [destRoot, sourceRoot: Node, dest, source: Span, saveForPaste: BOOL _ TRUE, event: Event _ NIL] RETURNS [result: Span]; Transpose: PROC [alphaRoot, betaRoot: Node, alpha, beta: Span, event: Event _ NIL] RETURNS [newAlpha, newBeta: Span]; Insert: PROC [root, old: Node, where: Place _ after, event: Event _ NIL] RETURNS [new: Node]; Inherit: PROC [old, new: Node, allprops: BOOL _ FALSE]; InsertTextNode: PROC [root, old: Node, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: Node]; Split: PROC [root: Node, loc: Location, event: Event _ NIL] RETURNS [new: Node]; Merge: PROC [root, node: Node, event: Event _ NIL] RETURNS [loc: Location]; ChangeNesting: PROC [root: Node, span: Span, change: INTEGER, event: Event _ NIL] RETURNS [new: Span]; Nest: PROC [root: Node, span: Span, event: Event _ NIL] RETURNS [new: Span] = INLINE { RETURN ChangeNesting[root, span, +1, event] }; UnNest: PROC [root: Node, span: Span, event: Event _ NIL] RETURNS [new: Span] = INLINE { RETURN ChangeNesting[root, span, -1, event] }; CapChange: TYPE = TextEdit.CapChange; ChangeCaps: PROC [root: Node, span: Span, how: CapChange _ allCaps, event: Event _ NIL]; AllCaps: PROC [root: Node, span: Span, event: Event _ NIL] = INLINE { ChangeCaps[root, span, allCaps, event] }; AllLower: PROC [root: Node, span: Span, event: Event _ NIL] = INLINE { ChangeCaps[root, span, allLower, event] }; InitialCaps: PROC [root: Node, span: Span, event: Event _ NIL] = INLINE { ChangeCaps[root, span, initCaps, event] }; NodeOrder: TYPE = { before, same, after, disjoint }; CompareNodeOrder: PROC [node1, node2: Node] RETURNS [order: NodeOrder]; CannotDoEdit: ERROR; afterMoved1, afterMoved2: Location; END. šEditSpan.mesa Copyright c 1985, 1986 by Xerox Corporation. All rights reserved. written by Bill Paxton, June 1981 last edit by Bill Paxton, October 13, 1982 2:22 pm last edit by Russ Atkinson, July 22, 1983 9:50 am Michael Plass, March 18, 1985 5:23:07 pm PST Doug Wyatt, September 5, 1986 2:51:51 pm PDT start.node can equal end.node in which case either both start.where and end.where = nodeItself, or neither does 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 Operations to add or delete looks first remove then add in the given span Editing operations on spans replace dest span by copy of source span result is the new copy of source result is last thing deleted or explicitly saved for Paste these are modifiers for the destination of a Move or Copy or Insert only apply when destination is an entire node (i.e., dest.where = nodeItself) place = before means insert as sibling before dest place = after means insert as sibling after dest; inherit children of dest place = sibling means insert as sibling after dest; don't inherit children of dest place = child means insert as first child of dest result is the new copy of source dest cannot be within source or get error BadMove result is moved span nesting is relative to dest e.g., where=after and nesting=1 makes source be child of dest like Replace, but moves source instead of copying it result is moved span alpha and beta must not overlap or get error BadTranspose newAlpha is new location of alpha span; ditto for newBeta New nodes; split & merge empty copy of old node is inserted in tree in position determined by "where" empty text node is inserted in tree inserts copy of loc.node is inserted directly before loc.node (as sibling) new adopts children of old (if any) if loc.where # nodeItself and loc.node is a text node, then text after loc.where moves to new node text before loc.where stays in old node returns the new node copies text of node to end of previous node then deletes node Nesting moves all nodes of span, even if don't have entire node selected moves span to a deeper nesting level in tree moves span to a shallower nesting level in tree Caps and Lowercase force specified span to all uppercase force specified span to all lowercase force first letter of words uppercase Miscellaneous determines relative order in tree of the nodes returns "same" if node1 = node2 returns "before" if node1 comes before node2 returns "after" if node1 comes after node2 returns "disjoint" if nodes are not from the same tree hints for repaint set by Move, MoveOnto, and Transpose gives pointers to locs after the moved spans ΚΤ˜codešœ ™ Kšœ Οmœ7™BKšœ!™!Kšœ2™2Kšœ1™1K™,K™,—K˜šΟk ˜ Jšœ žœ ˜Jšœ žœ˜+Jšœ žœ ˜.Jšœ žœ ˜—K˜KšΠblœžœž ˜šœž˜K˜Kšœžœ˜Kšœ žœ˜#Kšœ/˜/Kšœžœ˜K˜šœžœžœ'˜:šœ™KšœD™DKšœ)™)—šœ8™8Kšœ™Kšœ+™+—K˜—K˜.—headšœ!™!Kšœžœ˜K˜#K˜%K˜šΟn œžœ=žœ˜SKšœ'™'K˜—š œžœ5žœ˜GKšœžœ2˜:K˜—š  œžœ8žœ˜MKšœžœ5˜=K˜—š œžœ5žœ˜GKšœžœ3˜;K˜—š  œžœ)žœ˜=Kšœžœ7˜?K˜——šœ™š  œžœAžœžœžœžœ˜‡Kšœ(™(Kšœ ™ K˜—K˜š  œžœ(žœžœžœ˜TK˜—š  œžœžœ˜4K˜—š  œžœžœ˜)Kšœ:™:K˜—K˜šœžœ%˜0KšœC™CKšœM™MKšœ2™2KšœJ™JKšœR™RKšœ1™1K˜—š  œžœ\žœžœžœ˜ŸKšœ ™ K˜—š  œžœ\žœžœžœ˜ŸKšœ1™1Kšœ™šœ™Kšœ=™=K˜——K˜š  œžœAžœžœžœžœ˜ˆKšœ4™4Kšœ™K˜—š  œžœ@žœžœ˜vKšœ9™9Kšœ9™9K˜——šœ™š œžœ8žœžœ ˜]KšœL™LK˜—š œžœžœžœ˜7K˜—K˜š  œžœ3žœžœžœžœ ˜}Kšœ#™#K˜—š œžœ,žœžœ ˜PšœJ™JKšœ#™#—šœ;™;Kšœ&™&Kšœ'™'—Kšœ™K˜—š œžœ#žœžœ˜KKšœ+™+Kšœ™K˜——šœ™š   œžœ"žœžœžœ ˜gKšœA™AK˜—š œžœ)žœžœ ˜KKšœžœžœ(˜9Kšœ,™,K˜—š œžœ)žœžœ ˜MKšœžœžœ(˜9Kšœ/™/K˜——šœ™šœ žœ˜%K˜—š  œžœCžœ˜XK˜—š œžœ)žœ˜:Kšœžœ,˜4Kšœ%™%K˜—š œžœ)žœ˜;Kšœžœ-˜5Kšœ%™%K˜—š  œžœ)žœ˜>Kšœžœ-˜5Kšœ%™%K˜——šœ ™ šœ žœ%˜4K™—š œžœžœ˜GKšœ.™.Kšœ™Kšœ,™,Kšœ*™*Kšœ6™6K˜—K˜Kšœžœ˜K˜˜#Kšœ6™6Kšœ,™,K˜——K˜Kšžœ˜—…—„