tweaks: rename a variable -- lines refers to buffer, rows to screen

master
Benno Schulenberg 2017-01-12 17:33:46 +01:00
parent 26fb907aa6
commit 0208ae7149
4 changed files with 20 additions and 20 deletions

View File

@ -94,8 +94,8 @@ WINDOW *bottomwin;
* messages, the statusbar prompt, and a list of shortcuts. */ * messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0; int editwinrows = 0;
/* How many rows does the edit window take up? */ /* How many rows does the edit window take up? */
int maxrows = 0; int maxlines = 0;
/* How many usable lines there are (due to soft wrapping). */ /* How many file lines can be shown (due to soft wrapping). */
filestruct *cutbuffer = NULL; filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */ /* The buffer where we store cut text. */

View File

@ -100,7 +100,7 @@ void do_page_down(void)
/* If the cursor is less than a page away from the bottom of the file, /* If the cursor is less than a page away from the bottom of the file,
* put it at the end of the last line. */ * put it at the end of the last line. */
if (openfile->current->lineno + maxrows - 2 >= openfile->filebot->lineno) { if (openfile->current->lineno + maxlines - 2 >= openfile->filebot->lineno) {
do_last_line(); do_last_line();
return; return;
} }
@ -112,7 +112,7 @@ void do_page_down(void)
openfile->placewewant = openfile->current_y = 0; openfile->placewewant = openfile->current_y = 0;
} }
mustmove = (maxrows < 3) ? 1 : maxrows - 2; mustmove = (maxlines < 3) ? 1 : maxlines - 2;
for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) { for (i = mustmove; i > 0 && openfile->current != openfile->filebot; i--) {
openfile->current = openfile->current->next; openfile->current = openfile->current->next;

View File

@ -76,7 +76,7 @@ extern WINDOW *topwin;
extern WINDOW *edit; extern WINDOW *edit;
extern WINDOW *bottomwin; extern WINDOW *bottomwin;
extern int editwinrows; extern int editwinrows;
extern int maxrows; extern int maxlines;
extern filestruct *cutbuffer; extern filestruct *cutbuffer;
extern filestruct *cutbottom; extern filestruct *cutbottom;

View File

@ -2755,30 +2755,30 @@ bool need_horizontal_scroll(const size_t old_column, const size_t new_column)
/* When edittop changes, try and figure out how many lines we really /* When edittop changes, try and figure out how many lines we really
* have to work with, accounting for softwrap mode. */ * have to work with, accounting for softwrap mode. */
void compute_maxrows(void) void compute_maxlines(void)
{ {
#ifndef NANO_TINY #ifndef NANO_TINY
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP)) {
int screenrow; int screenrow;
filestruct *line = openfile->edittop; filestruct *line = openfile->edittop;
maxrows = 0; maxlines = 0;
for (screenrow = 0; screenrow < editwinrows && line != NULL; screenrow++) { for (screenrow = 0; screenrow < editwinrows && line != NULL; screenrow++) {
screenrow += strlenpt(line->data) / editwincols; screenrow += strlenpt(line->data) / editwincols;
line = line->next; line = line->next;
maxrows++; maxlines++;
} }
if (screenrow < editwinrows) if (screenrow < editwinrows)
maxrows += editwinrows - screenrow; maxlines += editwinrows - screenrow;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "recomputed: maxrows = %d\n", maxrows); fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
#endif #endif
} else } else
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
maxrows = editwinrows; maxlines = 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
@ -2877,7 +2877,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
foo = foo->next; foo = foo->next;
} }
compute_maxrows(); compute_maxlines();
} }
/* Update any lines between old_current and current that need to be /* Update any lines between old_current and current that need to be
@ -2889,9 +2889,9 @@ void edit_redraw(filestruct *old_current)
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
/* If the current line is offscreen, scroll until it's onscreen. */ /* If the current line is offscreen, scroll until it's onscreen. */
if (openfile->current->lineno >= openfile->edittop->lineno + maxrows || if (openfile->current->lineno >= openfile->edittop->lineno + maxlines ||
#ifndef NANO_TINY #ifndef NANO_TINY
(openfile->current->lineno == openfile->edittop->lineno + maxrows - 1 && (openfile->current->lineno == openfile->edittop->lineno + maxlines - 1 &&
ISSET(SOFTWRAP) && strlenpt(openfile->current->data) >= editwincols) || ISSET(SOFTWRAP) && strlenpt(openfile->current->data) >= editwincols) ||
#endif #endif
openfile->current->lineno < openfile->edittop->lineno) { openfile->current->lineno < openfile->edittop->lineno) {
@ -2933,15 +2933,15 @@ void edit_refresh(void)
filestruct *line; filestruct *line;
int row = 0; int row = 0;
/* Figure out what maxrows should really be. */ /* Figure out what maxlines should really be. */
compute_maxrows(); compute_maxlines();
/* If the current line is out of view, get it back on screen. */ /* If the current line is out of view, get it back on screen. */
if (openfile->current->lineno < openfile->edittop->lineno || if (openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno + maxrows) { openfile->current->lineno >= openfile->edittop->lineno + maxlines) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxrows = %d\n", fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxlines = %d\n",
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows); (long)openfile->current->lineno, (long)openfile->edittop->lineno, maxlines);
#endif #endif
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY); adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
} }
@ -3021,7 +3021,7 @@ void adjust_viewport(update_type manner)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno); fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
#endif #endif
compute_maxrows(); compute_maxlines();
} }
/* Unconditionally redraw the entire screen. */ /* Unconditionally redraw the entire screen. */