mirror of git://git.sv.gnu.org/nano.git
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
This commit is contained in:
parent
85ddc718f8
commit
92213f9de8
|
@ -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>
|
2014-07-02 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/proto.h: Add a typedef for a pointer to a function.
|
* src/proto.h: Add a typedef for a pointer to a function.
|
||||||
* src/global.c (func_from_key): New wrapper.
|
* src/global.c (func_from_key): New wrapper.
|
||||||
|
|
|
@ -1707,6 +1707,7 @@ int do_input(bool allow_funcs)
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (s->scfunc == do_toggle_void) {
|
if (s->scfunc == do_toggle_void) {
|
||||||
do_toggle(s->toggle);
|
do_toggle(s->toggle);
|
||||||
|
if (s->toggle != CUT_TO_END)
|
||||||
preserve = TRUE;
|
preserve = TRUE;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -572,7 +572,7 @@ enum
|
||||||
/* Extra bits for the undo function. */
|
/* Extra bits for the undo function. */
|
||||||
#define UNdel_del (1<<0)
|
#define UNdel_del (1<<0)
|
||||||
#define UNdel_backspace (1<<1)
|
#define UNdel_backspace (1<<1)
|
||||||
#define UNcut_marked_backwards (1<<2)
|
#define UNcut_marked_forward (1<<2)
|
||||||
#define UNcut_cutline (1<<3)
|
#define UNcut_cutline (1<<3)
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
|
|
20
src/text.c
20
src/text.c
|
@ -388,7 +388,7 @@ void undo_cut(undo *u)
|
||||||
|
|
||||||
copy_from_filestruct(u->cutbuffer);
|
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);
|
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,11 +406,11 @@ void redo_cut(undo *u)
|
||||||
openfile->placewewant = xplustabs();
|
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 = fsfromline(u->mark_begin_lineno);
|
||||||
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
|
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_set = FALSE;
|
||||||
openfile->mark_begin = NULL;
|
openfile->mark_begin = NULL;
|
||||||
|
@ -1060,15 +1060,19 @@ void update_undo(undo_type action)
|
||||||
ssize_t line = u->lineno;
|
ssize_t line = u->lineno;
|
||||||
u->lineno = u->mark_begin_lineno;
|
u->lineno = u->mark_begin_lineno;
|
||||||
u->mark_begin_lineno = line;
|
u->mark_begin_lineno = line;
|
||||||
u->xflags = UNcut_marked_backwards;
|
} else
|
||||||
}
|
u->xflags = UNcut_marked_forward;
|
||||||
} else if (!ISSET(CUT_TO_END)) {
|
} else {
|
||||||
/* Compute cutbottom for the uncut using our copy. */
|
/* Compute cutbottom for the uncut using our copy. */
|
||||||
u->cutbottom = u->cutbuffer;
|
u->cutbottom = u->cutbuffer;
|
||||||
while (u->cutbottom->next != NULL)
|
while (u->cutbottom->next != NULL)
|
||||||
u->cutbottom = u->cutbottom->next;
|
u->cutbottom = u->cutbottom->next;
|
||||||
if (u->type != CUT_EOF)
|
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno - u->cutbuffer->lineno;
|
||||||
u->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;
|
break;
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
|
|
Loading…
Reference in New Issue