First pass at fixing the line splitting undo since it's currently broken beyond belief.
I believe more is broken but committing will motivate me to get closer to a real fix :) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4389 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
55ca1028ac
commit
12ba55732f
|
@ -292,6 +292,8 @@ typedef struct undo {
|
||||||
/* Where did this action begin or end */
|
/* Where did this action begin or end */
|
||||||
char *strdata;
|
char *strdata;
|
||||||
/* String type data we will use for ccopying the affected line back */
|
/* String type data we will use for ccopying the affected line back */
|
||||||
|
char *strdata2;
|
||||||
|
/* Sigh, need this too it looks like */
|
||||||
int xflags;
|
int xflags;
|
||||||
/* Some flag data we need */
|
/* Some flag data we need */
|
||||||
|
|
||||||
|
@ -730,6 +732,7 @@ typedef struct subnfunc {
|
||||||
/* Extra bits for the undo function */
|
/* Extra bits for the undo function */
|
||||||
#define UNDO_DEL_DEL (1<<0)
|
#define UNDO_DEL_DEL (1<<0)
|
||||||
#define UNDO_DEL_BACKSPACE (1<<1)
|
#define UNDO_DEL_BACKSPACE (1<<1)
|
||||||
|
#define UNDO_SPLIT_MADENEW (1<<2)
|
||||||
|
|
||||||
/* Since in ISO C you can't pass around function pointers anymore,
|
/* Since in ISO C you can't pass around function pointers anymore,
|
||||||
let's make some integer macros for function names, and then I
|
let's make some integer macros for function names, and then I
|
||||||
|
|
35
src/text.c
35
src/text.c
|
@ -475,13 +475,16 @@ void do_undo(void)
|
||||||
break;
|
break;
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
undidmsg = _("line split");
|
undidmsg = _("line split");
|
||||||
free(f->data);
|
fprintf(stderr, "u->strdata = \"%s\"\n", u->strdata);
|
||||||
f->data = mallocstrcpy(NULL, u->strdata);
|
f->data = nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||||
if (f->next != NULL) {
|
strcat(f->data, u->strdata);
|
||||||
filestruct *tmp = f->next;
|
if (u->xflags & UNDO_SPLIT_MADENEW) {
|
||||||
unlink_node(tmp);
|
filestruct *foo = openfile->current->next;
|
||||||
delete_node(tmp);
|
unlink_node(foo);
|
||||||
|
delete_node(foo);
|
||||||
}
|
}
|
||||||
|
if (u->strdata2 != NULL)
|
||||||
|
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
|
||||||
renumber(f);
|
renumber(f);
|
||||||
break;
|
break;
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
|
@ -811,6 +814,7 @@ void add_undo(undo_type current_action)
|
||||||
char *data;
|
char *data;
|
||||||
openfilestruct *fs = openfile;
|
openfilestruct *fs = openfile;
|
||||||
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */
|
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */
|
||||||
|
ssize_t wrap_loc; /* For calculating split beginning */
|
||||||
|
|
||||||
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
|
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
|
||||||
we need to abort here */
|
we need to abort here */
|
||||||
|
@ -871,8 +875,16 @@ void add_undo(undo_type current_action)
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
|
wrap_loc = break_line(openfile->current->data, fill
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
|
, FALSE
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
u->strdata = mallocstrcpy(NULL, &openfile->current->data[wrap_loc]);
|
||||||
|
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
|
||||||
|
break;
|
||||||
|
case INSERT:
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
data = mallocstrcpy(NULL, fs->current->data);
|
data = mallocstrcpy(NULL, fs->current->data);
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
|
@ -902,7 +914,7 @@ void add_undo(undo_type current_action)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %d, u->begin = %d, type = %d\n",
|
fprintf(stderr, "fs->current->data = \"%s\", current_x = %d, u->begin = %d, type = %d\n",
|
||||||
fs->current->data, fs->current_x, u->begin, current_action);
|
fs->current->data, fs->current_x, u->begin, current_action);
|
||||||
fprintf(stderr, "left update_add...\n");
|
fprintf(stderr, "left add_undo...\n");
|
||||||
#endif
|
#endif
|
||||||
fs->last_action = current_action;
|
fs->last_action = current_action;
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1023,12 @@ void update_undo(undo_type action)
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
u->mark_begin_lineno = openfile->current->lineno;
|
u->mark_begin_lineno = openfile->current->lineno;
|
||||||
|
break;
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
|
/* This will only be called if we made a completely new line,
|
||||||
|
and as such we should note that so we can destroy it later */
|
||||||
|
u->xflags = UNDO_SPLIT_MADENEW;
|
||||||
|
break;
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
/* These cases are handled by the earlier check for a new line and action */
|
/* These cases are handled by the earlier check for a new line and action */
|
||||||
case OTHER:
|
case OTHER:
|
||||||
|
@ -1108,6 +1125,8 @@ bool do_wrap(filestruct *line)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
add_undo(SPLIT);
|
||||||
|
|
||||||
/* If autoindent is turned on, and we're on the character just after
|
/* If autoindent is turned on, and we're on the character just after
|
||||||
* the indentation, we don't wrap. */
|
* the indentation, we don't wrap. */
|
||||||
if (ISSET(AUTOINDENT)) {
|
if (ISSET(AUTOINDENT)) {
|
||||||
|
|
Loading…
Reference in New Issue