DIRECTORY IO USING [STREAM], Rope USING [ROPE], ViewerClasses USING [Viewer]; ViewerIO: CEDAR DEFINITIONS = BEGIN STREAM: TYPE ~ IO.STREAM; ROPE: TYPE ~ Rope.ROPE; Viewer: TYPE ~ ViewerClasses.Viewer; CreateViewerStreams: PROC [name: ROPE, viewer: Viewer _ NIL, backingFile: ROPE _ NIL, editedStream: BOOL _ TRUE ] RETURNS [in: STREAM, out: STREAM]; GetViewerFromStream: PROC [stream: STREAM] RETURNS [Viewer]; CreateMessageWindowStream: PROC RETURNS [STREAM]; GetBuffer: PROC [editedViewerStream: STREAM] RETURNS [REF TEXT]; TypeChars: PROC [editedViewerStream: STREAM, chars: ROPE]; END. fViewerIO.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Paul Rovner, November 29, 1983 8:31 am MBrown, December 16, 1983 4:36 pm Doug Wyatt, March 4, 1985 9:48:49 am PST 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: , echoTo: out]. Otherwise, out is established as an echo stream for in via EditedStream.SetEcho[in, out]. If stream was created by CreateViewerStreams, this returns the corresponding viewer, otherwise it returns NIL. 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[]} Obtain current buffer contents from editedViewerStream. Simulate typing the characters chars to the keyboard behind the given edited viewer stream. The stream's DeliverWhenProc sees the chars transmitted by TypeChars, unlike calling EditedStream.AppendBufferChars. ʘcodešœ ™ Kšœ Ïmœ1™