Przeglądaj źródła

Fix some special cases in scrolling

Jochen Sprickerhof 5 lat temu
rodzic
commit
79dd01d2f7
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      scroll.c

+ 5 - 2
scroll.c

@@ -283,21 +283,24 @@ scrollup(int n)
 		bottom = TAILQ_NEXT(bottom, entries);
 		write(STDOUT_FILENO, scrollend->buf, scrollend->size);
 	}
+	dprintf(STDOUT_FILENO, "\033[%d;%dH", ws.ws_row, ws.ws_col);
 }
 
 void
 scrolldown(char *buf, size_t size, int n)
 {
+	if (bottom == NULL || bottom == TAILQ_FIRST(&head))
+		return;
 	bottom = TAILQ_PREV(bottom, tailhead, entries);
 	/* print n lines */
 	for (; n > 0 && bottom != NULL && bottom != TAILQ_FIRST(&head); n--) {
 		bottom = TAILQ_PREV(bottom, tailhead, entries);
 		write(STDOUT_FILENO, bottom->buf, bottom->size);
 	}
-	if (bottom == TAILQ_FIRST(&head)) {
+	if (n > 0 && bottom == TAILQ_FIRST(&head)) {
 		write(STDOUT_FILENO, "\033[?25h", 6);	/* show cursor */
 		write(STDOUT_FILENO, buf, size);
-	} else
+	} else if (bottom != NULL)
 		bottom = TAILQ_NEXT(bottom, entries);
 }