added "more" command
[unix-history] / usr / src / usr.bin / window / ttinit.c
index 04fd663..57e7b99 100644 (file)
@@ -1,15 +1,44 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttinit.c    3.6 83/08/26";
+static char sccsid[] = "@(#)ttinit.c   3.14 %G%";
 #endif
 
 #endif
 
+/*
+ * Copyright (c) 1983 Regents of the University of California,
+ * All rights reserved.  Redistribution permitted subject to
+ * the terms of the Berkeley Software License Agreement.
+ */
+
 #include "ww.h"
 #include "tt.h"
 
 #include "ww.h"
 #include "tt.h"
 
+int tt_h19();
+int tt_h29();
+int tt_f100();
+int tt_tvi925();
+int tt_generic();
+struct tt_tab tt_tab[] = {
+       { "h19",        3, tt_h19 },
+       { "h29",        3, tt_h29 },
+       { "f100",       4, tt_f100 },
+       { "tvi925",     6, tt_tvi925 },
+       { "generic",    0, tt_generic },
+       0
+};
+
 ttinit()
 {
        register struct tt_tab *tp;
        register char *p, *q;
        register char *t;
 ttinit()
 {
        register struct tt_tab *tp;
        register char *p, *q;
        register char *t;
+       struct winsize winsize;
+
+       tt_strp = tt_strings;
+
+       /*
+        * Set output buffer size to about 1 second of output time.
+        */
+       tt_obp = tt_ob;
+       tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob);
 
        /*
         * Use the standard name of the terminal (i.e. the second
 
        /*
         * Use the standard name of the terminal (i.e. the second
@@ -38,5 +67,10 @@ ttinit()
                wwerrno = WWE_CANTDO;
                return -1;
        }
                wwerrno = WWE_CANTDO;
                return -1;
        }
+       if (ioctl(0, (int)TIOCGWINSZ, (char *)&winsize) >= 0 &&
+           winsize.ws_row != 0 && winsize.ws_col != 0) {
+               tt.tt_nrow = winsize.ws_row;
+               tt.tt_ncol = winsize.ws_col;
+       }
        return 0;
 }
        return 0;
 }