From 812ecaeb0c34dd08b03260a9896f4406a7005e5c Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 31 Jan 2017 15:28:48 -0600
Subject: [PATCH] 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.
---
 src/global.c |  2 --
 src/proto.h  |  1 -
 src/winio.c  | 36 ++----------------------------------
 3 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/src/global.c b/src/global.c
index d231c017..b0e1f8cc 100644
--- a/src/global.c
+++ b/src/global.c
@@ -94,8 +94,6 @@ WINDOW *bottomwin;
 	 * messages, the statusbar prompt, and a list of shortcuts. */
 int editwinrows = 0;
 	/* 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;
 	/* The buffer where we store cut text. */
diff --git a/src/proto.h b/src/proto.h
index 87b92a0d..707e3d56 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -76,7 +76,6 @@ extern WINDOW *topwin;
 extern WINDOW *edit;
 extern WINDOW *bottomwin;
 extern int editwinrows;
-extern int maxlines;
 
 extern filestruct *cutbuffer;
 extern filestruct *cutbottom;
diff --git a/src/winio.c b/src/winio.c
index b4230a54..3123a077 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -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));
 }
 
-/* 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
  * given column (leftedge).  After moving, leftedge will be set to the
  * starting column of the current chunk.  Return the number of chunks we
@@ -2941,8 +2915,6 @@ void edit_scroll(scroll_dir direction, int nrows)
 		openfile->current_x : 0);
 	line = line->next;
     }
-
-    compute_maxlines();
 }
 
 /* Return TRUE if current[current_x] is above the top of the screen, and FALSE
@@ -3028,14 +3000,11 @@ void edit_refresh(void)
     filestruct *line;
     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 (current_is_offscreen()) {
 #ifdef DEBUG
-	fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and maxlines = %d\n",
-		(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxlines);
+	fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and editwinrows = %d\n",
+		(long)openfile->current->lineno, (long)openfile->edittop->lineno, editwinrows);
 #endif
 	adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY);
     }
@@ -3110,7 +3079,6 @@ void adjust_viewport(update_type manner)
 #ifdef DEBUG
     fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
 #endif
-    compute_maxlines();
 }
 
 /* Unconditionally redraw the entire screen. */
-- 
GitLab