Listing 5 (region.cpp) Screen Region Package

#include "region.h"
region::region(int x0, int y0, int x1, int y1, int save)
      {
      left=x0;
      top=y0;
      right=x1;
      bot=y1;
      buf=NULL;
      if (save)
             reinit();
      }

void region::reinit(void)
      {
      if (buf) delete buf;
      buf=new char[2*(1+right-left)*(1+bot-top)];
      gettext(left,top,right,bot,buf);
      }

void region::restore(void)
      {
      if (buf)
             {
             puttext(left,top,right,bot,buf);
             destroy();
             }
      }


region::~region()
      {
      restore();
      }

void region::destroy(void)
      {
      if (buf)
             {
             delete buf;
             buf=NULL;
             }
 }

// End of File