From: Chris Allegretta Date: Thu, 21 Jun 2001 15:07:40 +0000 (+0000) Subject: Last fixes, add reset of cutbuffer when uncutting marked text and reset marked_cut... X-Git-Tag: v1.0.3~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=6ab3ef77af48cc38312dfe77538c45c714507341;p=nano.git Last fixes, add reset of cutbuffer when uncutting marked text and reset marked_cut when cutbuffer reset git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@688 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 616d7a7f..67e5327b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ CVS code - do_cut_text() - If the line is empty when using -k and wasn't already added, create a dummy line and add it to the cutbuffer (fixes bug #61) + - Reset marked_cut if we blow away the cutbuffer. + do_uncut_text() + - Reset cutbuffer even if we're uncutting marked or cut to end text! - files.c: do_browser() - Don't shift the size of the file is it's less than 1K. Fixed diff --git a/cut.c b/cut.c index 13717c66..e10ef6ce 100644 --- a/cut.c +++ b/cut.c @@ -142,6 +142,7 @@ int do_cut_text(void) int newsize, cuttingtoend = 0; #endif + check_statblank(); if (fileptr == NULL || fileptr->data == NULL) return 0; @@ -152,6 +153,7 @@ int do_cut_text(void) free_filestruct(cutbuffer); cutbuffer = NULL; + marked_cut = 0; #ifdef DEBUG fprintf(stderr, _("Blew away cutbuffer =)\n")); #endif @@ -165,15 +167,22 @@ int do_cut_text(void) if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) { if (current_x == strlen(current->data)) { - /* If the line is empty and we didn't just cut a non-blank + /* If the line is empty and we didn't just cut a non-blank line, create a dummy line and add it to the cutbuffer */ - if (current_x == 0 && marked_cut != 1) { + if (marked_cut != 1) { + filestruct *junk; - junk = copy_node(current); + junk = NULL; + junk = make_new_node(current); + junk->data = nmalloc(1 * sizeof (char)); + junk->data[0] = 0; add_to_cutbuffer(junk); + dump_buffer(cutbuffer); + } + do_delete(); SET(KEEP_CUTBUFFER); marked_cut = 2; @@ -319,6 +328,8 @@ int do_uncut_text(void) current->data = tmpstr; current_x += strlen(cutbuffer->data); totsize += strlen(cutbuffer->data); + if (strlen(cutbuffer->data) == 0) + totlines++; placewewant = xplustabs(); update_cursor(); @@ -379,7 +390,7 @@ int do_uncut_text(void) screw up all the work we just did and separate the line. There must be a better way to do this, but not at 1AM on a work night. */ - if (marked_cut == 2 && current_x != strlen(current->data)) { + if (marked_cut == 2) { tmp = make_new_node(current); tmp->data = nmalloc(strlen(¤t->data[current_x]) + 1); strcpy(tmp->data, ¤t->data[current_x]); @@ -388,6 +399,10 @@ int do_uncut_text(void) current = current->next; current_x = 0; placewewant = 0; + + /* Extra line added, update stuff */ + totlines++; + totsize++; } /* Renumber from BEFORE where we pasted ;) */ renumber(hold); @@ -396,6 +411,7 @@ int do_uncut_text(void) dump_buffer(cutbuffer); set_modified(); edit_refresh(); + UNSET(KEEP_CUTBUFFER); return 0; #else if (0) {