Ver código fonte

Fix setting bottom pointer while scrolling

Jochen Sprickerhof 5 anos atrás
pai
commit
68e4cf9bea
1 arquivos alterados com 7 adições e 2 exclusões
  1. 7 2
      scroll.c

+ 7 - 2
scroll.c

@@ -246,8 +246,6 @@ addline(char *buf, size_t size)
 	line->buf = earealloc(NULL, size);
 	memcpy(line->buf, buf, size);
 
-	bottom = line;
-
 	TAILQ_INSERT_HEAD(&head, line, entries);
 }
 
@@ -536,6 +534,13 @@ main(int argc, char *argv[])
 
 				if (*c == '\n') {
 					addline(buf, pos);
+					/* only advance bottom if scroll is */
+					/* at the end of the scroll back */
+					if (bottom == NULL ||
+					    TAILQ_PREV(bottom, tailhead,
+					      entries) == TAILQ_FIRST(&head))
+						bottom = TAILQ_FIRST(&head);
+
 					memset(buf, 0, size);
 					pos = 0;
 				}