TextNodeRegistry.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Doug Terry, June 26, 1987 2:58:55 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
TextNode USING [Ref];
TextNodeRegistry: CEDAR DEFINITIONS
~ BEGIN
Ref: TYPE ~ TextNode.Ref;
TransformProc: TYPE ~ PROC [node: Ref, parent: Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: Ref];
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: Ref, 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: BOOLEANFALSE,
transformProc: TransformProc ← NIL,
transformProcData: REF ANYNIL,
sizeProc: SizeProc ← NIL,
sizeProcData: REF ANYNIL,
activityProc: ActivityProc ← NIL,
activityProcData: REF ANYNIL];
Register: PROC [activity: ATOM, procs: ProcSet] RETURNS [];
The given TransformProc will hereafter be applied to all nodes having an active property with value=activity.
UnRegister: PROC [activity: ATOM] RETURNS [];
Removes the procedures associated with the given activity.
GetProcs: PROC[activity: ATOM] RETURNS [procs: ProcSet];
Return the procedures associated with the given activity.
ActivityOn: PROC [activity: ATOM, on: BOOLEANTRUE] 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.
DoTransform: PROC [activity: ATOM, node: Ref, parent: Ref ← NIL, wantFirst: BOOLEANTRUE] RETURNS [new: Ref];
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: Ref] 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.