tweaks: conditionalize a bit of softwrap code

This addresses https://savannah.gnu.org/bugs/?49803.
master
David Lawrence Ramsey 2016-12-08 09:56:16 -06:00 committed by Benno Schulenberg
parent 6263416355
commit c8c6340ce8
1 changed files with 18 additions and 18 deletions

View File

@ -2804,31 +2804,31 @@ bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
return (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 we really
* we really have to work with (i.e. set maxrows). */ * have to work with, accounting for softwrap mode. */
void compute_maxrows(void) void compute_maxrows(void)
{ {
int n; #ifndef NANO_TINY
filestruct *foo = openfile->edittop; if (ISSET(SOFTWRAP)) {
int n;
filestruct *foo = openfile->edittop;
if (!ISSET(SOFTWRAP)) { maxrows = 0;
maxrows = editwinrows; for (n = 0; n < editwinrows && foo; n++) {
return; maxrows++;
} n += strlenpt(foo->data) / editwincols;
foo = foo->next;
}
maxrows = 0; if (n < editwinrows)
for (n = 0; n < editwinrows && foo; n++) { maxrows += editwinrows - n;
maxrows++;
n += strlenpt(foo->data) / editwincols;
foo = foo->next;
}
if (n < editwinrows)
maxrows += editwinrows - n;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "compute_maxrows(): maxrows = %d\n", maxrows); fprintf(stderr, "compute_maxrows(): maxrows = %d\n", maxrows);
#endif #endif
} else
#endif /* !NANO_TINY */
maxrows = editwinrows;
} }
/* Scroll the edit window in the given direction and the given number /* Scroll the edit window in the given direction and the given number