nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit eb369c0e00c6c5b38012d0d0e3d4600e378e9eeb
parent df2a4679d50801617069a3033232b03f52d9f661
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Tue, 31 Jan 2017 16:51:06 -0600

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.

Diffstat:
Msrc/move.c | 16++++++++--------
Msrc/proto.h | 2+-
Msrc/winio.c | 11++++++-----
3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -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) diff --git a/src/proto.h b/src/proto.h @@ -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); diff --git a/src/winio.c b/src/winio.c @@ -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);