version 1.23, 2003/11/29 17:28:40 |
version 1.24, 2003/12/15 00:00:12 |
|
|
/* |
/* |
* Local functions |
* Local functions |
*/ |
*/ |
static int find_absolute_dot(LINE *, int); |
static int find_dot(LINE *, int); |
static int find_line_offset(int, LINE **, int *); |
static int find_lo(int, LINE **, int *); |
static struct undo_rec *new_undo_record(void); |
static struct undo_rec *new_undo_record(void); |
static int drop_oldest_undo_record(void); |
static int drop_oldest_undo_record(void); |
|
|
/* |
/* |
* find_{absolute_dot,line_offset}() |
* find_dot, find_lo() |
* |
* |
* Find an absolute dot in the buffer from a line/offset pair, and vice-versa. |
* Find an absolute dot in the buffer from a line/offset pair, and vice-versa. |
* |
* |
|
|
*/ |
*/ |
|
|
static int |
static int |
find_absolute_dot(LINE *lp, int off) |
find_dot(LINE *lp, int off) |
{ |
{ |
int count = 0; |
int count = 0; |
LINE *p; |
LINE *p; |
|
|
} |
} |
|
|
static int |
static int |
find_line_offset(int pos, LINE **olp, int *offset) |
find_lo(int pos, LINE **olp, int *offset) |
{ |
{ |
LINE *p; |
LINE *p; |
|
|
|
|
reg.r_offset = offset; |
reg.r_offset = offset; |
reg.r_size = size; |
reg.r_size = size; |
|
|
pos = find_absolute_dot(lp, offset); |
pos = find_dot(lp, offset); |
|
|
/* |
/* |
* We try to reuse the last undo record to `compress' things. |
* We try to reuse the last undo record to `compress' things. |
|
|
reg.r_offset = offset; |
reg.r_offset = offset; |
reg.r_size = size; |
reg.r_size = size; |
|
|
pos = find_absolute_dot(lp, offset); |
pos = find_dot(lp, offset); |
|
|
if (offset == llength(lp)) /* if it's a newline... */ |
if (offset == llength(lp)) /* if it's a newline... */ |
undo_add_boundary(); |
undo_add_boundary(); |
|
|
LINE *lp; |
LINE *lp; |
int offset, save, dot; |
int offset, save, dot; |
|
|
dot = find_absolute_dot(curwp->w_dotp, curwp->w_doto); |
dot = find_dot(curwp->w_dotp, curwp->w_doto); |
|
|
ptr = curwp->w_undoptr; |
ptr = curwp->w_undoptr; |
|
|
|
|
* Move to where this has to apply |
* Move to where this has to apply |
* |
* |
* Boundaries are put as position 0 (to save |
* Boundaries are put as position 0 (to save |
* lookup time in find_absolute_dot) so we must |
* lookup time in find_dot) so we must |
* not move there... |
* not move there... |
*/ |
*/ |
if (ptr->type != BOUNDARY) { |
if (ptr->type != BOUNDARY) { |
if (find_line_offset(ptr->pos, &lp, |
if (find_lo(ptr->pos, &lp, |
&offset) == FALSE) { |
&offset) == FALSE) { |
ewprintf("Internal error in Undo!"); |
ewprintf("Internal error in Undo!"); |
rval = FALSE; |
rval = FALSE; |
|
|
*/ |
*/ |
curwp->w_undoptr = ptr; |
curwp->w_undoptr = ptr; |
|
|
curwp->w_undopos = find_absolute_dot(curwp->w_dotp, curwp->w_doto); |
curwp->w_undopos = find_dot(curwp->w_dotp, curwp->w_doto); |
|
|
return (rval); |
return (rval); |
} |
} |