writewin(r1,c1,r2,c2,row, col, str, attr, retrace)
int r1,c1,r2,c2;
int row, col;
char *str;
int  attr, retrace;
{
   int   c;

   if ((row < r1) || (row > r2) )
      return;

   while (col < c1)
   {
      col++; str++;
   }

   while (c = *str++)
   {
      switch (c)
      {
         case  '\n' :
                      col = c1;
                      if (++row > r2)
                         scrollwin(1,r1,c1,r2,c2,attr);
                      break;
         case  '\t' :
                      {
                         int i = col % 8;

                         while ( (i <= 8) && (col <= c2) )
                         {
                            vputc(row, col++, ' ', attr, retrace);
                            i++;
                         }
                      }
                      break;
         default    :
                      if (col <= c2)
                         vputc(row, col++, c, attr, retrace);
      }
   }
}
