[BACK]Return to undo.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/undo.c between version 1.28 and 1.29

version 1.28, 2005/10/06 16:48:00 version 1.29, 2005/10/11 01:08:53
Line 155 
Line 155 
 {  {
         struct undo_rec *rec;          struct undo_rec *rec;
   
         rec = LIST_END(&curwp->w_undo);          rec = LIST_END(&curbp->b_undo);
         if (rec != NULL) {          if (rec != NULL) {
                 undo_free_num--;                  undo_free_num--;
                 LIST_REMOVE(rec, next);                  LIST_REMOVE(rec, next);
Line 170 
Line 170 
 {  {
         struct undo_rec *rec;          struct undo_rec *rec;
   
         if ((rec = LIST_FIRST(&curwp->w_undo)) != NULL)          if ((rec = LIST_FIRST(&curbp->b_undo)) != NULL)
                 return (rec->type);                  return (rec->type);
         return (0);          return (0);
 }  }
Line 205 
Line 205 
         rec = new_undo_record();          rec = new_undo_record();
         rec->type = BOUNDARY;          rec->type = BOUNDARY;
   
         LIST_INSERT_HEAD(&curwp->w_undo, rec, next);          LIST_INSERT_HEAD(&curbp->b_undo, rec, next);
   
         return (TRUE);          return (TRUE);
 }  }
Line 228 
Line 228 
         /*          /*
          * We try to reuse the last undo record to `compress' things.           * We try to reuse the last undo record to `compress' things.
          */           */
         rec = LIST_FIRST(&curwp->w_undo);          rec = LIST_FIRST(&curbp->b_undo);
         if (rec != NULL && rec->type == INSERT) {          if (rec != NULL && rec->type == INSERT) {
                 if (rec->pos + rec->region.r_size == pos) {                  if (rec->pos + rec->region.r_size == pos) {
                         rec->region.r_size += reg.r_size;                          rec->region.r_size += reg.r_size;
Line 247 
Line 247 
   
         undo_add_boundary();          undo_add_boundary();
   
         LIST_INSERT_HEAD(&curwp->w_undo, rec, next);          LIST_INSERT_HEAD(&curbp->b_undo, rec, next);
   
         return (TRUE);          return (TRUE);
 }  }
Line 273 
Line 273 
   
         if (offset == llength(lp))      /* if it's a newline... */          if (offset == llength(lp))      /* if it's a newline... */
                 undo_add_boundary();                  undo_add_boundary();
         else if ((rec = LIST_FIRST(&curwp->w_undo)) != NULL) {          else if ((rec = LIST_FIRST(&curbp->b_undo)) != NULL) {
                 /*                  /*
                  * Separate this command from the previous one if we're not                   * Separate this command from the previous one if we're not
                  * just before the previous record...                   * just before the previous record...
Line 300 
Line 300 
         if (lastrectype() != DELETE)          if (lastrectype() != DELETE)
                 undo_add_boundary();                  undo_add_boundary();
   
         LIST_INSERT_HEAD(&curwp->w_undo, rec, next);          LIST_INSERT_HEAD(&curbp->b_undo, rec, next);
   
         return (TRUE);          return (TRUE);
 }  }
Line 352 
Line 352 
         }          }
   
         num = 0;          num = 0;
         for (rec = LIST_FIRST(&curwp->w_undo); rec != NULL;          for (rec = LIST_FIRST(&curbp->b_undo); rec != NULL;
             rec = LIST_NEXT(rec, next)) {              rec = LIST_NEXT(rec, next)) {
                 num++;                  num++;
                 snprintf(buf, sizeof(buf),                  snprintf(buf, sizeof(buf),
Line 422 
Line 422 
   
         dot = find_dot(curwp->w_dotp, curwp->w_doto);          dot = find_dot(curwp->w_dotp, curwp->w_doto);
   
         ptr = curwp->w_undoptr;          ptr = curbp->b_undoptr;
   
         /* if we moved, make ptr point back to the top of the list */          /* if we moved, make ptr point back to the top of the list */
         if ((ptr == NULL && nulled == TRUE) || curwp->w_undopos != dot) {          if ((ptr == NULL && nulled == TRUE) || curbp->b_undopos != dot) {
                 ptr = LIST_FIRST(&curwp->w_undo);                  ptr = LIST_FIRST(&curbp->b_undo);
                 nulled = TRUE;                  nulled = TRUE;
         }          }
   
Line 513 
Line 513 
          * Record where we are. (we have to save our new position at the end           * Record where we are. (we have to save our new position at the end
          * since we change the dot when undoing....)           * since we change the dot when undoing....)
          */           */
         curwp->w_undoptr = ptr;          curbp->b_undoptr = ptr;
   
         curwp->w_undopos = find_dot(curwp->w_dotp, curwp->w_doto);          curbp->b_undopos = find_dot(curwp->w_dotp, curwp->w_doto);
   
         return (rval);          return (rval);
 }  }

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29