IndexToolPrivateImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Rick Beach, July 12, 1983 1:54 pm
Rick Beach, February 27, 1985 9:44:43 pm PST
DIRECTORY
Basics USING [BITXOR, Comparison],
IndexProperties,
IndexTree USING [IndexEntryCompare],
IndexToolPrivate,
IndexViewer,
IO,
OrderedSymbolTableRef USING [CreateTable],
Rope,
TEditScrolling,
TextNode USING [Body, Ref],
TiogaOps USING [FirstChild],
TiogaOpsDefs USING [],
ViewerClasses USING [Viewer],
ViewerTools USING [FindExistingViewer, MakeNewTextViewer];
IndexToolPrivateImpl: CEDAR PROGRAM
IMPORTS Basics, IndexProperties, IndexTree, IndexViewer, IO, OrderedSymbolTableRef, Rope, TEditScrolling, TiogaOps, ViewerTools
EXPORTS TiogaOpsDefs, IndexToolPrivate
= BEGIN OPEN IndexToolPrivate;
ROPE: TYPE = Rope.ROPE;
Comparison: TYPE = Basics.Comparison;
NodeBody: PUBLIC TYPE = TextNode.Body;
CreateIndexFromDocument: PUBLIC PROCEDURE [documentName: ROPE]
RETURNS [indexHandle: IndexHandle] = {
documentViewer: ViewerClasses.Viewer ← ViewerTools.FindExistingViewer[documentName];
IF documentViewer = NIL THEN
documentViewer ← ViewerTools.MakeNewTextViewer[info: [
name: documentName,
file: documentName]];
indexHandle ← CreateIndexFromViewer[documentViewer];
};
CreateIndexFromViewer: PUBLIC PROCEDURE [documentViewer: ViewerClasses.Viewer]
RETURNS [indexHandle: IndexHandle] = {
indexHandle ← IndexViewer.NewTool[documentViewer.name];
indexHandle.documentViewer ← documentViewer;
indexHandle.indexTable ← OrderedSymbolTableRef.CreateTable[compareProc: IndexTree.IndexEntryCompare];
IndexProperties.ScanIndexProperties[documentViewer, indexHandle];
TEditScrolling.ScrollToPosition[indexHandle.indexViewer, [indexHandle.rootIndexBranch, 0]];
};
SupplyTiogaBranch: PUBLIC PROCEDURE [indexHandle: IndexHandle]
RETURNS [branch: TextNode.Ref] = {
branchTiogaOps.FirstChild[indexHandle.rootIndexBranch];
};
IndexVersionStamp: PUBLIC PROCEDURE [rope: ROPE] RETURNS [stamp: ROPE] = {
array: ARRAY [0..4) OF CARDINALALL[0];
i: CARDINAL;
xorRopeChar: Rope.ActionType = TRUSTED {
array[i] ← Basics.BITXOR[array[i], LOOPHOLE[c]];
i ← (i + 1) MOD 4;
};
i ← 0;
[] ← Rope.Map[base: rope, start: 0, len: LAST[INT], action: xorRopeChar];
stamp ← IO.PutFR["%h%h%h%h", IO.card[array[0]], IO.card[array[1]], IO.card[array[2]], IO.card[array[3]]];
};
END.