TEditDocumentRopeImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Bill Paxton. March 31, 1983
last written by Paxton. March 31, 1983 9:22 am
Doug Wyatt, March 3, 1985 4:12:16 pm PST
DIRECTORY
Rope USING [Fetch, MakeRope, ROPE, Size],
TextNode,
TEditDocumentRope USING [];
TEditDocumentRopeImpl: CEDAR PROGRAM
IMPORTS Rope, TextNode
EXPORTS TEditDocumentRope
= BEGIN
Fetch:
PROC [data:
REF, index:
INT]
RETURNS [
CHAR] = {
doc: TextNode.Ref ← NARROW[data];
loc: TextNode.Location = TextNode.LocRelative[[doc,0], index];
n: TextNode.RefTextNode = TextNode.NarrowToTextNode[loc.node];
IF n=NIL THEN ERROR;
IF loc.where >= Rope.Size[n.rope] THEN RETURN ['\n];
RETURN [Rope.Fetch[n.rope, loc.where]]
};
Create:
PUBLIC
PROC [doc: TextNode.Ref]
RETURNS [r: Rope.
ROPE] = {
docSize: INT = TextNode.LocOffset[[doc,0], TextNode.LastLocWithin[doc]];
RETURN[Rope.MakeRope[base: doc, size: docSize, fetch: Fetch]];
};
END.