DIRECTORY BasicTime USING [Now], Commander USING [CommandProc, Register], CommandTool USING [DoCommandRope, NextArgument], Convert USING [Error, IntFromRope, RopeFromInt, RopeFromTime], MessageWindow USING [Append], NodeProps USING [GetProp, PutProp], Rope USING [Equal, ROPE, Size], TextLooks USING [CreateRun], TextNodeRegistry USING [ActivityOn, ActivityProc, ProcSetRec, Ref, Register, SizeProc, TransformProc]; ActiveSampler: CEDAR PROGRAM IMPORTS BasicTime, Commander, CommandTool, Convert, MessageWindow, NodeProps, Rope, TextLooks, TextNodeRegistry ~ BEGIN CommandTransform: TextNodeRegistry.TransformProc = { node.rope _ CommandTool.DoCommandRope[commandLine: node.rope, parent: NIL].out; node.runs _ TextLooks.CreateRun[Rope.Size[node.rope]]; NodeProps.PutProp[node, $Active, NIL]; -- make node inactive RETURN[node]; }; MaxTransform: TextNodeRegistry.TransformProc = { max: INT _ 0; FOR n: TextNodeRegistry.Ref _ node.child, n.next WHILE n#node DO i: INT; i _ Convert.IntFromRope[n.rope ! Convert.Error => {i _ -1; CONTINUE}]; max _ MAX[i, max]; ENDLOOP; node.rope _ Convert.RopeFromInt[max]; node.runs _ TextLooks.CreateRun[Rope.Size[node.rope]]; RETURN[node]; }; CurrentTimeTransform: TextNodeRegistry.TransformProc = { node.rope _ Convert.RopeFromTime[BasicTime.Now[]]; node.runs _ TextLooks.CreateRun[Rope.Size[node.rope]]; RETURN[node]; }; ActivityProc: Commander.CommandProc = { arg: Rope.ROPE = CommandTool.NextArgument[cmd]; SELECT TRUE FROM Rope.Equal[s1: arg, s2: "on", case: FALSE] => { [] _ TextNodeRegistry.ActivityOn[NIL, TRUE]; msg _ "Tioga activity turned on"; }; Rope.Equal[s1: arg, s2: "off", case: FALSE] => { [] _ TextNodeRegistry.ActivityOn[NIL, FALSE]; msg _ "Tioga activity turned off"; }; ENDCASE => msg _ "usage: ActiveTioga on/off"; }; TextNodeRegistry.Register[activity: $CurrentTime, procs: NEW[TextNodeRegistry.ProcSetRec _ [activityOn: TRUE, transformProc: CurrentTimeTransform]]]; TextNodeRegistry.Register[activity: $Max, procs: NEW[TextNodeRegistry.ProcSetRec _ [activityOn: TRUE, transformProc: MaxTransform]]]; TextNodeRegistry.Register[activity: $Command, procs: NEW[TextNodeRegistry.ProcSetRec _ [activityOn: TRUE, transformProc: CommandTransform]]]; Commander.Register[key: "ActiveTioga", proc: ActivityProc, doc: "turn ActiveTioga on/off"]; END.  ActiveSampler.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Doug Terry, July 9, 1987 9:58:59 am PDT A sampling of transformations for active Tioga nodes. Active=Activity ActivityTransform: TextNodeRegistry.TransformProc = { [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref] body }; ActivitySize: TextNodeRegistry.SizeProc = { [node: TextNode.Ref, clientData: REF ANY] RETURNS [size: INT] body }; ActivityActive: TextNodeRegistry.ActivityProc = { [on: BOOLEAN, clientData: REF ANY] body }; Active=Command [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref] Active=Max [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref] Active=CurrentTime [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref] Toggling activity [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] Registrations TextNodeRegistry.Register[activity: $Activity, procs: NEW[TextNodeRegistry.ProcSetRec _ [activityOn: TRUE, transformProc: ActivityTransform, sizeProc: ActivitySize, activityProc: ActivityActive]]]; ΚΙ˜codešœ™Kšœ<™Kšœœ ˜Kšœ œ˜#Kšœœœ˜Kšœ œ ˜KšœœP˜f—K˜KšΠbl œœ˜Kšœh˜oKšœ˜headšœΟtœŸ™•StartOfExpansions -- [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref]šΟnœ$™7Kš œ6œœœœ™oK–-[message: ROPE, clearFirst: BOOL _ FALSE]šŸœŸ™K™K™—–A -- [node: TextNode.Ref, clientData: REF ANY] RETURNS [size: INT]š œ™-Kš œ!œœœœ™=K–-[message: ROPE, clearFirst: BOOL _ FALSE]šŸœŸ™K™K™—–& -- [on: BOOLEAN, clientData: REF ANY]š œ#™3Kšœœœœ™"K–-[message: ROPE, clearFirst: BOOL _ FALSE]šŸœŸ™K™——šœ™–s -- [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref]š œ$˜4Kš œ6œœœœ™oK–I[commandLine: ROPE _ NIL, in: ROPE _ NIL, parent: Commander.Handle]šœFœ˜OK˜6Kšœ!œΟc˜=Kšœ˜ K˜K™——šœ ™ –s -- [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref]š  œ$˜0KšΟso™oK–-[message: ROPE, clearFirst: BOOL _ FALSE]šœœ˜ šœ.œ˜@Kšœœ˜Kšœ;œ˜FKšœœ ˜Kšœ˜—K–B[from: INT, base: Convert.Base _ 10, showRadix: BOOL _ TRUE]šœ%˜%K˜6Kšœ˜ K˜——™–s -- [node: TextNode.Ref, parent: TextNode.Ref, wantFirst: BOOLEAN, clientData: REF ANY] RETURNS [new: TextNode.Ref]š œ$˜8KšΠcko™oK–-[message: ROPE, clearFirst: BOOL _ FALSE]šœ2˜2K˜6Kšœ˜ K˜——™–L -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]š  œ˜'Kš œœ œœœœœ™HKšœ œ!˜/šœœ˜–-[s1: ROPE, s2: ROPE, case: BOOL _ TRUE]šœ$œ˜/Kšœ!œœ˜,K˜!K˜—–-[s1: ROPE, s2: ROPE, case: BOOL _ TRUE]šœ%œ˜0Kšœ!œœ˜-K˜"K˜—Kšœ&˜-—K˜——™ K–5[activity: ATOM, procs: TextNodeRegistry.ProcSet]š œ%ŸœŸœ œ,œb™ΝK™K–5[activity: ATOM, procs: TextNodeRegistry.ProcSet]šœ9œ,œ)˜•K–5[activity: ATOM, procs: TextNodeRegistry.ProcSet]šœ1œ,œ!˜…K–5[activity: ATOM, procs: TextNodeRegistry.ProcSet]šœ5œ,œ%˜K˜K˜[K™—Kšœ˜—…—όΟ