commit 00cca05ebb64ae45981fab34ca456b3e2160ad9b
parent 8c16bacbbf13185f9383aace9aa6388f88f83ad3
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Sat, 6 Nov 2004 20:33:43 +0000
in do_uncut_text(), maintain current_y's value when uncutting blocks so
that smooth scrolling works correctly; also add a few miscellaneous
cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2075 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -112,8 +112,11 @@ CVS code -
in files.c, and replace them with a static file_format enum.
Change the openfilestruct structure accordingly in order to
handle this. (DLR)
+ - Convert some ints with predefined boundaries to enums. (DLR)
- cut.c:
- - Make marked_line a static enum instead of a static int. (DLR)
+ do_uncut_text()
+ - Maintain current_y's value when uncutting blocks so that
+ smooth scrolling works correctly. (DLR)
- files.c:
read_file()
- Rename variable fileformat to format, to avoid confusion with
diff --git a/src/cut.c b/src/cut.c
@@ -240,8 +240,7 @@ void do_cut_text(void)
if (marked_cut != CUT_MARKED && current->next != filebot) {
filestruct *junk = make_new_node(current);
- junk->data = charalloc(1);
- junk->data[0] = '\0';
+ junk->data = mallocstrcpy(NULL, "");
add_to_cutbuffer(junk, TRUE);
#ifdef DEBUG
dump_buffer(cutbuffer);
@@ -403,9 +402,11 @@ void do_uncut_text(void)
new_magicline();
}
- /* Now why don't we update the totsize also? */
- for (tmp = current->next; tmp != newend; tmp = tmp->next)
+ /* Recalculate current_y and totsize. */
+ for (tmp = current->next; tmp != newend; tmp = tmp->next) {
+ current_y++;
totsize += strlen(tmp->data) + 1;
+ }
current = newend;
}
@@ -426,6 +427,7 @@ void do_uncut_text(void)
totlines++;
totsize++;
}
+
/* Renumber from BEFORE where we pasted ;) */
renumber(hold);
@@ -444,6 +446,7 @@ void do_uncut_text(void)
newbuf->prev = tmp;
} else
fileage = newbuf;
+
totlines++; /* Unmarked uncuts don't split lines. */
/* This is so uncutting at the top of the buffer will work => */
@@ -454,9 +457,11 @@ void do_uncut_text(void)
newend->next = current;
current->prev = newend;
- /* Recalculate size *sigh* */
- for (tmp = newbuf; tmp != current; tmp = tmp->next)
+ /* Recalculate current_y and totsize. */
+ for (tmp = newbuf; tmp != current; tmp = tmp->next) {
+ current_y++;
totsize += strlen(tmp->data) + 1;
+ }
renumber(newbuf);
edit_refresh();