EditSpan.mesa
Copyright Ó 1985, 1986, 1991, 1992 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, February 26, 1992 12:10 pm PST
DIRECTORY
Tioga USING [CapChange, Event, Location, Looks, Node, noLooks, nullLocation, nullSpan, Order, Place, Span];
EditSpan: CEDAR DEFINITIONS ~ BEGIN
Node: TYPE = Tioga.Node;
Location: TYPE = Tioga.Location;
nullLocation: Location = Tioga.nullLocation;
Span: TYPE = Tioga.Span;
nullSpan: Span = Tioga.nullSpan;
Event: TYPE = Tioga.Event;
Operations to add or delete looks
Looks: TYPE = Tioga.Looks;
noLooks: Looks = Tioga.noLooks;
ChangeLooks: PROC [root: Node, span: Span, remove, add: Looks ¬ noLooks,
event: Event ¬ NIL];
first remove then add in the given span
Editing operations on spans
Replace: PROC [destRoot, sourceRoot: Node, dest, source: Span,
saveForPaste: BOOL ¬ TRUE, event: Event ¬ NIL] RETURNS [result: Span];
replace dest span by copy of source span
result is the new copy of source
Delete: PROC [root: Node, del: Span, event: Event ¬ NIL, saveForPaste: BOOL ¬ TRUE];
SaveForPaste: PROC [span: Span, event: Event ¬ NIL];
SavedForPaste: PROC RETURNS [span: Span];
result is last thing deleted or explicitly saved for Paste
Place: TYPE = Tioga.Place; -- { before, after, sibling, child }
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
Copy: PROC [destRoot, sourceRoot: Node, dest: Location, source: Span,
where: Place ¬ after, nesting: INTEGER ¬ 0,
event: Event ¬ NIL] RETURNS [result: Span];
result is the new copy of source
Move: PROC [destRoot, sourceRoot: Node, dest: Location, source: Span,
where: Place ¬ after, nesting: INTEGER ¬ 0,
event: Event ¬ NIL] RETURNS [result: Span];
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
MoveOnto: PROC [destRoot, sourceRoot: Node, dest, source: Span,
saveForPaste: BOOL ¬ TRUE,
event: Event ¬ NIL] RETURNS [result: Span];
like Replace, but moves source instead of copying it
result is moved span
Transpose: PROC [alphaRoot, betaRoot: Node, alpha, beta: Span,
event: Event ¬ NIL] RETURNS [newAlpha, newBeta: 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
Insert: PROC [root, old: Node, where: Place ¬ after, event: Event ¬ NIL] RETURNS [new: Node];
empty copy of old node is inserted in tree in position determined by "where"
Inherit: PROC [old, new: Node, allprops: BOOL ¬ FALSE];
InsertTextNode: PROC [root, old: Node, where: Place ¬ after,
inherit: BOOL ¬ FALSE, event: Event ¬ NIL] RETURNS [Node];
empty text node is inserted in tree
Split: PROC [root: Node, loc: Location, event: Event ¬ NIL] RETURNS [new: Node];
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
Merge: PROC [root, node: Node, event: Event ¬ NIL] RETURNS [loc: Location];
copies text of node to end of previous node
then deletes node
Nesting
ChangeNesting: PROC [root: Node, span: Span, change: INTEGER,
event: Event ¬ NIL] RETURNS [new: Span];
moves all nodes of span, even if don't have entire node selected
Nest: PROC [root: Node, span: Span, event: Event ¬ NIL] RETURNS [new: Span]
= INLINE { new ¬ ChangeNesting[root, span, +1, event] };
moves span to a deeper nesting level in tree
UnNest: PROC [root: Node, span: Span, event: Event ¬ NIL] RETURNS [new: Span]
= INLINE { new ¬ ChangeNesting[root, span, -1, event] };
moves span to a shallower nesting level in tree
Caps and Lowercase
CapChange: TYPE = Tioga.CapChange;
ChangeCaps: PROC [root: Node, span: Span, how: CapChange ¬ allCaps, event: Event ¬ NIL];
Miscellaneous
Order: TYPE = Tioga.Order; -- { before, same, after, disjoint };
NodeOrder: TYPE = Order; -- for compatibility
CompareNodeOrder: PROC [node1, node2: Node] RETURNS [Order];
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
CompareLocOrder: PROC [loc1, loc2: Location] RETURNS [Order];
determines relative order of locations
CannotDoEdit: ERROR;
afterMoved1, afterMoved2: Location;
hints for repaint set by Move, MoveOnto, and Transpose
gives pointers to locs after the moved spans
END.