FeedbackClasses.mesa
Copyright Ó 1986, 1990 by Xerox Corporation. All rights reserved.
Bier, August 23, 1989 7:06:25 pm PDT
Pier, October 23, 1987 3:20:56 pm PDT
Last tweaked by Mike Spreitzer on May 3, 1990 7:20:21 am PDT
Contents: Various kinds of MsgHandlers, and connectivity between MsgRouter, MsgHandler, and IO.STREAM.
DIRECTORY Feedback, FeedbackTypes, IO, Rope, SimpleFeedback;
FeedbackClasses: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE ~ Rope.ROPE;
MsgType: TYPE = SimpleFeedback.MsgType;
MsgClass: TYPE = SimpleFeedback.MsgClass;
MsgRouter: TYPE = REF MsgRouterObj;
MsgRouterObj: TYPE = FeedbackTypes.MsgRouterObj;
MsgHandler: TYPE ~ REF MsgHandlerObj;
MsgHandlerObj: TYPE ~ Feedback.MsgHandlerObj;
CreateHandler: PROC
[
PutF: PROC [mh: MsgHandler, msgType: MsgType, msgClass: MsgClass, format: ROPE, v1, v2, v3, v4, v5: IO.Value ← [null[]] ],
ClearHerald: PROC [mh: MsgHandler, msgClass: MsgClass],
Blink: PROC [mh: MsgHandler, msgClass: MsgClass],
data: REF ANYNIL]
RETURNS [MsgHandler];
This is a general-purpose facility that most clients will not need to use, because they can usually get what they need from the specific kinds of handlers provided below and in other interfaces.
The class procs usually have no need for the MsgClass, but it's there for completeness. The class procs can get that data by calling the following:
GetHandlerData: PROC [MsgHandler] RETURNS [REF ANY];
doNothing: READONLY MsgHandler;
All its operations are no-ops.
CreateHandlerOnRouter: PROC [MsgRouter] RETURNS [MsgHandler];
Operations on the handler are implemented by operations on the router.
IsHandlerOnRouter: PROC [MsgHandler] RETURNS [is: BOOL, router: MsgRouter];
Reveals whether the given handler is the result of CreateHandlerOnRouter.
CreateSplittingHandler: PROC [h1, h2: MsgHandler] RETURNS [MsgHandler];
Each operation on the result is implemented by that operation on each of the arguments.
IsSplittingHandler: PROC [MsgHandler] RETURNS [is: BOOL, h1, h2: MsgHandler];
Reveals whether the given handler is a splitter.
CreateHandlerOnStream: PROC [to: IO.STREAM, nlAsap: BOOL, Blink: PROC [IO.STREAM, MsgClass] ← NIL] RETURNS [MsgHandler];
If nlAsap, a newline is output as soon as an end or oneLiner is output; otherwise, the newline is delayed until the next line begins to be output. If Blink=NIL, then this handler's Blink is a no-op. This handler's ClearHerald is a no-op.
SendAsciiBell: PROC [IO.STREAM, MsgClass];
A plausible Blink proc.
IsHandlerOnStream: PROC [MsgHandler] RETURNS [is: BOOL, to: IO.STREAM, nlAsap: BOOL, Blink: PROC [IO.STREAM, MsgClass]];
CreateStoringHandler: PROC [buffsize: INTINT.LAST] RETURNS [MsgHandler];
Creates a handler that simply stores its messages (forgetting msgClass), up to a given number of characters, after which it simply discards output. ClearHerald and Blink are no-ops.
IsStoringHandler: PROC [MsgHandler] RETURNS [is: BOOL, buffsize: INT];
GetStore: PROC [from: MsgHandler] RETURNS [msgs: LIST OF ROPE, lastIsComplete: BOOL];
from is a storing handler. Please don't side-effect result.
lastIsComplete=typeBreaksAt[latest msgType].end when msgs#NIL.
PlayStore: PROC [from, to: MsgHandler, withClass: MsgClass, thenClear: BOOL];
from is a storing handler. All past messages are played. Messages are played with the given class.
handleByProblem: READONLY MsgHandler;
Raises Problem with each output string; ClearHerald and Blink are no-ops.
CreateStreamOnRouter: PROC [msgRouter: MsgRouter, msgClass: MsgClass] RETURNS [IO.STREAM];
Linebreaks sent to this stream become message boundaries. Except that %-Value pairs are sent through uninterpreted.
IsStreamOnRouter: PROC [IO.STREAM] RETURNS [is: BOOL, msgRouter: MsgRouter, msgClass: MsgClass];
END.