tweaks: rename need_horizontal_scroll() to line_needs_update()

The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
This commit is contained in:
David Lawrence Ramsey 2017-01-31 16:51:06 -06:00 committed by Benno Schulenberg
parent df2a4679d5
commit eb369c0e00
3 changed files with 15 additions and 14 deletions

View File

@ -369,7 +369,7 @@ void do_home(void)
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
@ -381,7 +381,7 @@ void do_end(void)
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
ensure_line_is_visible();
@ -414,10 +414,10 @@ void do_up(bool scroll_only)
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y > 0) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
if (line_needs_update(was_column, 0))
update_line(openfile->current->next, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
@ -492,10 +492,10 @@ void do_down(bool scroll_only)
/* If the lines weren't already redrawn, see if they need to be. */
if (openfile->current_y < editwinrows - 1) {
/* Redraw the prior line if it was horizontally scrolled. */
if (need_horizontal_scroll(was_column, 0))
if (line_needs_update(was_column, 0))
update_line(openfile->current->prev, 0);
/* Redraw the current line if it needs to be horizontally scrolled. */
if (need_horizontal_scroll(0, xplustabs()))
if (line_needs_update(0, xplustabs()))
update_line(openfile->current, openfile->current_x);
}
}
@ -535,7 +535,7 @@ void do_left(void)
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
}
@ -557,7 +557,7 @@ void do_right(void)
openfile->placewewant = xplustabs();
if (need_horizontal_scroll(was_column, openfile->placewewant))
if (line_needs_update(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x);
if (openfile->current_x == 0)

View File

@ -706,7 +706,7 @@ void reset_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);

View File

@ -2715,9 +2715,10 @@ int update_line(filestruct *fileptr, size_t index)
return 1;
}
/* Check whether old_column and new_column are on different "pages" (or that
* the mark is on), which means that the relevant line needs to be redrawn. */
bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
/* Check whether the mark is on, or whether old_column and new_column are on
* different "pages" (in softwrap mode, only the former applies), which means
* that the relevant line needs to be redrawn. */
bool line_needs_update(const size_t old_column, const size_t new_column)
{
#ifndef NANO_TINY
if (openfile->mark_set)
@ -2934,7 +2935,7 @@ void edit_scroll(scroll_dir direction, int nrows)
for (i = nrows; i > 0 && line != NULL; i--) {
if ((i == nrows && direction == DOWNWARD) ||
(i == 1 && direction == UPWARD)) {
if (need_horizontal_scroll(openfile->placewewant, 0))
if (line_needs_update(openfile->placewewant, 0))
update_line(line, (line == openfile->current) ?
openfile->current_x : 0);
} else
@ -3016,7 +3017,7 @@ void edit_redraw(filestruct *old_current)
/* Update current if the mark is on or it has changed "page", or if it
* differs from old_current and needs to be horizontally scrolled. */
if (need_horizontal_scroll(was_pww, openfile->placewewant) ||
if (line_needs_update(was_pww, openfile->placewewant) ||
(old_current != openfile->current &&
get_page_start(openfile->placewewant) > 0))
update_line(openfile->current, openfile->current_x);