version 1.21, 2003/11/09 01:20:32 |
version 1.22, 2003/11/09 01:44:39 |
|
|
} |
} |
|
|
static __inline__ int |
static __inline__ int |
last_was_boundary(void) |
lastrectype(void) |
{ |
{ |
struct undo_rec *rec; |
struct undo_rec *rec; |
|
|
if ((rec = LIST_FIRST(&curwp->w_undo)) != NULL && |
if ((rec = LIST_FIRST(&curwp->w_undo)) != NULL) |
(rec->type == BOUNDARY)) |
return (rec->type); |
return (1); |
|
return (0); |
return (0); |
} |
} |
|
|
|
|
undo_enable(int on) |
undo_enable(int on) |
{ |
{ |
int pon = undo_disable_flag; |
int pon = undo_disable_flag; |
|
|
undo_disable_flag = (on == TRUE) ? 0 : 1; |
undo_disable_flag = (on == TRUE) ? 0 : 1; |
return (pon ? FALSE : TRUE); |
return (pon ? FALSE : TRUE); |
} |
} |
|
|
*/ |
*/ |
rec = LIST_FIRST(&curwp->w_undo); |
rec = LIST_FIRST(&curwp->w_undo); |
if (rec != NULL) { |
if (rec != NULL) { |
/* this will be hit like, 80% of the time... */ |
|
if (rec->type == BOUNDARY) |
|
rec = LIST_NEXT(rec, next); |
|
if (rec->type == INSERT) { |
if (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; |
|
|
memmove(&rec->region, ®, sizeof(REGION)); |
memmove(&rec->region, ®, sizeof(REGION)); |
rec->content = NULL; |
rec->content = NULL; |
|
|
if (!last_was_boundary()) |
if (lastrectype() != INSERT) |
undo_add_boundary(); |
undo_add_boundary(); |
|
|
LIST_INSERT_HEAD(&curwp->w_undo, rec, next); |
LIST_INSERT_HEAD(&curwp->w_undo, rec, next); |
undo_add_boundary(); |
|
|
|
return (TRUE); |
return (TRUE); |
} |
} |
|
|
|
|
region_get_data(®, rec->content, reg.r_size); |
region_get_data(®, rec->content, reg.r_size); |
|
|
|
if (lastrectype() != DELETE) |
|
undo_add_boundary(); |
|
|
LIST_INSERT_HEAD(&curwp->w_undo, rec, next); |
LIST_INSERT_HEAD(&curwp->w_undo, rec, next); |
undo_add_boundary(); |
|
|
|
return (TRUE); |
return (TRUE); |
} |
} |
|
|
struct undo_rec *ptr, *nptr; |
struct undo_rec *ptr, *nptr; |
int done, rval; |
int done, rval; |
LINE *lp; |
LINE *lp; |
int offset; |
int offset, save; |
|
|
ptr = curwp->w_undoptr; |
ptr = curwp->w_undoptr; |
|
|
|
|
* Loop while we don't get a boundary specifying we've |
* Loop while we don't get a boundary specifying we've |
* finished the current action... |
* finished the current action... |
*/ |
*/ |
|
|
|
if (lastrectype() != BOUNDARY) |
|
undo_add_boundary(); |
|
|
|
save = nobound; |
|
nobound = 1; |
|
|
done = 0; |
done = 0; |
do { |
do { |
/* Unlink the current node from the list */ |
|
nptr = LIST_NEXT(ptr, next); |
|
LIST_REMOVE(ptr, next); |
|
|
|
/* |
/* |
* Move to where this has to apply |
* Move to where this has to apply |
* |
* |
|
|
default: |
default: |
break; |
break; |
} |
} |
free_undo_record(ptr); |
|
|
|
/* And move to next record */ |
/* And move to next record */ |
ptr = nptr; |
ptr = LIST_NEXT(ptr, next); |
} while (ptr != NULL && !done); |
} while (ptr != NULL && !done); |
|
|
|
nobound = save; |
|
undo_add_boundary(); |
|
|
ewprintf("Undo!"); |
ewprintf("Undo!"); |
} |
} |