-- File: ViewersIO.mesa
--   Teitelman on  May 28, 1982 9:23 pm

DIRECTORY
	Rope, IO, TypeScript, ViewerClasses;
		
ViewerIO:   DEFINITIONS  =

BEGIN

CreateViewerStreams: PROC [name: Rope.ROPE, viewer: ViewerClasses.Viewer ← NIL, backingFile: Rope.ROPE ← NIL]
	RETURNS [in: IO.STREAM, out: IO.STREAM]; 
  -- If viewer is non-NIL, creats two IOs, one for input, one for output, and "connects" them to the indicated viewer. Viewer must be of viewerclass TypeScript or raises RTTypesBasic.NarrowRefFault. If viewer is NIL, creates a Viewer of class TypeScript with name name, and proceeds as above.  If backingFile is non-NIL, creates a file stream on this file (using overWrite semantics), then creates a dribble stream which outputs to the out and dribbles to the file stream, flushing every 256 characters, i.e. out ← IO.CreateDribbleStream[stream: out, dribbleTo: CreateFileStream[backingFile, overWrite], flushEveryNChars: 256]
 
  -- N.B. It is perfectly permissible to have more than one output stream connected to the same viewer. However, if two input IOs are connected to the same viewer and a character is typed, only one of the streams will get the character.
  
END.