Commit b8d32d8b authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Condensing the code by removing a triplication.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5583 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 16 additions and 75 deletions
+16 -75
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* src/files.c (update_poshistory): Move an updated item to the end * src/files.c (update_poshistory): Move an updated item to the end
of the list, so that it won't be dropped any time soon. The problem of the list, so that it won't be dropped any time soon. The problem
was pointed out by David Niklas. was pointed out by David Niklas.
* src/winio.c (edit_redraw): Condense by removing a triplication.
2016-01-22 Benno Schulenberg <bensberg@justemail.net> 2016-01-22 Benno Schulenberg <bensberg@justemail.net>
* src/utils.c (get_homedir): Don't use $HOME when we're root, because * src/utils.c (get_homedir): Don't use $HOME when we're root, because
......
...@@ -2948,90 +2948,30 @@ void edit_scroll(scroll_dir direction, ssize_t nlines) ...@@ -2948,90 +2948,30 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
* updated. Use this if we've moved without changing any text. */ * updated. Use this if we've moved without changing any text. */
void edit_redraw(filestruct *old_current, size_t pww_save) void edit_redraw(filestruct *old_current, size_t pww_save)
{ {
filestruct *foo = NULL; /* If the current line is offscreen, scroll until it's onscreen. */
bool do_redraw = need_screen_update(0) || need_screen_update(pww_save); if (openfile->current->lineno >= openfile->edittop->lineno + maxrows ||
openfile->current->lineno < openfile->edittop->lineno)
/* If either old_current or current is offscreen, scroll the edit
* window until it's onscreen and get out. */
if (old_current->lineno < openfile->edittop->lineno ||
old_current->lineno >= openfile->edittop->lineno + maxrows ||
openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno + maxrows) {
#ifdef DEBUG
fprintf(stderr, "edit_redraw(): line %ld was offscreen, oldcurrent = %ld edittop = %ld",
(long)openfile->current->lineno, (long)old_current->lineno, (long)openfile->edittop->lineno);
#endif
#ifndef NANO_TINY
/* If the mark is on, update all the lines between old_current
* and either the old first line or old last line (depending on
* whether we've scrolled up or down) of the edit window. */
if (openfile->mark_set) {
ssize_t old_lineno;
if (openfile->edittop->lineno + maxrows <= openfile->filebot->lineno)
old_lineno = openfile->edittop->lineno + editwinrows;
else
old_lineno = openfile->filebot->lineno;
foo = old_current;
while (foo->lineno != old_lineno) {
update_line(foo, 0);
foo = (foo->lineno > old_lineno) ?
foo->prev : foo->next;
}
}
#endif /* !NANO_TINY */
/* Make sure the current line is on the screen. */
edit_update((ISSET(SMOOTH_SCROLL) && !focusing) ? NONE : CENTER); edit_update((ISSET(SMOOTH_SCROLL) && !focusing) ? NONE : CENTER);
/* Update old_current if we're not on the same page as
* before. */
if (do_redraw)
update_line(old_current, 0);
#ifndef NANO_TINY #ifndef NANO_TINY
/* If the mark is on, update all the lines between the old first /* If the mark is on, update all lines between old_current and current. */
* line or old last line of the edit window (depending on if (openfile->mark_set) {
* whether we've scrolled up or down) and current. */ filestruct *foo = old_current;
if (openfile->mark_set) {
while (foo->lineno != openfile->current->lineno) {
update_line(foo, 0);
foo = (foo->lineno > openfile->current->lineno) ?
foo->prev : foo->next;
}
}
#endif /* !NANO_TINY */
return;
}
/* Update old_current and current if we're not on the same page as
* before. If the mark is on, update all the lines between
* old_current and current too. */
foo = old_current;
while (foo != openfile->current) { while (foo != openfile->current) {
if (do_redraw)
update_line(foo, 0); update_line(foo, 0);
#ifndef NANO_TINY foo = (foo->lineno > openfile->current->lineno) ?
if (!openfile->mark_set) foo->prev : foo->next;
#endif }
break;
#ifndef NANO_TINY
foo = (foo->lineno > openfile->current->lineno) ? foo->prev :
foo->next;
#endif
} }
#endif /* !NANO_TINY */
if (do_redraw) /* Update old_current and current if we've changed page. */
if (need_screen_update(0) || need_screen_update(pww_save)) {
update_line(old_current, 0);
update_line(openfile->current, openfile->current_x); update_line(openfile->current, openfile->current_x);
}
} }
/* Refresh the screen without changing the position of lines. Use this /* Refresh the screen without changing the position of lines. Use this
......
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