<> <> <> <> 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] = { branch _ TiogaOps.FirstChild[indexHandle.rootIndexBranch]; }; IndexVersionStamp: PUBLIC PROCEDURE [rope: ROPE] RETURNS [stamp: ROPE] = { array: ARRAY [0..4) OF CARDINAL _ ALL[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.