Commit f0bb5030 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Renaming three flags for clarity.

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