Fusing two identical functions into one: need_screen_update().

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5207 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2015-04-20 08:16:41 +00:00
parent 455a918071
commit 7edd350593
4 changed files with 17 additions and 31 deletions

View File

@ -1,3 +1,7 @@
2015-04-20 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (need_horizontal_update, need_vertical_update): Fuse
two identical functions into one: need_screen_update().
2015-04-18 Benno Schulenberg <bensberg@justemail.net> 2015-04-18 Benno Schulenberg <bensberg@justemail.net>
* src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi: * src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi:
Make the descriptions of the multibuffer feature more accurate. Make the descriptions of the multibuffer feature more accurate.

View File

@ -471,7 +471,7 @@ void do_home(void)
} }
#endif #endif
if (need_horizontal_update(pww_save)) if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
@ -483,7 +483,7 @@ void do_end(void)
openfile->current_x = strlen(openfile->current->data); openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save)) if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
@ -534,7 +534,7 @@ void do_up(
* needs to be redrawn if we're not on the first page, and the * needs to be redrawn if we're not on the first page, and the
* latter needs to be drawn unconditionally. */ * latter needs to be drawn unconditionally. */
if (openfile->current_y > 0) { if (openfile->current_y > 0) {
if (need_vertical_update(0)) if (need_screen_update(0))
update_line(openfile->current->next, 0); update_line(openfile->current->next, 0);
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
@ -632,7 +632,7 @@ void do_down(
|| ISSET(SOFTWRAP) || ISSET(SOFTWRAP)
#endif #endif
) { ) {
if (need_vertical_update(0)) if (need_screen_update(0))
update_line(openfile->current->prev, 0); update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
@ -671,7 +671,7 @@ void do_left(void)
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save)) if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
@ -692,6 +692,6 @@ void do_right(void)
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save)) if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }

View File

@ -789,8 +789,7 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted, int void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start); line, size_t start);
int update_line(filestruct *fileptr, size_t index); int update_line(filestruct *fileptr, size_t index);
bool need_horizontal_update(size_t pww_save); bool need_screen_update(size_t pww_save);
bool need_vertical_update(size_t pww_save);
void edit_scroll(scroll_dir direction, ssize_t nlines); void edit_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(filestruct *old_current, size_t pww_save); void edit_redraw(filestruct *old_current, size_t pww_save);
void edit_refresh(void); void edit_refresh(void);

View File

@ -2949,23 +2949,10 @@ int update_line(filestruct *fileptr, size_t index)
return extralinesused; return extralinesused;
} }
/* Return TRUE if we need an update after moving horizontally, and FALSE /* Return TRUE if we need an update after moving the cursor, and
* otherwise. We need one if the mark is on or if pww_save and * FALSE otherwise. We need an update if the mark is on, or if
* placewewant are on different pages. */ * pww_save and placewewant are on different pages. */
bool need_horizontal_update(size_t pww_save) bool need_screen_update(size_t pww_save)
{
return
#ifndef NANO_TINY
openfile->mark_set ||
#endif
get_page_start(pww_save) !=
get_page_start(openfile->placewewant);
}
/* Return TRUE if we need an update after moving vertically, and FALSE
* otherwise. We need one if the mark is on or if pww_save and
* placewewant are on different pages. */
bool need_vertical_update(size_t pww_save)
{ {
return return
#ifndef NANO_TINY #ifndef NANO_TINY
@ -3012,15 +2999,12 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
{ {
ssize_t i; ssize_t i;
filestruct *foo; filestruct *foo;
bool do_redraw = FALSE; bool do_redraw = need_screen_update(0);
/* Don't bother scrolling less than one line. */ /* Don't bother scrolling less than one line. */
if (nlines < 1) if (nlines < 1)
return; return;
if (need_vertical_update(0))
do_redraw = TRUE;
/* Part 1: nlines is the number of lines we're going to scroll the /* Part 1: nlines is the number of lines we're going to scroll the
* text of the edit window. */ * text of the edit window. */
@ -3122,9 +3106,8 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
* updated. Use this if we've moved without changing any text. */ * updated. Use this if we've moved without changing any text. */
void edit_redraw(filestruct *old_current, size_t pww_save) void edit_redraw(filestruct *old_current, size_t pww_save)
{ {
bool do_redraw = need_vertical_update(0) ||
need_vertical_update(pww_save);
filestruct *foo = NULL; filestruct *foo = NULL;
bool do_redraw = need_screen_update(0) || need_screen_update(pww_save);
/* If either old_current or current is offscreen, scroll the edit /* If either old_current or current is offscreen, scroll the edit
* window until it's onscreen and get out. */ * window until it's onscreen and get out. */