Browse Source

Don't scroll over one line upon first scrollup

Jochen Sprickerhof 5 năm trước cách đây
mục cha
commit
7cc66224c3
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      scroll.c

+ 6 - 2
scroll.c

@@ -245,7 +245,11 @@ addline(char *buf, size_t size)
 void
 scrollup(void)
 {
-	int rows = 0;
+	int rows = 0, start = 0;
+
+	/* account for last line */
+	if(TAILQ_PREV(bottom, tailhead, entries) == NULL)
+		start = 1;
 
 	/* wind back bottom pointer by two pages */
 	for (; bottom != NULL && TAILQ_NEXT(bottom, entries) != NULL && rows < 2 * ws.ws_row; rows++)
@@ -264,7 +268,7 @@ scrollup(void)
 	write(STDOUT_FILENO, "\033[?25l", 6);
 
 	/* print one page */
-	for (rows = 0; rows < ws.ws_row; rows++) {
+	for (rows = 0; rows < ws.ws_row + start; rows++) {
 		bottom = TAILQ_PREV(bottom, tailhead, entries);
 		write(STDOUT_FILENO, bottom->buf, bottom->size);
 	}