CreateViewerStreams:
PROC
[name: ROPE, viewer: Viewer ← NIL, backingFile: ROPE ← NIL, editedStream: BOOL ← TRUE]
RETURNS [in: STREAM, out: STREAM];
If viewer is NIL, viewer ← a new (non-iconic) TypeScript Viewer with the given name.
If viewer is non-NIL, raise IO.Error[$Failure, NIL] if not TypeScript.IsATypeScript[viewer].
Create two streams: one for input, one for output, and store name as $Name on the property list of each of these. If backingFile is non-NIL, specify FS.StreamOpen[backingFile, $create] as the backingStream for out.
The new output stream has endOf, putBlock, putChar, flush, and eraseChar operations. endOf will raise IO.Error[StreamClosed] if the typescript has been destroyed, otherwise it always returns FALSE. putBlock calls putChar in a loop. putChar, flush and eraseChar use their TypeScript counterparts (TypeScript.BackSpace is used by flush) and raise IO.Error[StreamClosed] if the typescript has been destroyed. The 'l PFCodeProc for out will use TypeScript.ChangeLooks (see IOUtils.PFCodeProc and friends).
A new input stream with endOf, charsAvail, and getChar operations is created. endOf behaves as above. charsAvail will raise IO.Error[StreamClosed] if the typescript has been destroyed, otherwise it will invoke either TypeScript.WaitUntilCharsAvail or TypeScript.CharsAvailable, depending on the wait argument. The integer returned by charsAvail will always be either 0 or 1. Like putChar, getChar uses its TypeScript counterpart and raises IO.Error[StreamClosed] if the typescript has been destroyed. out is established as an `echo stream' for in; this means that each character returned by in.GetChar will be passed to out.PutChar (see SetEcho, below).
If editedStream is TRUE, in = EditedStream.Create[in: <the new input stream>, echoTo: out]. Otherwise, out is established as an echo stream for in via EditedStream.SetEcho[in, out].
CreateMessageWindowStream:
PROC
RETURNS [
STREAM];
This stream has flush and reset operations and a backingStream created by IO.ROS[]. Flush causes characters output to the stream (derived from self.backingStream.RopeFromROS[]) to be displayed in the message window via MessageWindow.Append[message: r, clearFirst: TRUE]. Reset is simply {self.backingStream.Reset[]; MessageWindow.Clear[]}