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
master
David Lawrence Ramsey 2004-11-06 20:33:43 +00:00
parent 8c16bacbbf
commit 00cca05ebb
2 changed files with 15 additions and 7 deletions

View File

@ -112,8 +112,11 @@ CVS code -
in files.c, and replace them with a static file_format enum. in files.c, and replace them with a static file_format enum.
Change the openfilestruct structure accordingly in order to Change the openfilestruct structure accordingly in order to
handle this. (DLR) handle this. (DLR)
- Convert some ints with predefined boundaries to enums. (DLR)
- cut.c: - 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: - files.c:
read_file() read_file()
- Rename variable fileformat to format, to avoid confusion with - Rename variable fileformat to format, to avoid confusion with

View File

@ -240,8 +240,7 @@ void do_cut_text(void)
if (marked_cut != CUT_MARKED && current->next != filebot) { if (marked_cut != CUT_MARKED && current->next != filebot) {
filestruct *junk = make_new_node(current); filestruct *junk = make_new_node(current);
junk->data = charalloc(1); junk->data = mallocstrcpy(NULL, "");
junk->data[0] = '\0';
add_to_cutbuffer(junk, TRUE); add_to_cutbuffer(junk, TRUE);
#ifdef DEBUG #ifdef DEBUG
dump_buffer(cutbuffer); dump_buffer(cutbuffer);
@ -403,9 +402,11 @@ void do_uncut_text(void)
new_magicline(); new_magicline();
} }
/* Now why don't we update the totsize also? */ /* Recalculate current_y and totsize. */
for (tmp = current->next; tmp != newend; tmp = tmp->next) for (tmp = current->next; tmp != newend; tmp = tmp->next) {
current_y++;
totsize += strlen(tmp->data) + 1; totsize += strlen(tmp->data) + 1;
}
current = newend; current = newend;
} }
@ -426,6 +427,7 @@ void do_uncut_text(void)
totlines++; totlines++;
totsize++; totsize++;
} }
/* Renumber from BEFORE where we pasted ;) */ /* Renumber from BEFORE where we pasted ;) */
renumber(hold); renumber(hold);
@ -444,6 +446,7 @@ void do_uncut_text(void)
newbuf->prev = tmp; newbuf->prev = tmp;
} else } else
fileage = newbuf; fileage = newbuf;
totlines++; /* Unmarked uncuts don't split lines. */ totlines++; /* Unmarked uncuts don't split lines. */
/* This is so uncutting at the top of the buffer will work => */ /* This is so uncutting at the top of the buffer will work => */
@ -454,9 +457,11 @@ void do_uncut_text(void)
newend->next = current; newend->next = current;
current->prev = newend; current->prev = newend;
/* Recalculate size *sigh* */ /* Recalculate current_y and totsize. */
for (tmp = newbuf; tmp != current; tmp = tmp->next) for (tmp = newbuf; tmp != current; tmp = tmp->next) {
current_y++;
totsize += strlen(tmp->data) + 1; totsize += strlen(tmp->data) + 1;
}
renumber(newbuf); renumber(newbuf);
edit_refresh(); edit_refresh();