Preliminary notes on  CONSTREAM
Copyright 1990 by John M. Dlugosz

Enclosed is this note, the header CONSTREA.H, and the object code
for small model CONSTREA.OBJ, and a demo program/example CONTEST.CPP.

This is being presented to get feedback so I can complete the project.
More notes to follow.

--------

There are two streams, coni and cono.  They work for input and output
respectivly and use the conio library.

You can mix <conio.h> functions with the constream functions.  Most
will be in the constream though so that will not be needed.  It does let
you use existing code though.  Just make sure you flush before calling
other code.

All the formatted and unformatted IO and manipulators work for these
streams.  that is the whole idea.

There are some differences though.  I need to add various flags that can
effect emulation of cin/cout or other modes.  Let me know what you would
like.  In particular, the conio functions treat \n as a linefeed instead
of a newline.

Some of the conio behavor may not be what is liked using this system.  Once
I get ideas of what is wanted, I can adjust it.

A particular problem is the meaning of RETURN.  The conio stuff will wait
until you press RETURN before proceeding.  That is just what cin does though.
I have added functions to get "live" keys from coni.

   char getch();  //does not wait for CR
   char getche(); //same as above, with echo
   conistream& eatws();  //skip whitespace allready typed,
      //but does not get more input from user

There are several functions that are members of both con streams.  They
are exactly like the CONIO functions, but take care of other housework,
in partucular buffering.

   void gotoxy (int, int);
   void cls();  //clear screen
   void clreol();  //clear to end of line
   void delline(); //delete a line
   void insline(); //insert a line

Several are available as manipulators as well.

Buffering
---------

The sterams are buffered.  You can flush the output by using the flush
member of cono, or the flush manipulator, as with any stream.  This is
rarely needed though.  There is a "tie" between coni and cono, so whenever
input is requested the output is flushed automaticlly.  In addition, the
functions to move the cursor etc. all flush first.

You would want to flush if you are printing stuff while computing something
length, and want the display to show progress, for example.  That way the
display would keep up with the real time of the output.  If you find yourself
needing to flush, try using "unit buffering".  Setting this flag with
   cono.setf (ios::unitbuf)
will cause the buffer to be flushed after each insertion.  That makes it
as if unbuffered, but does not flush after every character as a true
unbuffered device would be.  This is off by default because it makes things
more efficient for long formatting statements.



Caveats
--------

Consider the line:

   cono << "\r\n" << clreol << "you typed " << '[' << s << ']';

the clreol manipulator is used in the middle of an expression.  This does
not work.  The manipulators for conio stuff only works on the coniostreams,
and I seem to have outsmarted myself here.  The first term, outputting the
"\r\n" string, returns cono in preperation for the next term, but it returns
it typed as a plain ostream and not as a conostream.  Oh well.  Should I
have clreol and the like work on _any_ stream, blindly clearing the screen
even if I send it to a file?  Or at least check to see if I sent it to a
con stream?


I also plan to add a flag that will echo the \n when you type RETURN, as
part of the cin/cout emulation modes.

