nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit a872709ab426e51e6f4caf7c3d232bbe66011943
parent b439f5567877bdfaabbaf77bdf1764d5eeb572be
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Wed, 18 Jun 2014 19:04:35 +0000

Making sure the cutbuffer is cleared at the appropriate moments.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4978 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 10++++++++++
Msrc/cut.c | 18+++++++++++++++++-
Msrc/proto.h | 1+
Msrc/text.c | 3++-
4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,13 @@ +2014-06-18 Mark Majeres <mark@engine12.com> + * src/text.c (add_undo): Don't start a new undo for CUT when the + cutbuffer is being preserved, because then the cuts are contiguous + and will form a single undo item. And make sure the cutbuffer will + be cleared when a new undo item for CUT is created. + * src/cut.c (keeping_cutbuffer): New function, to access the status + of 'keep_cutbuffer' from the undo/redo code in src/text.c. + * src/cut.c (do_copy_text): Blow away the contents of the cutbuffer + if the mark is set or the cursor has moved between two copy commands. + 2014-06-17 Mark Majeres <mark@engine12.com> * src/text.c (do_undo, do_redo): After an undo or redo, update the 'placewewant' (the desired horizontal position of the cursor). diff --git a/src/cut.c b/src/cut.c @@ -37,6 +37,12 @@ void cutbuffer_reset(void) keep_cutbuffer = FALSE; } +/* Return the status of cutbuffer preservation. */ +inline bool keeping_cutbuffer(void) +{ + return keep_cutbuffer; +} + /* If we aren't on the last line of the file, move all the text of the * current line, plus the newline at the end, into the cutbuffer. If we * are, move all of the text of the current line into the cutbuffer. In @@ -245,10 +251,20 @@ void do_cut_text_void(void) #ifndef NANO_TINY /* Move text from the current filestruct into the cutbuffer, and copy it - * back into the filestruct afterward. */ + * back into the filestruct afterward. If the mark is set or the cursor + * was moved, blow away previous contents of the cutbuffer. */ void do_copy_text(void) { + static struct filestruct *next_contiguous_line = NULL; + bool mark_set = openfile->mark_set; + + if (mark_set || openfile->current != next_contiguous_line) + cutbuffer_reset(); + do_cut_text(TRUE, FALSE, FALSE); + + /* If the mark was set, blow away the cutbuffer on the next copy. */ + next_contiguous_line = (mark_set ? NULL : openfile->current); } /* Cut from the current cursor position to the end of the file. */ diff --git a/src/proto.h b/src/proto.h @@ -249,6 +249,7 @@ void color_update(void); /* All functions in cut.c. */ void cutbuffer_reset(void); +bool keeping_cutbuffer(void); void cut_line(void); #ifndef NANO_TINY void cut_marked(void); diff --git a/src/text.c b/src/text.c @@ -854,7 +854,7 @@ void add_undo(undo_type current_action) * on the same lineno, we need to abort here. */ u = fs->current_undo; if (u && u->mark_begin_lineno == fs->current->lineno && - ((current_action == CUT && u->type == CUT && !u->mark_set) || + ((current_action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer()) || (current_action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x))) return; @@ -941,6 +941,7 @@ void add_undo(undo_type current_action) case CUT_EOF: u->to_end = TRUE; case CUT: + cutbuffer_reset(); u->mark_set = openfile->mark_set; if (u->mark_set) { u->mark_begin_lineno = openfile->mark_begin->lineno;