/***************************************************
All references to width are adjusted to width-1, this 
  is to prevent the bumping of the cursor to the next line,
  which causes ugly shifting effects. this could also be 
  done by leaving an extra row for the cursor to end up on,
  but rows are more valuble than columns.
 
***************************************************/
void DisplayFilter1::ReDraw ( void ) {

  int64_t LineCounter;
  char * LineBuff;
  int y;
  int64_t tpos;

  if (( LineBuff = new char[(Display->Width)+2] ) == NULL ) {
    printf("cannot allocate scroll buffer.\n");
    exit ( 0 ); // !!!???!!!  CHANGE THIS
  }

   Dataf.Seek(0, SEEK_SET); // rewind the data

  // select the line
//  contentfilter->SelectStart(contentfilter->seekline( ScrollLoc.Y ));

/*
    This gets interesting...
    to find the line, we have to trudge though a bunch of Nextline methods,
    and we have to be open to the possibility that the line were looking for 
    may not exist at all...
    I expect that within the next few years this will be replaced with
    a bookmark to hold our position, by then the accumulator will likley
    be streamable too...
*/
  tpos = 0; //preset
  for (y = ScrollLoc.Y; y != 0; y--) {
     if ((tpos = Dataf.NextLine()) != (-1)) {
       Dataf.SelectionStart(tpos);    
     } else {
       //printf("displayfilter:redraw  oops, sorry...\n");
     }
   }
  
   Dataf.SelectionEnd(Dataf.LineEnd());
  
   for (LineCounter = 0;  LineCounter < Display->Height; LineCounter++ ) {    
   
     // clear the line buffer
     memset(LineBuff, ' ', (Display->Width - 1)); // clears as it draws (much faster)

     // modify the buffer with whatever content
     if ((ScrollLoc.X < Dataf.SelectionSize()) & (tpos != (-1))) {    // selectionsize = linelength
       Dataf.SelectionStart( Dataf.SelectionStart() + ScrollLoc.X );  // offset to the scrollloc
       Dataf.Read( LineBuff, (Display->Width - 1));	
       LineBuff[Dataf.SelectionSize()] = ' ';                         // remove terminating null      	
     } 
     
     LineBuff[(Display->Width - 1)] = '\0';  // terminate
      
     // select next line 
     Dataf.SelectionStart(tpos = Dataf.NextLine());
     Dataf.SelectionEnd  (Dataf.LineEnd());   
	  /*
     Display->CursorPos ( 0, LineCounter + 1);
     Display->WriteText ( LineBuff );
	  */
     
     Display->BufferPos  (0, LineCounter + 1);
     Display->BufferText ( LineBuff, NULL );
     
   } // end of for
  
 Display->ReDraw();  
 delete[] LineBuff;

}
