1
1

Handling the cases of cutting-from-cursor-to-end-of-line

(that is, when CUT_TO_END is set) properly.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5054 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Benno Schulenberg 2014-07-02 20:29:57 +00:00
родитель 85ddc718f8
Коммит 92213f9de8
4 изменённых файлов: 21 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,9 @@
2014-07-02 Mark Majeres <mark@engine12.com>
* src/text.c (undo_cut, redo_cut, update_undo): Handle the
cases of cutting-from-cursor-to-end-of-line properly.
* src/nano.c (do_input): Don't preserve the cutbuffer when
CUT_TO_END is toggled -- it would intermix two cut types.
2014-07-02 Benno Schulenberg <bensberg@justemail.net>
* src/proto.h: Add a typedef for a pointer to a function.
* src/global.c (func_from_key): New wrapper.

Просмотреть файл

@ -1707,7 +1707,8 @@ int do_input(bool allow_funcs)
#ifndef NANO_TINY
if (s->scfunc == do_toggle_void) {
do_toggle(s->toggle);
preserve = TRUE;
if (s->toggle != CUT_TO_END)
preserve = TRUE;
} else
#endif
{

Просмотреть файл

@ -572,7 +572,7 @@ enum
/* Extra bits for the undo function. */
#define UNdel_del (1<<0)
#define UNdel_backspace (1<<1)
#define UNcut_marked_backwards (1<<2)
#define UNcut_marked_forward (1<<2)
#define UNcut_cutline (1<<3)
#endif /* !NANO_TINY */

Просмотреть файл

@ -388,7 +388,7 @@ void undo_cut(undo *u)
copy_from_filestruct(u->cutbuffer);
if (u->xflags == UNcut_cutline || u->xflags == UNcut_marked_backwards || u->type == CUT_EOF)
if (u->xflags != UNcut_marked_forward && u->type != PASTE)
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
}
@ -406,11 +406,11 @@ void redo_cut(undo *u)
openfile->placewewant = xplustabs();
}
openfile->mark_set = ISSET(CUT_TO_END) ? u->mark_set : TRUE;
openfile->mark_set = TRUE;
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
do_cut_text(FALSE, u->type == CUT_EOF, TRUE);
do_cut_text(FALSE, FALSE, TRUE);
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
@ -1060,15 +1060,19 @@ void update_undo(undo_type action)
ssize_t line = u->lineno;
u->lineno = u->mark_begin_lineno;
u->mark_begin_lineno = line;
u->xflags = UNcut_marked_backwards;
}
} else if (!ISSET(CUT_TO_END)) {
} else
u->xflags = UNcut_marked_forward;
} else {
/* Compute cutbottom for the uncut using our copy. */
u->cutbottom = u->cutbuffer;
while (u->cutbottom->next != NULL)
u->cutbottom = u->cutbottom->next;
if (u->type != CUT_EOF)
u->lineno++;
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno - u->cutbuffer->lineno;
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
u->begin = strlen(u->cutbottom->data);
if(u->lineno == u->mark_begin_lineno)
u->begin += u->mark_begin_x;
}
}
break;
case REPLACE: