Explorar o código

add some comments to scrollup

Jan Klemkow %!s(int64=6) %!d(string=hai) anos
pai
achega
67123e8c1c
Modificáronse 2 ficheiros con 4 adicións e 1 borrados
  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;