Răsfoiți Sursa

Only move bottom if it was scrolled out of the window

Jochen Sprickerhof 5 ani în urmă
părinte
comite
4b23d03e3c
1 a modificat fișierele cu 9 adăugiri și 3 ștergeri
  1. 9 3
      scroll.c

+ 9 - 3
scroll.c

@@ -314,16 +314,22 @@ scrollup(int n)
 		write(STDOUT_FILENO, scrollend->buf + 1, scrollend->size - 1);
 	else
 		write(STDOUT_FILENO, scrollend->buf, scrollend->size);
-	bottom = TAILQ_NEXT(bottom, entries);
+	if ( x + n >= ws.ws_row)
+		bottom = TAILQ_NEXT(bottom, entries);
 
 	/* print rows lines and move bottom forward to the new screen bottom */
 	for (; rows > 1; rows--) {
 		scrollend = TAILQ_PREV(scrollend, tailhead, entries);
-		bottom = TAILQ_NEXT(bottom, entries);
+		if ( x + n >= ws.ws_row)
+			bottom = TAILQ_NEXT(bottom, entries);
 		write(STDOUT_FILENO, scrollend->buf, scrollend->size);
 	}
 	/* move cursor from line n to the old bottom position */
-	dprintf(STDOUT_FILENO, "\033[%d;0H", x);
+	if (x + n < ws.ws_row) {
+		dprintf(STDOUT_FILENO, "\033[%d;%dH", x + n, y);
+		write(STDOUT_FILENO, "\033[?25h", 6);	/* show cursor */
+	} else
+		dprintf(STDOUT_FILENO, "\033[%d;0H", ws.ws_row);
 }
 
 void