FeedbackOps.mesa
Copyright Ó 1988, 1990 by Xerox Corporation. All rights reserved.
Bier, August 23, 1989 10:16:56 am PDT
Last tweaked by Mike Spreitzer on May 3, 1990 9:40:14 am PDT
Contents: Setting Feedback handlers that manipulate Viewers objects.
DIRECTORY Feedback, IO, Rope, ViewerClasses;
FeedbackOps: CEDAR DEFINITIONS = BEGIN
Copied Types
Viewer: TYPE = ViewerClasses.Viewer;
MsgType: TYPE = Feedback.MsgType;
MsgClass: TYPE = Feedback.MsgClass;
MsgRouter: TYPE = Feedback.MsgRouter;
MsgHandler: TYPE = Feedback.MsgHandler;
Named typescripts
CreateNamedTypescript: PROC [headerText: Rope.ROPE, typescriptName: ATOM, openHeight: NAT ← 120, storing: BOOLFALSE] RETURNS [alreadyExists: BOOL, typescript: Viewer];
Open a new typescript with the headerText in its black strip. Register it under name. The typescript is returned so that the client can later destroy it, if desired. If a (working) typescript of this name already exists, no new typescript is made and alreadyExists = TRUE. If storing, the typescript henceforth (until directed otherwise) remembers its output, so that if the typescript is later destroyed and then re-created, the old output can be re-produced.
CreateTypescriptFromStream: PROC [stream: IO.STREAM, typescriptName: ATOM, storing: BOOLFALSE] RETURNS [alreadyExists: BOOL, oldStream: IO.STREAM];
Like CreateNamedTypescript, but lets you provide your own stream instead of using ViewerIO to make one. If this stream is ever closed, output to this typescriptName will stop appearing until CreateTypescriptFromStream is called again to provide a fresh stream. If alreadyExists = TRUE, oldStream is the value of the old stream. The new stream is put in its place.
GetTypescripts: PROC [] RETURNS [names: LIST OF ATOM];
Lists all of the named typescripts that were created by CreateNamedTypescript above.
GetTypescriptStream: PROC [typescriptName: ATOM] RETURNS [IO.STREAM];
Returns the output stream that goes to typescript typescriptName.
Our two-headed handlers
This interface provides MsgHandlers that can output to one, both, or neither of two places: (1) a label (either the MessageWindow or a Viewer created through the Labels interface), and (2) a named typescript. For output to a label, the handler is told whether or not to blink the label on each text output operation.
Although the facilies for creating such handlers are presented next, most clients can use the convenience procendures that follow, which operate directly on MsgRouters.
messageWindow: READONLY Viewer;
CreateViewersHandler: PROC [typescriptName: ATOM ← $None, label: Viewer ← NIL, blink: BOOLFALSE] RETURNS [MsgHandler];
Creates a new two-headed handler, and initializes it; it may be redirected later.
typescriptName=$None => no output to any named typescript.
typescriptName#$None => output goes to that named typescript, if it exists at the moment of output.
label=NIL => no output to any label.
label=messageWindow => output goes to the MessageWindow.
label is from Labels => output goes to that label.
blink <=> label is blinked when text is output to it.
IsViewersHandler: PROC [MsgHandler] RETURNS [is: BOOL, typescriptName: ATOM ← $None, label: Viewer ← NIL, blink: BOOLFALSE];
Reports whether the given handler is one of ours.
HandleToLabel: PROC [vh: MsgHandler, label: Viewer, blink: BOOLFALSE];
Redirects the label head of the given handler, which must be a Viewers handler.
HandleToTypescript: PROC [vh: MsgHandler, typescriptName: ATOM ← $None];
Redirects the typescript head of the given handler, which must be a Viewers handler.
Wiring up a MsgRouter to specific Viewers output streams
SetLabel: PROC [router: MsgRouter, label: Viewer, blink: BOOLFALSE, msgClass: MsgClass ← $Every];
Direct output to (router, msgClass) to a label (possibly in addition to a typescript). If blink is TRUE, the label will be blinked when messages of msgClass are received.
If label=NIL, no output will be sent to a label when msgClass messages are received.
SetMultiLabel: PROC [router: MsgRouter, label: Viewer, blink: BOOLFALSE, msgClasses: LIST OF ATOM];
Like SetLabel, but sets the label for several specific message classes at once.
SetMessageWindow: PROC [router: MsgRouter, blink: BOOLFALSE, msgClass: MsgClass ← $Every];
= {SetLabel[router, messageWindow, blink, msgClass]};
SetMultiMessageWindow: PROC [router: MsgRouter, blink: BOOLFALSE, msgClasses: LIST OF ATOM];
Like SetMessageWindow, but sets the label for several specific message classes at once.
SetTypescript: PROC [router: MsgRouter, typescriptName: ATOM ← $None, msgClass: MsgClass ← $Every];
Direct output to (router, msgClass) to a typescript (possibly in addition to a label or the MessageWindow). If typescriptName=$None, no output will be sent to a typescript when msgClass messages are received.
SetMultiTypescript: PROC [router: MsgRouter, typescriptName: ATOM ← $None, msgClasses: LIST OF ATOM];
Like SetTypescript, but sets the typescript for several specific message classes at once.
CreateSimpleRouter: PROC [label: Viewer, blink: BOOLFALSE, typescriptName: ATOM] RETURNS [router: MsgRouter];
For convenience. Equivalent to CreateRouter[], SetLabel[...$Every], SetTypescript[...$Every].
CreateMultiRouter: PROC [label: Viewer, blink: BOOLFALSE, labelClasses: LIST OF ATOM, typescriptName: ATOM, typescriptClasses: LIST OF ATOM] RETURNS [router: MsgRouter];
For convenience. Equivalent to CreateRouter[], SetMultiLabel, SetMultiTypescript.
Queries on routers (mostly for debugging)
GetLabel: PROC [router: MsgRouter, msgClass: MsgClass ← $Default] RETURNS [label: Viewer, blink: BOOLFALSE];
Get the label that router is using when messages of msgClass are received. If msgClass = $Default, return the label that is used when a message is received for a message class that is has no special label assigned to it. If label=messageWindow, the Cedar Message Window is being used.
GetTypescriptName: PROC [router: MsgRouter, msgClass: MsgClass ← $Default] RETURNS [typescriptName: ATOM];
Get the typescript name that router is using when messages of msgClass are received. If msgClass = $Default, return the typescript that is used when a message is received for a message class that is has no special typescript assigned to it.
END.