Commit 812ecaeb authored by David Lawrence Ramsey's avatar David Lawrence Ramsey Committed by Benno Schulenberg
Browse files

weeding: remove maxlines and related code

Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
No related merge requests found
Showing with 2 additions and 37 deletions
+2 -37
...@@ -94,8 +94,6 @@ WINDOW *bottomwin; ...@@ -94,8 +94,6 @@ 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 maxlines = 0;
/* 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. */
......
...@@ -76,7 +76,6 @@ extern WINDOW *topwin; ...@@ -76,7 +76,6 @@ extern WINDOW *topwin;
extern WINDOW *edit; extern WINDOW *edit;
extern WINDOW *bottomwin; extern WINDOW *bottomwin;
extern int editwinrows; extern int editwinrows;
extern int maxlines;
extern filestruct *cutbuffer; extern filestruct *cutbuffer;
extern filestruct *cutbottom; extern filestruct *cutbottom;
......
...@@ -2728,32 +2728,6 @@ bool line_needs_update(const size_t old_column, const size_t new_column) ...@@ -2728,32 +2728,6 @@ bool line_needs_update(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));
} }
/* Determine how many file lines we can display, accounting for softwraps. */
void compute_maxlines(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
int row = 0;
maxlines = 0;
while (row < editwinrows && line != NULL) {
row += (strlenpt(line->data) / editwincols) + 1;
line = line->next;
maxlines++;
}
if (row < editwinrows)
maxlines += (editwinrows - row);
#ifdef DEBUG
fprintf(stderr, "recomputed: maxlines = %d\n", maxlines);
#endif
} else
#endif /* !NANO_TINY */
maxlines = editwinrows;
}
/* Try to move up nrows softwrapped chunks from the given line and the /* Try to move up nrows softwrapped chunks from the given line and the
* given column (leftedge). After moving, leftedge will be set to the * given column (leftedge). After moving, leftedge will be set to the
* starting column of the current chunk. Return the number of chunks we * starting column of the current chunk. Return the number of chunks we
...@@ -2941,8 +2915,6 @@ void edit_scroll(scroll_dir direction, int nrows) ...@@ -2941,8 +2915,6 @@ void edit_scroll(scroll_dir direction, int nrows)
openfile->current_x : 0); openfile->current_x : 0);
line = line->next; line = line->next;
} }
compute_maxlines();
} }
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE /* Return TRUE if current[current_x] is above the top of the screen, and FALSE
...@@ -3028,14 +3000,11 @@ void edit_refresh(void) ...@@ -3028,14 +3000,11 @@ void edit_refresh(void)
filestruct *line; filestruct *line;
int row = 0; int row = 0;
/* Figure out what maxlines should really be. */
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 (current_is_offscreen()) { if (current_is_offscreen()) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxlines = %d\n", fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and editwinrows = %d\n",
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxlines); (long)openfile->current->lineno, (long)openfile->edittop->lineno, editwinrows);
#endif #endif
adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY); adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
} }
...@@ -3110,7 +3079,6 @@ void adjust_viewport(update_type manner) ...@@ -3110,7 +3079,6 @@ 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_maxlines();
} }
/* Unconditionally redraw the entire screen. */ /* Unconditionally redraw the entire screen. */
......
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