EditSpanSupport.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
written by Bill Paxton, June 1981
last edit by Bill Paxton, 17-Feb-82 9:53:04
last edit by Russ Atkinson, July 22, 1983 9:53 am
Michael Plass, March 14, 1985 12:24:06 pm PST
Doug Wyatt, September 10, 1986 6:35:56 pm PDT
DIRECTORY
EditSpan USING [NodeOrder, Place, Span],
TextNode USING [Location, MaxLen, Node, nodeItself],
UndoEvent USING [Event];
EditSpanSupport: CEDAR DEFINITIONS
= BEGIN
Node: TYPE = TextNode.Node;
MaxLen: INT = TextNode.MaxLen;
Location: TYPE = TextNode.Location;
nodeItself: INT = TextNode.nodeItself;
Event: TYPE = UndoEvent.Event;
Span: TYPE = EditSpan.Span;
Place: TYPE ~ EditSpan.Place;
NodeOrder: TYPE ~ EditSpan.NodeOrder;
Slice: TYPE = REF SliceArray;
SliceArray: TYPE = RECORD [
next: Slice, -- for free list
length: NAT ← 0,
nodes: SEQUENCE maxLength: NAT OF Node
];
SliceKind: TYPE = { before, after };
GetSlice: PROC [len: NAT] RETURNS [slice: Slice];
FreeSlice: PROC [slice: Slice];
SliceLength: PROC [slice: Slice] RETURNS [NAT]
= INLINE { RETURN [slice.length] };
SliceNode: PROC [slice: Slice, index: NAT] RETURNS [Node]
= INLINE { RETURN [slice[index]] };
LastOfSlice: PROC [slice: Slice] RETURNS [Node]
= INLINE { RETURN [slice[slice.length-1]] };
KindOfSlice: PROC [slice: Slice] RETURNS [SliceKind]
= INLINE { RETURN [IF slice[0]#NIL THEN before ELSE after] };
Splice: PROC [before, after: Slice, beforeStart, afterStart: NAT ← 0];
ReplaceBand: PROC [before, after, top, bottom: Slice, nesting: INTEGER];
BadBand: ERROR;
DescribeBand: PROC [first, last: Node] RETURNS [before, after, top, bottom: Slice, nesting: INTEGER, depth: NAT];
DeletePrefix: PROC [slice: Slice, depth: NAT];
DestSlices: PROC [dest: Node, where: Place] RETURNS [before, after: Slice, nesting: INTEGER];
CreateDest: PROC [depth: NAT] RETURNS [dest: Location];
CopySpan: PROC [span: Span] RETURNS [result: Span];
NeededNestingChange: TYPE = { needNest, needUnNest, ok };
NeedNestingChange: PROC [before, after, top, bottom: Slice,
nesting: INTEGER, depth: NAT] RETURNS [NeededNestingChange];
CompareSliceOrder: PROC [s1, s2: Slice] RETURNS [order: NodeOrder];
DoSplits: PROC [alpha, beta: Span, event: Event]
RETURNS
[Span, Span];
DoSplits2: PROC [dest: Location, source: Span, where: Place, nesting: INTEGER, event: Event]
RETURNS
[Location, Span, Place, INTEGER];
UndoSplits: PROC [alpha, beta: Span, event: Event]
RETURNS
[Span, Span];
UndoSplits2: PROC [dest: Location, source: Span, event: Event]
RETURNS
[Location, Span];
ReMerge: PROC [alpha, beta: Span, merge: Node, event: Event, tail: BOOLFALSE]
RETURNS
[Span, Span];
SliceOrder: PROC [alpha, beta: Span, aBefore, aBottom, bBefore, bBottom: Slice]
RETURNS
[overlap: BOOL, head, tail: Span, startOrder, endOrder: NodeOrder];
ApplyProc: TYPE = PROC [node: Node, start, len: INT] RETURNS [stop: BOOL];
Apply: PROC [span: Span, proc: ApplyProc];
NodeSpan: PROC [span: Span] RETURNS [Span]
= INLINE { RETURN[[[span.start.node, nodeItself], [span.end.node, nodeItself]]] };
NodeLoc: PROC [loc: Location] RETURNS [Location]
= INLINE { RETURN [[loc.node, nodeItself]] };
ForwardLoc: PROC [loc: Location] RETURNS [new: Location];
BackLoc: PROC [loc: Location] RETURNS [new: Location];
END.