Commit 2f664768 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename a function, and adjust some comments

parent c9e99642
No related merge requests found
Showing with 23 additions and 25 deletions
+23 -25
...@@ -385,7 +385,7 @@ void do_home(void) ...@@ -385,7 +385,7 @@ void do_home(void)
openfile->placewewant = xplustabs(); 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); update_line(openfile->current, openfile->current_x);
} }
...@@ -397,7 +397,7 @@ void do_end(void) ...@@ -397,7 +397,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_screen_update(was_column, openfile->placewewant)) if (need_horizontal_scroll(was_column, openfile->placewewant))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
} }
...@@ -439,12 +439,11 @@ void do_up(bool scroll_only) ...@@ -439,12 +439,11 @@ void do_up(bool scroll_only)
#endif #endif
editwinrows / 2 + 1); editwinrows / 2 + 1);
/* If we're not on the first line of the edit window, and the target /* Redraw the prior line if it was horizontally scrolled. */
* column is beyond the screen or the mark is on, redraw the prior if (need_horizontal_scroll(was_column, 0))
* and current lines. */
if (need_screen_update(was_column, 0))
update_line(openfile->current->next, 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); update_line(openfile->current, openfile->current_x);
} }
...@@ -522,12 +521,11 @@ void do_down(bool scroll_only) ...@@ -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 /* Redraw the prior line if it was horizontally scrolled. */
* column is beyond the screen or the mark is on, redraw the prior if (need_horizontal_scroll(was_column, 0))
* and current lines. */
if (need_screen_update(was_column, 0))
update_line(openfile->current->prev, 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); update_line(openfile->current, openfile->current_x);
} }
...@@ -566,7 +564,7 @@ void do_left(void) ...@@ -566,7 +564,7 @@ void do_left(void)
openfile->placewewant = xplustabs(); 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); update_line(openfile->current, openfile->current_x);
} }
...@@ -583,7 +581,7 @@ void do_right(void) ...@@ -583,7 +581,7 @@ void do_right(void)
else if (openfile->current != openfile->filebot) { else if (openfile->current != openfile->filebot) {
openfile->current_x = 0; openfile->current_x = 0;
openfile->placewewant = 0; openfile->placewewant = 0;
if (need_screen_update(was_column, 0)) if (need_horizontal_scroll(was_column, 0))
update_line(openfile->current, 0); update_line(openfile->current, 0);
do_down_void(); do_down_void();
return; return;
...@@ -591,6 +589,6 @@ void do_right(void) ...@@ -591,6 +589,6 @@ void do_right(void)
openfile->placewewant = xplustabs(); 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); update_line(openfile->current, openfile->current_x);
} }
...@@ -785,7 +785,7 @@ void reset_cursor(void); ...@@ -785,7 +785,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_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_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(filestruct *old_current); void edit_redraw(filestruct *old_current);
void edit_refresh(void); void edit_refresh(void);
......
...@@ -2602,16 +2602,16 @@ int update_line(filestruct *fileptr, size_t index) ...@@ -2602,16 +2602,16 @@ int update_line(filestruct *fileptr, size_t index)
return extralinesused; return extralinesused;
} }
/* Return TRUE if we need an update after moving the cursor, and /* Check whether old_column and new_column are on different "pages" (or that
* FALSE otherwise. We need an update if the mark is on, or if * the mark is on), which means that the relevant line needs to be redrawn. */
* old_column and new_column are on different pages. */ bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
bool need_screen_update(const size_t old_column, const size_t new_column)
{ {
return
#ifndef NANO_TINY #ifndef NANO_TINY
openfile->mark_set || if (openfile->mark_set)
return TRUE;
else
#endif #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 /* When edittop changes, try and figure out how many lines
...@@ -2740,7 +2740,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines) ...@@ -2740,7 +2740,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
for (i = nlines; i > 0 && foo != NULL; i--) { for (i = nlines; i > 0 && foo != NULL; i--) {
if ((i == nlines && direction == DOWNWARD) || (i == 1 && if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
direction == UPWARD)) { direction == UPWARD)) {
if (need_screen_update(openfile->placewewant, 0)) if (need_horizontal_scroll(openfile->placewewant, 0))
update_line(foo, (foo == openfile->current) ? update_line(foo, (foo == openfile->current) ?
openfile->current_x : 0); openfile->current_x : 0);
} else } else
...@@ -2786,7 +2786,7 @@ void edit_redraw(filestruct *old_current) ...@@ -2786,7 +2786,7 @@ void edit_redraw(filestruct *old_current)
/* Update current if we've changed page, or if it differs from /* Update current if we've changed page, or if it differs from
* old_current and needs to be horizontally scrolled. */ * 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 && (old_current != openfile->current &&
get_page_start(openfile->placewewant) > 0)) get_page_start(openfile->placewewant) > 0))
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment