commit b97c36c2184d0c6a7123d81ec6a8fabda253b7ba
parent 3e1d2b9049ee7069e0104db895e7b7cc1f41c305
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 25 Apr 2016 20:05:21 +0200
screen: don't always set 'edit_refresh_needed' when adjusting edittop
The function edit_update() is called by edit_refresh() itself, so it is
silly that the first sets 'edit_refresh_needed' to TRUE. This setting
is needed only in a few cases -- in the others it's not needed because
the screen does not need to be refreshed (it was just about positioning
the cursor), or 'edit_refresh_needed' has already been set by a call to
goto_line_posx(). So, just set the flag in the five places that need it
and spare the other four calls.
Diffstat:
5 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1262,9 +1262,6 @@ void do_insertfile(
#ifndef DISABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
- /* Update the screen to account for the current buffer. */
- display_buffer();
-
#ifndef DISABLE_HISTORIES
if (ISSET(POS_HISTORY)) {
ssize_t priorline, priorcol;
@@ -1275,6 +1272,8 @@ void do_insertfile(
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
}
#endif /* !DISABLE_HISTORIES */
+ /* Update the screen to account for the current buffer. */
+ display_buffer();
} else
#endif /* !DISABLE_MULTIBUFFER */
{
diff --git a/src/move.c b/src/move.c
@@ -97,6 +97,7 @@ void do_page_up(void)
/* Scroll the edit window up a page. */
edit_update(STATIONARY);
+ edit_refresh_needed = TRUE;
}
/* Move down one page. */
@@ -137,6 +138,7 @@ void do_page_down(void)
/* Scroll the edit window down a page. */
edit_update(STATIONARY);
+ edit_refresh_needed = TRUE;
}
#ifndef DISABLE_JUSTIFY
diff --git a/src/nano.c b/src/nano.c
@@ -403,8 +403,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
- if (edittop_inside)
+ if (edittop_inside) {
edit_update(STATIONARY);
+ edit_refresh_needed = TRUE;
+ }
/* Renumber starting with the beginning line of the old
* partition. */
diff --git a/src/search.c b/src/search.c
@@ -242,6 +242,7 @@ int search_init(bool replacing, bool use_answer)
} else if (func == do_gotolinecolumn_void) {
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
+ edit_refresh_needed = TRUE;
return 3;
}
diff --git a/src/winio.c b/src/winio.c
@@ -2954,8 +2954,10 @@ void edit_redraw(filestruct *old_current)
/* If the current line is offscreen, scroll until it's onscreen. */
if (openfile->current->lineno >= openfile->edittop->lineno + maxrows ||
- openfile->current->lineno < openfile->edittop->lineno)
+ openfile->current->lineno < openfile->edittop->lineno) {
edit_update((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : FLOWING);
+ edit_refresh_needed = TRUE;
+ }
#ifndef NANO_TINY
/* If the mark is on, update all lines between old_current and current. */
@@ -3070,7 +3072,6 @@ void edit_update(update_type manner)
fprintf(stderr, "edit_update(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
#endif
compute_maxrows();
- edit_refresh_needed = TRUE;
}
/* Unconditionally redraw the entire screen. */