commit 7edd35059326f37b8016077017b9452ef886b8e7
parent 455a918071c659458f1f34b7a219dcbe0a9c2aeb
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 20 Apr 2015 08:16:41 +0000
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
Diffstat:
4 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -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>
* src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi:
Make the descriptions of the multibuffer feature more accurate.
diff --git a/src/move.c b/src/move.c
@@ -471,7 +471,7 @@ void do_home(void)
}
#endif
- if (need_horizontal_update(pww_save))
+ if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
@@ -483,7 +483,7 @@ void do_end(void)
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
- if (need_horizontal_update(pww_save))
+ if (need_screen_update(pww_save))
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
* latter needs to be drawn unconditionally. */
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, openfile->current_x);
}
@@ -632,7 +632,7 @@ void do_down(
|| ISSET(SOFTWRAP)
#endif
) {
- if (need_vertical_update(0))
+ if (need_screen_update(0))
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);
}
@@ -671,7 +671,7 @@ void do_left(void)
openfile->placewewant = xplustabs();
- if (need_horizontal_update(pww_save))
+ if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
@@ -692,6 +692,6 @@ void do_right(void)
openfile->placewewant = xplustabs();
- if (need_horizontal_update(pww_save))
+ if (need_screen_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
diff --git a/src/proto.h b/src/proto.h
@@ -789,8 +789,7 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start);
int update_line(filestruct *fileptr, size_t index);
-bool need_horizontal_update(size_t pww_save);
-bool need_vertical_update(size_t pww_save);
+bool need_screen_update(size_t pww_save);
void edit_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(filestruct *old_current, size_t pww_save);
void edit_refresh(void);
diff --git a/src/winio.c b/src/winio.c
@@ -2949,23 +2949,10 @@ int update_line(filestruct *fileptr, size_t index)
return extralinesused;
}
-/* Return TRUE if we need an update after moving horizontally, and FALSE
- * otherwise. We need one if the mark is on or if pww_save and
- * placewewant are on different pages. */
-bool need_horizontal_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 TRUE if we need an update after moving the cursor, and
+ * FALSE otherwise. We need an update if the mark is on, or if
+ * pww_save and placewewant are on different pages. */
+bool need_screen_update(size_t pww_save)
{
return
#ifndef NANO_TINY
@@ -3012,15 +2999,12 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
{
ssize_t i;
filestruct *foo;
- bool do_redraw = FALSE;
+ bool do_redraw = need_screen_update(0);
/* Don't bother scrolling less than one line. */
if (nlines < 1)
return;
- if (need_vertical_update(0))
- do_redraw = TRUE;
-
/* Part 1: nlines is the number of lines we're going to scroll the
* 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. */
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;
+ bool do_redraw = need_screen_update(0) || need_screen_update(pww_save);
/* If either old_current or current is offscreen, scroll the edit
* window until it's onscreen and get out. */