From f5fd540f4421225a45b42783d5a5e79193f5198f Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Thu, 25 Oct 2001 14:35:27 +0000 Subject: [PATCH] Backported 1.1 fixes for edit_refresh instead of edit_update when cut/uncut text can fit on screen git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@885 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ cut.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e987136..2e3e1110 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,12 @@ CVS code - 1" as the COPYING file is actually version 2 of the GPL (bug noticed by Jordi Mallach). - cut.c: + do_cut_text() + - Backported 1.1 fixes for just doing edit_update when we cut + text instead of edit_update. + do_uncut_text() + - Backported David Lawrence Ramsey's fixes for doing refresh + instead of edit_update when uncutting text. cut_marked_segment() - Fix off-by one in mem allocation. - nano.c: diff --git a/cut.c b/cut.c index 08a2fa85..2b6d4660 100644 --- a/cut.c +++ b/cut.c @@ -142,7 +142,7 @@ int do_cut_text(void) #ifndef NANO_SMALL char *tmpstr; int newsize, cuttingtoend = 0; - int cuttingpartialline = 0; + int dontupdate = 0; #endif @@ -201,7 +201,7 @@ int do_cut_text(void) } if (ISSET(MARK_ISSET)) { if (current->lineno == mark_beginbuf->lineno) { - cuttingpartialline = 1; + dontupdate = 1; tmp = copy_node(current); newsize = abs(mark_beginx - current_x) + 1; @@ -224,21 +224,38 @@ int do_cut_text(void) add_to_cutbuffer(tmp); dump_buffer(cutbuffer); align(¤t->data); - } else if (current->lineno < mark_beginbuf->lineno) + } else if (current->lineno < mark_beginbuf->lineno) { + + /* Don't do_update and move the screen position if the marked + area lies entirely within the screen buffer */ + if (current->lineno >= edittop->lineno + && mark_beginbuf->lineno <= editbot->lineno) + dontupdate = 1; + cut_marked_segment(current, current_x, mark_beginbuf, mark_beginx); - else + } + else { + + /* Same as above, easier logic since we know it's a multi-line + cut and mark_beginbuf is before current */ + if (mark_beginbuf->lineno >= edittop->lineno + && current->lineno <= editbot->lineno) + dontupdate = 1; + cut_marked_segment(mark_beginbuf, mark_beginx, current, current_x); + } placewewant = xplustabs(); UNSET(MARK_ISSET); marked_cut = 1; set_modified(); - if (cuttingpartialline || cuttingtoend) + if (dontupdate || cuttingtoend) { + fix_editbot(); edit_refresh(); - else + } else edit_update(current, CENTER); return 1; @@ -385,8 +402,12 @@ int do_uncut_text(void) i = editbot->lineno; current = newend; - if (i <= newend->lineno) + if (i < newend->lineno) { edit_update(current, CENTER); + } + else { + edit_refresh(); + } } /* If marked cut == 2, that means that we're doing a cut to end @@ -444,8 +465,12 @@ int do_uncut_text(void) i = editbot->lineno; renumber(newbuf); - if (i < newend->lineno) + if (i < newend->lineno) { edit_update(fileptr, CENTER); + } + else { + edit_refresh(); + } dump_buffer_reverse(fileptr); -- 2.39.5