home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_05 / 8n05049a < prev    next >
Text File  |  1990-04-18  |  863b  |  48 lines

  1. *****Listing 2*****
  2.  
  3. typedef int truth;
  4. const truth forever = 1;
  5. class Editor {
  6. public:
  7.         Editor( char *fname) : b( fname), 
  8.                                input(fname), output( "", "w")
  9.     {
  10.         filename = new char[strlen( fname) + 1];
  11.         strcpy( filename, fname);
  12.  
  13.         rp = ®
  14.     }
  15.  
  16.     void eval()
  17.     {
  18.         while( forever)
  19.             (this->*action[input.get()])();
  20.     }
  21.  
  22.     void go()     { rp->go( b, output); }
  23.  
  24.     void print()  { rp->print( b, output); }
  25.  
  26.     void insert() { rp->insert( b, input); }
  27.  
  28.     void del()    { rp->del( b, kbuf, output); }
  29.  
  30.     void put()    { rp->put( b, kbuf); }
  31.     
  32.     void quit()   { exit(0); }
  33.  
  34.     void eerror() { output.put( "?\n"); } // error function
  35.  
  36.     void donothing()    {}
  37. private:
  38.     Buffer b;
  39.     File input;
  40.     File output;
  41.  
  42.     Register Editor::*rp;
  43.     Register reg;
  44.     Iregister ireg;
  45.     Buffer kbuf;  // kill buffer
  46. };
  47.  
  48.