tweaks: condense a comment, rename a variable, and use a while loop
parent
b7c2513f7d
commit
bf0268d41d
14
src/winio.c
14
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));
|
return (get_page_start(old_column) != get_page_start(new_column));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When edittop changes, try and figure out how many lines we really
|
/* Determine how many file lines we can display, accounting for softwraps. */
|
||||||
* have to work with, accounting for softwrap mode. */
|
|
||||||
void compute_maxlines(void)
|
void compute_maxlines(void)
|
||||||
{
|
{
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
int screenrow;
|
|
||||||
filestruct *line = openfile->edittop;
|
filestruct *line = openfile->edittop;
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
maxlines = 0;
|
maxlines = 0;
|
||||||
|
|
||||||
for (screenrow = 0; screenrow < editwinrows && line != NULL; screenrow++) {
|
while (row < editwinrows && line != NULL) {
|
||||||
screenrow += strlenpt(line->data) / editwincols;
|
row += (strlenpt(line->data) / editwincols) + 1;
|
||||||
line = line->next;
|
line = line->next;
|
||||||
maxlines++;
|
maxlines++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screenrow < editwinrows)
|
if (row < editwinrows)
|
||||||
maxlines += editwinrows - screenrow;
|
maxlines += (editwinrows - row);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
|
fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue