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
/* 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. */
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);
}
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);
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);
/* 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);
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:
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;