changing window size and new WINSZ ioctl
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 2 Mar 1985 09:40:51 +0000 (01:40 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 2 Mar 1985 09:40:51 +0000 (01:40 -0800)
SCCS-vsn: usr.bin/window/ttinit.c 3.11
SCCS-vsn: usr.bin/window/win.c 3.11
SCCS-vsn: usr.bin/window/cmd5.c 3.13
SCCS-vsn: usr.bin/window/ww.h 3.35
SCCS-vsn: usr.bin/window/wwopen.c 3.19

usr/src/usr.bin/window/cmd5.c
usr/src/usr.bin/window/ttinit.c
usr/src/usr.bin/window/win.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwopen.c

index f9470f9..b459ad3 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cmd5.c     3.12 %G%";
+static char sccsid[] = "@(#)cmd5.c     3.13 %G%";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -16,6 +16,8 @@ register struct ww *w;
        int maxcol, maxrow;
        int curcol, currow;
 
        int maxcol, maxrow;
        int curcol, currow;
 
+       if (!terse)
+               wwputs("New window position: ", cmdwin);
        col = w->ww_w.l;
        row = w->ww_w.t;
        wwadd(boxwin, framewin->ww_back);
        col = w->ww_w.l;
        row = w->ww_w.t;
        wwadd(boxwin, framewin->ww_back);
@@ -55,8 +57,8 @@ register struct ww *w;
 {
        struct ww *back = w->ww_back;
 
 {
        struct ww *back = w->ww_back;
 
-       w->ww_altpos.r = w->ww_w.t;
-       w->ww_altpos.c = w->ww_w.l;
+       w->ww_alt.t = w->ww_w.t;
+       w->ww_alt.l = w->ww_w.l;
        wwdelete(w);
        wwmove(w, row, col);
        wwadd(w, back);
        wwdelete(w);
        wwmove(w, row, col);
        wwadd(w, back);
index 6307516..fb1ab88 100644 (file)
@@ -1,15 +1,28 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)ttinit.c   3.10 %G%";
+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;
 
 
        tt_strp = tt_strings;
 
@@ -46,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;
 }
index 2c45548..0d98e0c 100644 (file)
@@ -47,8 +47,7 @@ char *shf, **sh;
        w->ww_id = id;
        window[id] = w;
        w->ww_hasframe = hasframe;
        w->ww_id = id;
        window[id] = w;
        w->ww_hasframe = hasframe;
-       w->ww_altpos.r = 1;
-       w->ww_altpos.c = 0;
+       w->ww_alt = w->ww_w;
        if (label != 0 && setlabel(w, label) < 0)
                error("No memory for label.");
        wwcursor(w, 1);
        if (label != 0 && setlabel(w, label) < 0)
                error("No memory for label.");
        wwcursor(w, 1);
index 439ee24..65756d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * @(#)ww.h    3.34 %G%        
+ * @(#)ww.h    3.35 %G%        
  */
 
 #include <sgtty.h>
  */
 
 #include <sgtty.h>
@@ -23,10 +23,13 @@ struct ww_pos {
 
        /* the window structure */
 struct ww {
 
        /* the window structure */
 struct ww {
+               /* general flags and states */
+       char ww_state;          /* state of window */
+       char ww_oflags;         /* wwopen flags */
+
                /* information for overlap */
        struct ww *ww_forw;     /* doubly linked list, for overlapping info */
        struct ww *ww_back;
                /* information for overlap */
        struct ww *ww_forw;     /* doubly linked list, for overlapping info */
        struct ww *ww_back;
-       char ww_state;          /* state of window */
        char ww_index;          /* the window index, for wwindex[] */
        char ww_order;          /* the overlapping order */
 
        char ww_index;          /* the window index, for wwindex[] */
        char ww_order;          /* the overlapping order */
 
@@ -51,7 +54,6 @@ struct ww {
        char ww_unctrl;         /* expand control characters */
        char ww_nointr;         /* wwwrite() not interruptable */
        char ww_hascursor;      /* has fake cursor */
        char ww_unctrl;         /* expand control characters */
        char ww_nointr;         /* wwwrite() not interruptable */
        char ww_hascursor;      /* has fake cursor */
-       char ww_hasframe;       /* frame it */
 
                /* things for the window process and io */
        char ww_ispty;          /* ww_pty is really a pty, not socket pair */
 
                /* things for the window process and io */
        char ww_ispty;          /* ww_pty is really a pty, not socket pair */
@@ -66,10 +68,11 @@ struct ww {
        char *ww_obq;           /* current write position in ww_ob */
 
                /* things for the user, they really don't belong here */
        char *ww_obq;           /* current write position in ww_ob */
 
                /* things for the user, they really don't belong here */
-       char ww_center;         /* center the label */
        char ww_id;             /* the user window id */
        char ww_id;             /* the user window id */
+       char ww_center;         /* center the label */
+       char ww_hasframe;       /* frame it */
        char *ww_label;         /* the user supplied label */
        char *ww_label;         /* the user supplied label */
-       struct ww_pos ww_altpos;/* alternate position */
+       struct ww_dim ww_alt;   /* alternate position and size */
 };
 
        /* state of a tty */
 };
 
        /* state of a tty */
index 6b6ac1a..af82273 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)wwopen.c   3.18 %G%";
+static char sccsid[] = "@(#)wwopen.c   3.19 %G%";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -58,10 +58,19 @@ wwopen(flags, nrow, ncol, row, col, nline)
        w->ww_cur.c = w->ww_w.l;
 
        if (flags & WWO_PTY) {
        w->ww_cur.c = w->ww_w.l;
 
        if (flags & WWO_PTY) {
+               struct winsize winsize;
+
                if (wwgetpty(w) < 0)
                        goto bad;
                if (wwsettty(w->ww_pty, &wwwintty, (struct ww_tty *)0) < 0)
                        goto bad;
                if (wwgetpty(w) < 0)
                        goto bad;
                if (wwsettty(w->ww_pty, &wwwintty, (struct ww_tty *)0) < 0)
                        goto bad;
+               winsize.ws_row = nrow;
+               winsize.ws_col = ncol;
+               winsize.ws_xpixel = winsize.ws_ypixel = 0;
+               if (ioctl(w->ww_pty, TIOCSWINSZ, (char *)&winsize) < 0) {
+                       wwerrno = WWE_SYS;
+                       goto bad;
+               }
                w->ww_ispty = 1;
        } else if (flags & WWO_SOCKET) {
                int d[2];
                w->ww_ispty = 1;
        } else if (flags & WWO_SOCKET) {
                int d[2];
@@ -98,12 +107,12 @@ wwopen(flags, nrow, ncol, row, col, nline)
                w->ww_fmap = wwalloc(w->ww_w.t, w->ww_w.l,
                        w->ww_w.nr, w->ww_w.nc, sizeof (char));
                if (w->ww_fmap == 0)
                w->ww_fmap = wwalloc(w->ww_w.t, w->ww_w.l,
                        w->ww_w.nr, w->ww_w.nc, sizeof (char));
                if (w->ww_fmap == 0)
-                       wwerrno = WWE_NOMEM;
+                       goto bad;
                for (i = w->ww_w.t; i < w->ww_w.b; i++)
                        for (j = w->ww_w.l; j < w->ww_w.r; j++)
                                w->ww_fmap[i][j] = 0;
        }
                for (i = w->ww_w.t; i < w->ww_w.b; i++)
                        for (j = w->ww_w.l; j < w->ww_w.r; j++)
                                w->ww_fmap[i][j] = 0;
        }
-       
+
        w->ww_buf = (union ww_char **)
                wwalloc(w->ww_b.t, w->ww_b.l,
                        w->ww_b.nr, w->ww_b.nc, sizeof (union ww_char));
        w->ww_buf = (union ww_char **)
                wwalloc(w->ww_b.t, w->ww_b.l,
                        w->ww_b.nr, w->ww_b.nc, sizeof (union ww_char));
@@ -124,6 +133,7 @@ wwopen(flags, nrow, ncol, row, col, nline)
                w->ww_nvis[i] = nvis;
 
        w->ww_state = WWS_INITIAL;
                w->ww_nvis[i] = nvis;
 
        w->ww_state = WWS_INITIAL;
+       w->ww_oflags = flags;
        return wwindex[w->ww_index] = w;
 bad:
        if (w != 0) {
        return wwindex[w->ww_index] = w;
 bad:
        if (w != 0) {