- Add very basic undo for text replace.
- Fix lots of warnings whe using -Wall - Fix some comments git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4290 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
015c74093a
commit
3c1131a5b3
|
@ -788,6 +788,9 @@ ssize_t do_replace_loop(
|
||||||
char *copy;
|
char *copy;
|
||||||
size_t length_change;
|
size_t length_change;
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
update_undo(REPLACE, openfile);
|
||||||
|
#endif
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
replaceall = TRUE;
|
replaceall = TRUE;
|
||||||
|
|
||||||
|
|
39
src/text.c
39
src/text.c
|
@ -368,7 +368,7 @@ void do_unindent(void)
|
||||||
void do_undo(void)
|
void do_undo(void)
|
||||||
{
|
{
|
||||||
undo *u = openfile->current_undo;
|
undo *u = openfile->current_undo;
|
||||||
filestruct *f = openfile->current, *t, *t2;
|
filestruct *f = openfile->current, *t;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char *undidmsg, *data;
|
char *undidmsg, *data;
|
||||||
|
|
||||||
|
@ -458,6 +458,12 @@ void do_undo(void)
|
||||||
free_filestruct(cutbuffer);
|
free_filestruct(cutbuffer);
|
||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
break;
|
break;
|
||||||
|
case REPLACE:
|
||||||
|
undidmsg = _("text replace");
|
||||||
|
data = u->strdata;
|
||||||
|
u->strdata = f->data;
|
||||||
|
f->data = data;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
undidmsg = _("wtf?");
|
undidmsg = _("wtf?");
|
||||||
break;
|
break;
|
||||||
|
@ -472,8 +478,8 @@ void do_undo(void)
|
||||||
void do_redo(void)
|
void do_redo(void)
|
||||||
{
|
{
|
||||||
undo *u = openfile->undotop;
|
undo *u = openfile->undotop;
|
||||||
filestruct *f = openfile->current, *t, *t2;
|
filestruct *f = openfile->current, *t;
|
||||||
int len = 0, i, i2;
|
int len = 0, i;
|
||||||
char *undidmsg, *data;
|
char *undidmsg, *data;
|
||||||
|
|
||||||
for (; u != NULL && u->next != openfile->current_undo; u = u->next)
|
for (; u != NULL && u->next != openfile->current_undo; u = u->next)
|
||||||
|
@ -588,6 +594,12 @@ void do_redo(void)
|
||||||
openfile->mark_begin_x = 0;
|
openfile->mark_begin_x = 0;
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
break;
|
break;
|
||||||
|
case REPLACE:
|
||||||
|
undidmsg = _("text replace");
|
||||||
|
data = u->strdata;
|
||||||
|
u->strdata = f->data;
|
||||||
|
f->data = data;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
undidmsg = _("wtf?");
|
undidmsg = _("wtf?");
|
||||||
break;
|
break;
|
||||||
|
@ -822,6 +834,7 @@ void add_undo(undo_type current_action, openfilestruct *fs)
|
||||||
u->begin = fs->current_x;
|
u->begin = fs->current_x;
|
||||||
break;
|
break;
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
|
case REPLACE:
|
||||||
data = mallocstrcpy(NULL, fs->current->data);
|
data = mallocstrcpy(NULL, fs->current->data);
|
||||||
u->begin = fs->current_x;
|
u->begin = fs->current_x;
|
||||||
u->strdata = data;
|
u->strdata = data;
|
||||||
|
@ -835,6 +848,11 @@ void add_undo(undo_type current_action, openfilestruct *fs)
|
||||||
}
|
}
|
||||||
u->to_end = (current_action == CUTTOEND);
|
u->to_end = (current_action == CUTTOEND);
|
||||||
break;
|
break;
|
||||||
|
case UNCUT:
|
||||||
|
break;
|
||||||
|
case OTHER:
|
||||||
|
statusbar(_("OOPS. Tried to add unknown thing to undo struct, I'd save your work"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -858,8 +876,12 @@ void update_undo(undo_type action, openfilestruct *fs)
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %d, fs->current_undo->lineno = %d\n",
|
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %d",
|
||||||
action, fs->last_action, openfile->current->lineno, fs->current_undo->lineno);
|
action, fs->last_action, openfile->current->lineno);
|
||||||
|
if (fs->current_undo)
|
||||||
|
fprintf(stderr, "fs->current_undo->lineno = %d\n", fs->current_undo->lineno);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Change to an add if we're not using the same undo struct
|
/* Change to an add if we're not using the same undo struct
|
||||||
|
@ -938,10 +960,13 @@ void update_undo(undo_type action, openfilestruct *fs)
|
||||||
u->cutbottom = cutbottom;
|
u->cutbottom = cutbottom;
|
||||||
u->linescut++;
|
u->linescut++;
|
||||||
break;
|
break;
|
||||||
|
case REPLACE:
|
||||||
|
add_undo(action, fs);
|
||||||
|
break;
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
case UNSPLIT:
|
case UNSPLIT:
|
||||||
/* We don't really ever update an enter key press, treat it as a new */
|
/* These cases are handled by the earlier check for a new line and action */
|
||||||
// add_undo(action, fs);
|
case OTHER:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue