TextNodeRegistry.mesa
Copyright Ó 1987, 1991 by Xerox Corporation. All rights reserved.
Doug Terry, July 28, 1988 5:04:37 pm PDT
Don Baker, May 27, 1988 1:44:55 pm PDT
Doug Wyatt, October 8, 1991 4:49 pm PDT
Transformations on text nodes can be registered to provide for a rudimentary type of "active" Tioga document. These transformations are done by Tioga on demand, that is, registered transformation procedures are called at the time that a node with the "Active" property is to be returned to clients of TextNode (the value of the "Active" property identifies the activity to be performed).
The rules regarding legal transformations are as follows:
— A node may transform into one or more sibling nodes,
— A node may not be deleted by a transformation,
— The transformation procedure is responsible for making any necessary changes in the document tree, i.e. reestablishing proper child and next links for new nodes; these changes must obey the previous two rules,
— An active node may transform into another active node, however, in this case, the new active node may been seen by clients; the transformation on it will not occur until the next time the node is requested.
DIRECTORY
Tioga USING [Node];
TextNodeRegistry: CEDAR DEFINITIONS ~ BEGIN
Node: TYPE ~ Tioga.Node;
TransformProc: TYPE ~ PROC [node: Node, parent: Node, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: Node];
Performs a transformation on the given node and returns the resulting node. If the transformation results in more than one new node then the first new node is returned if wantFirst=TRUE, otherwise the last new node is returned.
SizeProc: TYPE ~ PROC [node: Node, clientData: REF ANY] RETURNS [size: INT];
Computes or estimates the size that the given node will be AFTER it is transformed.
ActivityProc: TYPE ~ PROC [on: BOOLEAN, clientData: REF ANY] RETURNS [];
Informs clients whether or not the registered transformations should be currently applied.
ProcSet: TYPE = REF ProcSetRec;
ProcSetRec: TYPE = RECORD[
activityOn: BOOLEAN ¬ FALSE,
transformProc: TransformProc ¬ NIL,
transformProcData: REF ANY ¬ NIL,
sizeProc: SizeProc ¬ NIL,
sizeProcData: REF ANY ¬ NIL,
activityProc: ActivityProc ¬ NIL,
activityProcData: REF ANY ¬ NIL];
Register: PROC [activity: ATOM, procs: ProcSet] RETURNS [];
The given TransformProc will hereafter be applied to all nodes having an active property with value=activity. Notification procedures are invoked accordingly.
UnRegister: PROC [activity: ATOM] RETURNS [];
Removes the procedures associated with the given activity. Notification procedures are invoked accordingly.
GetProcs: PROC[activity: ATOM] RETURNS [procs: ProcSet];
Return the procedures associated with the given activity.
ActivityOn: PROC [activity: ATOM, on: BOOLEAN ¬ TRUE] RETURNS [wasOn: BOOLEAN];
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. Notification procedures are called accordingly.
IsActivityOn: PROC [activity: ATOM] RETURNS [isOn: BOOLEAN];
Returns true if the activity specified is on.
NotifyProc: TYPE ~ PROC [handle: REF ANY, activity: ATOM, nowOn: BOOLEAN] RETURNS [];
Notifies client of an addition, deletion, or status change in the list of registered activities.
NotifySet: TYPE = REF NotifySetRec;
NotifySetRec: TYPE = RECORD[
registrationNotify: NotifyProc ¬ NIL,
unRegistrationNotify: NotifyProc ¬ NIL,
activityOnNotify: NotifyProc ¬ NIL];
NotificationRegister: PROC[handle: REF ANY, notifyProcs: NotifySet] RETURNS [];
Registers a set of notification procedures which are called both in the event of a change in activity registration or status *and* during this call, notification will be given of the "registration" of those activities which are already registered. Note that handle serves as a unique key for the registration.
NotificationUnRegister: PROC[handle: REF ANY, doNotify: BOOLEAN ¬ FALSE] RETURNS [];
Unregisters a set of notification procedures. If doNotify is true, notification of the "unregistration" of registered activities will be made during this call.
DoTransform: PROC [activity: ATOM, node: Node, parent: Node ¬ NIL, wantFirst: BOOLEAN ¬ TRUE] RETURNS [new: Node];
Force the TransformProc associated with the given activity to be applied to the node. (This is intended primarily for use by TextNodeImpl.)
GetSize: PROC [activity: ATOM, node: Node] RETURNS [size: INT];
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.)
END.