home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / WWW / LYNX / SOURCE / SRC0_8A.ZIP / DOSLYNX / SRC / TCAPTUR2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.8 KB  |  61 lines

  1. //    Copyright (c) 1994, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TCapture
  4. //    Include File:    tcapture.h
  5. //    Purpose:    Captures c streams stdout and sterr to a window.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //        Works in conjuction with the c source file capstdio.c and
  8. //        two global variables capstdout and capstderr in globals.c
  9. //    Revision History:
  10. //        01-08-94    created
  11. //        02-09-94    Split all members into seperate files.
  12. #define Uses_otstream
  13. #include"tcapture.h"
  14.  
  15. TCapture::TCapture(TRect TR, const char *cp_title, unsigned short int
  16.     usi_bufsize) :
  17.     TWindowInit(TCapture::initFrame),
  18.     TWindow(TR, cp_title, 0)    {
  19. //    Purpose:    Constructor of the TCapture object.
  20. //    Arguments:    TR        The rectangle to occupy.
  21. //            cp_title    The title of the window.
  22. //            usi_bufsize    The size of the buffer for the dumb
  23. //                    terminal.
  24. //    Remarks/Portability/Dependencies/Restrictions:
  25. //    Revision History:
  26. //        01-08-94    created
  27. //        08-09-94    Modified to send output to NUL if not needed.
  28.  
  29.     //    Set out palette to that of a message window.
  30.     palette = wpCyanWindow;
  31.  
  32.     //    Get the size of the window.
  33.     //    Create the terminal.
  34.     TR = getExtent();
  35.     TR.grow(-1, -1);
  36.  
  37.     if(B_noInfo == FALSE)    {
  38.         TT = new TTerminal(TR, NULL, standardScrollBar(sbVertical |
  39.             sbHandleKeyboard), usi_bufsize);
  40.         insert(TT);
  41.  
  42.         otstream ot(TT);
  43.         DumbStream = ot;
  44.     }
  45.     else    {
  46.         //    Warning, serious DOS/C++ hack coming!!!
  47.         //    We are not sending the output anywhere if they don't
  48.         //    want to see it set by the B_noInfo global, so to
  49.         //    avoid making two different binary versions, we hack
  50.         //    below to assign the same functionality but output
  51.         //    is going absolutely nowhere.
  52.  
  53.         //    Open up the NUL device.
  54.         filebuf *fb = new filebuf();
  55.         fb->open("NUL", ios::out);
  56.  
  57.         //    Assign the stream.
  58.         ostream os(fb);
  59.         DumbStream = os;
  60.     }
  61. }