From: Eric S. Raymond Date: Mon, 1 Nov 2004 23:09:46 +0000 (+0000) Subject: Knows how to use LINES now. X-Git-Tag: 2.0~440 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=dd95aad0a184fc4f2ab4cd13323a70c9833acc2b;p=super-star-trek.git Knows how to use LINES now. --- diff --git a/TODO b/TODO index 8062cb1..142160b 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,6 @@ * Remove the assumption that sst.doc lives in the current directory. -* Have it read the value of LINES rather than assumong a 24-line terminal. - * Do a manual page. * Improve the internal pager. diff --git a/sst.c b/sst.c index b06a82f..b3a0202 100644 --- a/sst.c +++ b/sst.c @@ -11,6 +11,7 @@ int getch(void); static char line[128], *linep = line; static int linecount; /* for paging */ +static int screenheight = 24; static void clearscreen(void); @@ -163,8 +164,8 @@ static void helpme(void) { while (fgets(linebuf, sizeof(linebuf),fp)) { if (strstr(linebuf, "******")) break; - linebuf[strlen(linebuf)-1] = '\0'; // No \n at end - prout(linebuf); + /* use fputs here to avoid % expansion */ + fputs(linebuf, stdout); } fclose(fp); } @@ -355,6 +356,10 @@ int main(int argc, char **argv) { int hitme; char ch; prelim(); + char *LINES = getenv("LINES"); + + if (LINES) + screenheight = atoi(LINES); if (argc > 1) { fromcommandline = 1; @@ -577,7 +582,7 @@ void pause(int i) { void skip(int i) { while (i-- > 0) { linecount++; - if (linecount >= 23) + if (linecount >= screenheight) pause(0); else putchar('\n');