version 1.28, 2005/10/06 16:48:00 |
version 1.29, 2005/10/11 01:08:53 |
|
|
{ |
{ |
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); |
|
|
{ |
{ |
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); |
} |
} |
|
|
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); |
} |
} |
|
|
/* |
/* |
* 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; |
|
|
|
|
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); |
} |
} |
|
|
|
|
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... |
|
|
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); |
} |
} |
|
|
} |
} |
|
|
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), |
|
|
|
|
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; |
} |
} |
|
|
|
|
* 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); |
} |
} |