DIRECTORY RefTab USING [Create, Delete, EachPairAction, Fetch, Pairs, Ref, Store], Rope USING [Size], TextNodeRegistry; TextNodeRegistryImpl: CEDAR PROGRAM IMPORTS RefTab, Rope EXPORTS TextNodeRegistry ~ BEGIN Ref: TYPE ~ TextNodeRegistry.Ref; ProcSet: TYPE ~ TextNodeRegistry.ProcSet; registrationTable: RefTab.Ref = RefTab.Create[]; Register: PUBLIC PROC [activity: ATOM, procs: ProcSet] RETURNS [] ~ { [] _ RefTab.Store[registrationTable, activity, procs]; }; UnRegister: PUBLIC PROC [activity: ATOM] RETURNS [] ~ { [] _ RefTab.Delete[registrationTable, activity]; }; GetProcs: PUBLIC PROC[activity: ATOM] RETURNS [procs: ProcSet] ~ { RETURN[NARROW[RefTab.Fetch[registrationTable, activity].val]]; }; ActivityOn: PUBLIC PROC [activity: ATOM, on: BOOLEAN _ TRUE] RETURNS [wasOn: BOOLEAN] ~ { SetActivity: RefTab.EachPairAction = { procs: TextNodeRegistry.ProcSet = NARROW[val]; IF procs#NIL THEN { wasOn _ procs.activityOn; procs.activityOn _ on; IF wasOn#on AND procs.activityProc#NIL THEN procs.activityProc[on, procs.activityProcData]; }; }; wasOn _ FALSE; IF activity#NIL THEN [] _ SetActivity[activity, RefTab.Fetch[registrationTable, activity].val] ELSE [] _ RefTab.Pairs[registrationTable, SetActivity]; }; DoTransform: PUBLIC PROC [activity: ATOM, node: Ref, parent: Ref _ NIL, wantFirst: BOOLEAN _ TRUE] RETURNS [new: Ref] ~ { procs: TextNodeRegistry.ProcSet = NARROW[RefTab.Fetch[registrationTable, activity].val]; new _ IF procs=NIL OR NOT procs.activityOn OR procs.transformProc=NIL THEN node ELSE procs.transformProc[node, parent, wantFirst, procs.transformProcData]; }; GetSize: PUBLIC PROC [activity: ATOM, node: Ref] RETURNS [size: INT] ~ { procs: TextNodeRegistry.ProcSet = NARROW[RefTab.Fetch[registrationTable, activity].val]; size _ IF procs=NIL OR NOT procs.activityOn OR procs.sizeProc=NIL THEN Rope.Size[node.rope] ELSE procs.sizeProc[node, procs.sizeProcData]; }; END. ςTextNodeRegistryImpl.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Doug Terry, June 26, 1987 7:09:38 pm PDT The given TransformProc will hereafter be applied to all nodes having an active property with value=activity. Removes the procedures associated with the given activity. Return the procedures associated with the given activity. Determines whether or not the registered transformations should be currently applied; if activity=NIL then activity is turned on/off for all registered clients. Registered clients are informed via callbacks when this switch is toggled so they can take appropriate action. [key: RefTab.Key, val: RefTab.Val] RETURNS [quit: BOOL _ FALSE] Force the TransformProc associated with the given activity to be applied to the node. (This is intended primarily for use by TextNodeImpl.) Computes or estimates the size that the given node will be AFTER it is transformed by the specified activity. (This is intended primarily for use by TextNodeImpl.) Κ5˜codešœ™Kšœ<™K˜J™—šŸ œœœ œœœœ œ˜YKšœbœ«™•StartOfExpansionC -- [key: RefTab.Key, val: RefTab.Val] RETURNS [quit: BOOL _ FALSE]šŸ œ˜&KšΟs#Πks ‘ ‘ ™?Kšœ"œ˜.šœœœ˜Kšœ˜Kšœ˜šœ œœ˜+Kšœ/˜/—K˜—K˜—Kšœœ˜šœ ˜KšœJ˜NKšœ3˜7—K˜K™—šŸ œœœ œœ œœœ˜yKšœŒ™ŒKšœ"œ0˜XKšœœœœœœœœœG˜›K˜K™—š Ÿœœœ œ œœ˜HKšœ€™€Kšœ"œ0˜XKšœœœœœœœœœ*˜ŠK˜—J˜—Kšœ˜—…—n•