commit bf0268d41d8ccf6585fdc1fb6bf7c16769c13079
parent b7c2513f7d2357360833b42da423af3e69311f6f
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 12 Jan 2017 21:31:08 +0100
tweaks: condense a comment, rename a variable, and use a while loop
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -2752,26 +2752,24 @@ 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));
}
-/* When edittop changes, try and figure out how many lines we really
- * have to work with, accounting for softwrap mode. */
+/* Determine how many file lines we can display, accounting for softwraps. */
void compute_maxlines(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
- int screenrow;
filestruct *line = openfile->edittop;
+ int row = 0;
maxlines = 0;
- for (screenrow = 0; screenrow < editwinrows && line != NULL; screenrow++) {
- screenrow += strlenpt(line->data) / editwincols;
+ while (row < editwinrows && line != NULL) {
+ row += (strlenpt(line->data) / editwincols) + 1;
line = line->next;
maxlines++;
}
- if (screenrow < editwinrows)
- maxlines += editwinrows - screenrow;
-
+ if (row < editwinrows)
+ maxlines += (editwinrows - row);
#ifdef DEBUG
fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
#endif