From 0f3e303d1adf456f5a83b5c663c55049ffe4b0a6 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 2 Dec 2016 17:37:11 +0100 Subject: [PATCH] tweaks: get rid of some spurious textual references to edit_refresh() --- src/nano.c | 7 +++---- src/search.c | 4 ++-- src/text.c | 5 ++--- src/winio.c | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/nano.c b/src/nano.c index fdf92564..c192f941 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1911,10 +1911,9 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) #endif #ifndef DISABLE_WRAPPING - /* If we're wrapping text, we need to call edit_refresh(). */ - if (!ISSET(NO_WRAP)) - if (do_wrap(openfile->current)) - refresh_needed = TRUE; + /* If text gets wrapped, the edit window needs a refresh. */ + if (!ISSET(NO_WRAP) && do_wrap(openfile->current)) + refresh_needed = TRUE; #endif } diff --git a/src/search.c b/src/search.c index 8a7b9b14..f137ffbb 100644 --- a/src/search.c +++ b/src/search.c @@ -734,8 +734,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, if (!replaceall) { #ifndef DISABLE_COLOR - /* If color syntaxes are available and turned on, we - * need to call edit_refresh(). */ + /* When doing syntax coloring, the replacement might require + * a change of colors, so refresh the whole edit window. */ if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) edit_refresh(); else diff --git a/src/text.c b/src/text.c index 01523de8..07713009 100644 --- a/src/text.c +++ b/src/text.c @@ -2461,9 +2461,8 @@ void do_justify(bool full_justify) } else openfile->current_x = strlen(openfile->current->data); - /* Renumber the lines of the now-justified current paragraph, - * since both find_paragraph() and edit_refresh() need the line - * numbers to be right. */ + /* Renumber the now-justified paragraph, since both refreshing the + * edit window and finding a paragraph need correct line numbers. */ renumber(curr_first_par_line); /* We've just finished justifying the paragraph. If we're not diff --git a/src/winio.c b/src/winio.c index f75304fc..3b59cc37 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2996,7 +2996,7 @@ void edit_refresh(void) if (openfile->current->lineno < openfile->edittop->lineno || openfile->current->lineno >= openfile->edittop->lineno + maxrows) { #ifdef DEBUG - fprintf(stderr, "edit_refresh(): line = %ld, edittop %ld + maxrows %d\n", + fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxrows = %d\n", (long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows); #endif adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY); @@ -3005,7 +3005,7 @@ void edit_refresh(void) foo = openfile->edittop; #ifdef DEBUG - fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno); + fprintf(stderr, "edit-refresh: now edittop = %ld\n", (long)openfile->edittop->lineno); #endif for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {