Knows how to use LINES now.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 23:09:46 +0000 (23:09 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Nov 2004 23:09:46 +0000 (23:09 +0000)
TODO
sst.c

diff --git a/TODO b/TODO
index 8062cb145c7b81c2980ab8a66614f2a262fde37b..142160ba232ee46e03a3baa0ac31dd209fd1846a 100644 (file)
--- 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 b06a82fade956d28bd2b9b4f6b32a250d39db369..b3a0202663bd5d6760366c82f8a1bf73d4f24545 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -11,6 +11,7 @@ int getch(void);
 \r
 static char line[128], *linep = line;\r
 static int linecount;  /* for paging */\r
+static int screenheight = 24;\r
 \r
 static void clearscreen(void);\r
 \r
@@ -163,8 +164,8 @@ static void helpme(void) {
        while (fgets(linebuf, sizeof(linebuf),fp)) {\r
                if (strstr(linebuf, "******"))\r
                        break;\r
-               linebuf[strlen(linebuf)-1] = '\0'; // No \n at end\r
-               prout(linebuf);\r
+               /* use fputs here to avoid % expansion */\r
+               fputs(linebuf, stdout);\r
        }\r
        fclose(fp);\r
 }\r
@@ -355,6 +356,10 @@ int main(int argc, char **argv) {
        int hitme;\r
        char ch;\r
        prelim();\r
+       char *LINES = getenv("LINES");\r
\r
+       if (LINES)\r
+           screenheight = atoi(LINES);\r
 \r
        if (argc > 1) {\r
                fromcommandline = 1;\r
@@ -577,7 +582,7 @@ void pause(int i) {
 void skip(int i) {\r
        while (i-- > 0) {\r
                linecount++;\r
-               if (linecount >= 23)\r
+               if (linecount >= screenheight)\r
                        pause(0);\r
                else\r
                        putchar('\n');\r