changing window size, new struct ww
[unix-history] / usr / src / usr.bin / window / ttinit.c
index 5bc3d8a..fb1ab88 100644 (file)
@@ -1,15 +1,36 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttinit.c    3.7 83/12/17";
+static char sccsid[] = "@(#)ttinit.c   3.11 %G%";
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
+int tt_h19();
+int tt_h29();
+int tt_f100();
+int tt_generic();
+struct tt_tab tt_tab[] = {
+       { "h19",        3, tt_h19 },
+       { "h29",        3, tt_h29 },
+       { "f100",       4, tt_f100 },
+       { "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 +59,10 @@ ttinit()
                wwerrno = WWE_CANTDO;
                return -1;
        }
                wwerrno = WWE_CANTDO;
                return -1;
        }
+       if (ioctl(0, 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;
 }