commit f0bb50306c2a594b1a50a67767a1142ed851d8c3
parent 412b9fc0a2b48641c24ce7176b0bfae52c854329
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 27 Jun 2015 09:27:19 +0000
Renaming three flags for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5268 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,6 +1,7 @@
2015-06-27 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when
it really tried to delete the final, magic newline.
+ * src/nano.h, src/text.c: Rename three flags for clarity.
2015-06-23 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Verify that there exists multidata for the
diff --git a/src/nano.h b/src/nano.h
@@ -569,10 +569,10 @@ enum
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
-/* Some extra bits for the undo function. */
-#define SKIP_FINAL_BACKSPACE (1<<1)
-#define UNcut_marked_forward (1<<2)
-#define UNcut_cutline (1<<3)
+/* Some extra flags for the undo function. */
+#define WAS_FINAL_BACKSPACE (1<<1)
+#define WAS_MARKED_FORWARD (1<<2)
+#define WAS_WHOLE_LINE (1<<3)
#endif /* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */
diff --git a/src/text.c b/src/text.c
@@ -393,14 +393,14 @@ void undo_cut(undo *u)
return;
/* Get to where we need to uncut from. */
- if (u->xflags == UNcut_cutline)
+ if (u->xflags == WAS_WHOLE_LINE)
goto_line_posx(u->mark_begin_lineno, 0);
else
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
copy_from_filestruct(u->cutbuffer);
- if (u->xflags != UNcut_marked_forward && u->type != PASTE)
+ if (u->xflags != WAS_MARKED_FORWARD && u->type != PASTE)
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
}
@@ -424,7 +424,7 @@ void redo_cut(undo *u)
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;
+ openfile->mark_begin_x = (u->xflags == WAS_WHOLE_LINE) ? 0 : u->mark_begin_x;
do_cut_text(FALSE, FALSE, TRUE);
@@ -503,7 +503,7 @@ void do_undo(void)
undidmsg = _("line join");
/* When the join was done by a Backspace at the tail of the file,
* don't actually add another line; just position the cursor. */
- if (ISSET(NO_NEWLINES) || u->xflags != SKIP_FINAL_BACKSPACE) {
+ if (ISSET(NO_NEWLINES) || u->xflags != WAS_FINAL_BACKSPACE) {
t = make_new_node(f);
t->data = mallocstrcpy(NULL, u->strdata);
data = mallocstrncpy(NULL, f->data, u->mark_begin_x + 1);
@@ -938,7 +938,7 @@ void add_undo(undo_type action)
/* If the next line is the magic line, don't ever undo this
* backspace, as it won't actually have deleted anything. */
if (fs->current->next == fs->filebot && fs->current->data[0] != '\0')
- u->xflags = SKIP_FINAL_BACKSPACE;
+ u->xflags = WAS_FINAL_BACKSPACE;
case DEL:
if (u->begin != strlen(fs->current->data)) {
char *char_buf = charalloc(mb_cur_max() + 1);
@@ -985,7 +985,7 @@ void add_undo(undo_type action)
else if (!ISSET(CUT_TO_END)) {
/* The entire line is being cut regardless of the cursor position. */
u->begin = 0;
- u->xflags = UNcut_cutline;
+ u->xflags = WAS_WHOLE_LINE;
}
break;
case PASTE:
@@ -1104,7 +1104,7 @@ fprintf(stderr, " >> Updating... action = %d, fs->last_action = %d, openfile->c
u->lineno = u->mark_begin_lineno;
u->mark_begin_lineno = line;
} else
- u->xflags = UNcut_marked_forward;
+ u->xflags = WAS_MARKED_FORWARD;
} else {
/* Compute cutbottom for the uncut using our copy. */
u->cutbottom = u->cutbuffer;