ttwrite added
[unix-history] / usr / src / usr.bin / window / win.c
index fc51997..3c3adab 100644 (file)
@@ -1,7 +1,13 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)win.c       3.7 84/04/08";
+static char sccsid[] = "@(#)win.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 "defs.h"
 #include "char.h"
 
 #include "defs.h"
 #include "char.h"
 
@@ -25,8 +31,10 @@ static       char *sccsid = "@(#)win.c       3.7 84/04/08";
  * Open a user window.
  */
 struct ww *
  * Open a user window.
  */
 struct ww *
-openwin(id, row, col, nrow, ncol, nline, label)
+openwin(id, row, col, nrow, ncol, nline, label, haspty, hasframe, shf, sh)
 char *label;
 char *label;
+char haspty, hasframe;
+char *shf, **sh;
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
@@ -37,15 +45,15 @@ char *label;
                error("Illegal window position.");
                return 0;
        }
                error("Illegal window position.");
                return 0;
        }
-       if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0) {
-               error("%s.", wwerror());
+       w = wwopen(haspty ? WWO_PTY : WWO_SOCKET, nrow, ncol, row, col, nline);
+       if (w == 0) {
+               error("Can't open window: %s.", wwerror());
                return 0;
        }
        w->ww_id = id;
        window[id] = w;
                return 0;
        }
        w->ww_id = id;
        window[id] = w;
-       w->ww_hasframe = 1;
-       w->ww_altpos.r = 1;
-       w->ww_altpos.c = 0;
+       w->ww_hasframe = hasframe;
+       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);
@@ -59,9 +67,9 @@ char *label;
        setselwin(w);
        wwupdate();
        wwflush();
        setselwin(w);
        wwupdate();
        wwflush();
-       if (wwspawn(w, shell, shellname, (char *)0) < 0) {
+       if (wwspawn(w, shf, sh) < 0) {
+               error("Can't execute %s: %s.", shf, wwerror());
                c_close(w);
                c_close(w);
-               error("%s: %s.", shell, wwerror());
                return 0;
        }
        return w;
                return 0;
        }
        return w;
@@ -220,6 +228,36 @@ register struct ww *w;
        }
 }
 
        }
 }
 
+stopwin(w)
+       register struct ww *w;
+{
+       w->ww_stopped = 1;
+       if (w->ww_pty >= 0 && w->ww_ispty)
+               (void) ioctl(w->ww_pty, (int)TIOCSTOP, (char *)0);
+}
+
+startwin(w)
+       register struct ww *w;
+{
+       w->ww_stopped = 0;
+       if (w->ww_pty >= 0 && w->ww_ispty)
+               (void) ioctl(w->ww_pty, (int)TIOCSTART, (char *)0);
+}
+
+sizewin(w, nrow, ncol)
+register struct ww *w;
+{
+       struct ww *back = w->ww_back;
+
+       w->ww_alt.nr = w->ww_w.nr;
+       w->ww_alt.nc = w->ww_w.nc;
+       wwdelete(w);
+       if (wwsize(w, nrow, ncol) < 0)
+               error("Can't resize window: %s.", wwerror());
+       wwadd(w, back);
+       reframe();
+}
+
 waitnl(w)
 struct ww *w;
 {
 waitnl(w)
 struct ww *w;
 {