-- EditSpanSupport.mesa
-- written by Bill Paxton, June 1981
-- last edit by Bill Paxton, 17-Feb-82 9:53:04
DIRECTORY
EditSpan,
TextLooks,
TextNode,
EditNotify,
UndoEvent;
EditSpanSupport: CEDAR DEFINITIONS
IMPORTS TextLooks =
BEGIN
OPEN EditSpan;
Ref: TYPE = TextNode.Ref;
RefTextNode: TYPE = TextNode.RefTextNode;
RefOtherNode: TYPE = TextNode.RefOtherNode;
Offset: TYPE = TextNode.Offset;
MaxLen: Offset = LAST[Offset];
Location: TYPE = TextNode.Location;
nullLocation: Location = TextNode.nullLocation;
Span: TYPE = TextNode.Span;
nullSpan: Span = TextNode.nullSpan;
Event: TYPE = UndoEvent.Ref;
NodeItself: Offset = TextNode.NodeItself;
-- ***** Declarations
Slice: TYPE = REF SliceArray;
SliceArray: TYPE = RECORD [
next: Slice, -- for free list
kind: OfSlice, -- before/after
length: NAT ← 0,
nodes: SEQUENCE maxLength: NAT OF Ref
];
OfSlice: TYPE = { before, after };
-- ***** Operations
GetSlice: PROC [len: NAT] RETURNS [slice: Slice];
FreeSlice: PROC [slice: Slice];
SliceLength: PROC [slice: Slice] RETURNS [length: NAT] = INLINE { RETURN [slice.length] };
SliceNode: PROC [slice: Slice, index: NAT] RETURNS [Ref] = INLINE {
RETURN [slice[index]] };
LastOfSlice: PROC [slice: Slice] RETURNS [Ref] = INLINE {
RETURN [slice[slice.length-1]] };
Splice: PROC [before, after: Slice, beforeStart, afterStart: NAT ← 0];
ReplaceBand: PROC [before, after, top, bottom: Slice, nesting: INTEGER, event: Event];
BadBand: ERROR;
DescribeBand: PROC [first, last: Ref]
RETURNS [before, after, top, bottom: Slice, nesting: INTEGER, depth: NAT];
DeletePrefix: PROC [slice: Slice, depth: NAT];
DestSlices: PUBLIC PROC [dest: Ref, where: Place]
RETURNS [before, after: Slice, nesting: INTEGER];
CreateDest: PROC [depth: NAT] RETURNS [dest: Location];
CopySpan: PROC [span: Span] RETURNS [result: Span];
CheckBeforeMove: PROC [dest: Location, source: Span, where: Place] RETURNS [ok: BOOLEAN];
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: PUBLIC PROC [dest: Location, source: Span, event: Event]
RETURNS [Location, Span];
ReMerge: PROC [alpha, beta: Span, merge: Ref, event: Event, tail: BOOLEANFALSE]
RETURNS [Span, Span];
SliceOrder: PROC [alpha, beta: Span, aBefore, aBottom, bBefore, bBottom: Slice]
RETURNS [overlap: BOOLEAN, head, tail: Span, startOrder, endOrder: NodeOrder];
FixWordSpans: PROC [alpha, beta: Span, event: Event]
RETURNS [newAlpha, newBeta: Span];
ApplyProc: TYPE = PROC [node: RefTextNode, start, len: Offset] RETURNS [stop: BOOLEAN];
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]] };
BackLoc, ForwardLoc: PROC [loc: Location] RETURNS [new: Location];
END.