IndexNotifyImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Rick Beach, July 12, 1983 5:47 pm
Rick Beach, February 27, 1985 9:55:20 pm PST
DIRECTORY
IndexNotify,
IndexToolPrivate,
OrderedSymbolTableRef,
Rope,
TEditDocument,
TEditMouseImpl,
TEditSelection,
TextNode,
TiogaOps,
TiogaOpsDefs,
TIPUser,
ViewerClasses,
ViewerOps;
IndexNotifyImpl: CEDAR PROGRAM
IMPORTS OrderedSymbolTableRef, Rope, TEditMouseImpl, TEditSelection, TiogaOps, ViewerOps
EXPORTS IndexNotify, TiogaOpsDefs
SHARES TEditMouseImpl
= BEGIN OPEN IndexToolPrivate;
ROPE: TYPE = Rope.ROPE;
NodeBody: PUBLIC TYPE = TextNode.Body;
IndexNotifier: PUBLIC ViewerClasses.NotifyProc = {
indexHandle: IndexHandle ← NARROW[ViewerOps.FetchProp[self, $IndexHandle], IndexHandle];
indexSelection: TEditDocument.Selection ← TEditSelection.Create[];
mouse: TIPUser.TIPScreenCoords;
FOR list: LIST OF REF ANY ← input, list.rest UNTIL list = NIL DO
WITH list.first SELECT FROM
x: ATOM => SELECT x FROM
$Feedback => TRUSTED {
Call TEditMouseImpl.ResolveToChar to get Tioga location
rightOfLine: BOOLEAN ← TEditMouseImpl.ResolveToChar[
indexSelection,
indexHandle.indexViewer,
NARROW[indexHandle.indexViewer.data, TEditDocument.TEditDocumentData],
mouse.mouseX,
mouse.mouseY];
selection info returned in indexSelection.start.pos as TextNode.Location
back up the tree from indexSelection.start.pos.node accumulating phrases
ix: IndexEntry ← NEW[IndexEntryRec];
item: OrderedSymbolTableRef.Item;
smallerItem, equalItem, largerItem: OrderedSymbolTableRef.Item;
phrases: LIST OF ROPENIL;
node: TextNode.Ref ← indexSelection.start.pos.node;
WHILE node # NIL AND node # indexHandle.rootIndexBranch DO
nodeRope: ROPE ← TiogaOps.GetRope[node];
phrase: ROPE ← Rope.Substr[nodeRope, 0, Rope.Index[nodeRope, 0, ","]];
IF phrase = NIL OR phrase.Length = 0 THEN EXIT;
phrases ← CONS[phrase, phrases];
node ← TiogaOps.Parent[node];
ENDLOOP;
lookup the phrases for next larger or equal
ix.phrases ← phrases;
[smallerItem, equalItem, largerItem] ← OrderedSymbolTableRef.Lookup3[indexHandle.indexTable, ix];
use item as the ix item for feedback
item ← IF equalItem # NIL THEN equalItem ELSE IF largerItem # NIL THEN largerItem ELSE smallerItem;
Make selection node reverse video
ix ← NARROW[item, IndexEntry];
TiogaOps.SetSelection[
viewer: indexHandle.indexViewer,
start: [ix.branchLocationStart.node, ix.branchLocationStart.where],
end: [ix.branchLocationEnd.node, ix.branchLocationEnd.where],
level: word,
caretBefore: TRUE,
pendingDelete: TRUE,
which: feedback];
};
$Hit => {
Turn off reverse video
TiogaOps.CancelSelection[feedback];
Determine which IndexEntry corresponds to the hit
and Process.Detach[FORK indexButtonProcs[which one]]
};
ENDCASE => NULL;
z: TIPUser.TIPScreenCoords => {
mouse ← z;
mouse.mouseY ← self.ch - mouse.mouseY;
};
ENDCASE => ERROR;
ENDLOOP;
};
END.