Bläddra i källkod

add some comments to scrollup

Jan Klemkow 6 år sedan
förälder
incheckning
67123e8c1c
2 ändrade filer med 4 tillägg och 1 borttagningar
  1. 1 1
      Makefile
  2. 3 0
      scroll.c

+ 1 - 1
Makefile

@@ -1,4 +1,4 @@
-CFLAGS += -std=c99 -pedantic -Wall -Wextra
+CFLAGS += -std=c99 -pedantic -Wall -Wextra -g
 LDLIBS += -lutil
 CPPFLAGS += -D_DEFAULT_SOURCE
 

+ 3 - 0
scroll.c

@@ -173,12 +173,15 @@ scrollup(void)
 	/* set cursor position */
 	write(STDOUT_FILENO, "\033[0;0H", 6);
 
+	/* check if the input line is on the bottom of the screen */
 	if (TAILQ_FIRST(&head) == bottom)
 		first = 1;
 
+	/* wind back bottom pointer by two pages */
 	for (rows = 0; bottom != NULL && rows < 2 * ws.ws_row; rows++)
 		bottom = TAILQ_NEXT(bottom, entries);
 
+	/* print one page */
 	for (; rows > ws.ws_row - first;) {
 		if ((bottom = TAILQ_PREV(bottom, tailhead, entries)) == NULL)
 			break;