tweaks: rename a function, and adjust some comments
parent
c9e9964207
commit
2f6647687a
28
src/move.c
28
src/move.c
|
@ -385,7 +385,7 @@ void do_home(void)
|
|||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_screen_update(was_column, openfile->placewewant))
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ void do_end(void)
|
|||
openfile->current_x = strlen(openfile->current->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_screen_update(was_column, openfile->placewewant))
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
|
@ -439,12 +439,11 @@ void do_up(bool scroll_only)
|
|||
#endif
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
/* If we're not on the first line of the edit window, and the target
|
||||
* column is beyond the screen or the mark is on, redraw the prior
|
||||
* and current lines. */
|
||||
if (need_screen_update(was_column, 0))
|
||||
/* Redraw the prior line if it was horizontally scrolled. */
|
||||
if (need_horizontal_scroll(was_column, 0))
|
||||
update_line(openfile->current->next, 0);
|
||||
if (need_screen_update(0, xplustabs()))
|
||||
/* Redraw the current line if it needs to be horizontally scrolled. */
|
||||
if (need_horizontal_scroll(0, xplustabs()))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
|
@ -522,12 +521,11 @@ void do_down(bool scroll_only)
|
|||
}
|
||||
}
|
||||
|
||||
/* If we're not on the last line of the edit window, and the target
|
||||
* column is beyond the screen or the mark is on, redraw the prior
|
||||
* and current lines. */
|
||||
if (need_screen_update(was_column, 0))
|
||||
/* Redraw the prior line if it was horizontally scrolled. */
|
||||
if (need_horizontal_scroll(was_column, 0))
|
||||
update_line(openfile->current->prev, 0);
|
||||
if (need_screen_update(0, xplustabs()))
|
||||
/* Redraw the current line if it needs to be horizontally scrolled. */
|
||||
if (need_horizontal_scroll(0, xplustabs()))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
|
@ -566,7 +564,7 @@ void do_left(void)
|
|||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_screen_update(was_column, openfile->placewewant))
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
|
@ -583,7 +581,7 @@ void do_right(void)
|
|||
else if (openfile->current != openfile->filebot) {
|
||||
openfile->current_x = 0;
|
||||
openfile->placewewant = 0;
|
||||
if (need_screen_update(was_column, 0))
|
||||
if (need_horizontal_scroll(was_column, 0))
|
||||
update_line(openfile->current, 0);
|
||||
do_down_void();
|
||||
return;
|
||||
|
@ -591,6 +589,6 @@ void do_right(void)
|
|||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (need_screen_update(was_column, openfile->placewewant))
|
||||
if (need_horizontal_scroll(was_column, openfile->placewewant))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
|
|
@ -785,7 +785,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_screen_update(const size_t old_column, const size_t new_column);
|
||||
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines);
|
||||
void edit_redraw(filestruct *old_current);
|
||||
void edit_refresh(void);
|
||||
|
|
18
src/winio.c
18
src/winio.c
|
@ -2602,16 +2602,16 @@ int update_line(filestruct *fileptr, size_t index)
|
|||
return extralinesused;
|
||||
}
|
||||
|
||||
/* 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
|
||||
* old_column and new_column are on different pages. */
|
||||
bool need_screen_update(const size_t old_column, const size_t new_column)
|
||||
/* 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)
|
||||
{
|
||||
return
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark_set ||
|
||||
if (openfile->mark_set)
|
||||
return TRUE;
|
||||
else
|
||||
#endif
|
||||
get_page_start(old_column) != get_page_start(new_column);
|
||||
return (get_page_start(old_column) != get_page_start(new_column));
|
||||
}
|
||||
|
||||
/* When edittop changes, try and figure out how many lines
|
||||
|
@ -2740,7 +2740,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
|||
for (i = nlines; i > 0 && foo != NULL; i--) {
|
||||
if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
|
||||
direction == UPWARD)) {
|
||||
if (need_screen_update(openfile->placewewant, 0))
|
||||
if (need_horizontal_scroll(openfile->placewewant, 0))
|
||||
update_line(foo, (foo == openfile->current) ?
|
||||
openfile->current_x : 0);
|
||||
} else
|
||||
|
@ -2786,7 +2786,7 @@ void edit_redraw(filestruct *old_current)
|
|||
|
||||
/* Update current if we've changed page, or if it differs from
|
||||
* old_current and needs to be horizontally scrolled. */
|
||||
if (need_screen_update(was_pww, openfile->placewewant) ||
|
||||
if (need_horizontal_scroll(was_pww, openfile->placewewant) ||
|
||||
(old_current != openfile->current &&
|
||||
get_page_start(openfile->placewewant) > 0))
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
|
Loading…
Reference in New Issue