version 1.34, 2005/11/18 17:11:21 |
version 1.35, 2005/11/18 20:56:53 |
|
|
/* |
/* |
* Local functions |
* Local functions |
*/ |
*/ |
static int find_dot(LINE *, int); |
static int find_dot(struct line *, int); |
static int find_lo(int, LINE **, int *); |
static int find_lo(int, struct 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); |
|
|
|
|
* need to have an absolute dot to have something reliable. |
* need to have an absolute dot to have something reliable. |
*/ |
*/ |
static int |
static int |
find_dot(LINE *lp, int off) |
find_dot(struct line *lp, int off) |
{ |
{ |
int count = 0; |
int count = 0; |
LINE *p; |
struct line *p; |
|
|
for (p = curbp->b_linep; p != lp; p = lforw(p)) { |
for (p = curbp->b_linep; p != lp; p = lforw(p)) { |
if (count != 0) { |
if (count != 0) { |
|
|
} |
} |
|
|
static int |
static int |
find_lo(int pos, LINE **olp, int *offset) |
find_lo(int pos, struct line **olp, int *offset) |
{ |
{ |
LINE *p; |
struct line *p; |
|
|
p = curbp->b_linep; |
p = curbp->b_linep; |
while (pos > llength(p)) { |
while (pos > llength(p)) { |
|
|
} |
} |
|
|
int |
int |
undo_add_insert(LINE *lp, int offset, int size) |
undo_add_insert(struct line *lp, int offset, int size) |
{ |
{ |
REGION reg; |
struct region reg; |
struct undo_rec *rec; |
struct undo_rec *rec; |
int pos; |
int pos; |
|
|
|
|
rec = new_undo_record(); |
rec = new_undo_record(); |
rec->pos = pos; |
rec->pos = pos; |
rec->type = INSERT; |
rec->type = INSERT; |
memmove(&rec->region, ®, sizeof(REGION)); |
memmove(&rec->region, ®, sizeof(struct region)); |
rec->content = NULL; |
rec->content = NULL; |
|
|
undo_add_boundary(); |
undo_add_boundary(); |
|
|
* This of course must be done _before_ the actual deletion is done. |
* This of course must be done _before_ the actual deletion is done. |
*/ |
*/ |
int |
int |
undo_add_delete(LINE *lp, int offset, int size) |
undo_add_delete(struct line *lp, int offset, int size) |
{ |
{ |
REGION reg; |
struct region reg; |
struct undo_rec *rec; |
struct undo_rec *rec; |
int pos; |
int pos; |
|
|
|
|
rec->pos = pos; |
rec->pos = pos; |
|
|
rec->type = DELETE; |
rec->type = DELETE; |
memmove(&rec->region, ®, sizeof(REGION)); |
memmove(&rec->region, ®, sizeof(struct region)); |
do { |
do { |
rec->content = malloc(reg.r_size + 1); |
rec->content = malloc(reg.r_size + 1); |
} while ((rec->content == NULL) && drop_oldest_undo_record()); |
} while ((rec->content == NULL) && drop_oldest_undo_record()); |
|
|
* This of course must be called before the change takes place. |
* This of course must be called before the change takes place. |
*/ |
*/ |
int |
int |
undo_add_change(LINE *lp, int offset, int size) |
undo_add_change(struct line *lp, int offset, int size) |
{ |
{ |
if (undo_disable_flag) |
if (undo_disable_flag) |
return (TRUE); |
return (TRUE); |
|
|
undo_dump(int f, int n) |
undo_dump(int f, int n) |
{ |
{ |
struct undo_rec *rec; |
struct undo_rec *rec; |
BUFFER *bp; |
struct buffer *bp; |
MGWIN *wp; |
struct mgwin *wp; |
char buf[4096], tmp[1024]; |
char buf[4096], tmp[1024]; |
int num; |
int num; |
|
|
|
|
{ |
{ |
struct undo_rec *ptr, *nptr; |
struct undo_rec *ptr, *nptr; |
int done, rval; |
int done, rval; |
LINE *lp; |
struct line *lp; |
int offset, save, dot; |
int offset, save, dot; |
static int nulled = FALSE; |
static int nulled = FALSE; |
|
|