Add define for Kirk Smith's USR Courier driver. Change default baud
[unix-history] / usr / src / usr.bin / window / win.c
index deb748c..3c3adab 100644 (file)
@@ -1,8 +1,15 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)win.c       3.6 84/04/07";
+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 "defs.h"
+#include "char.h"
 
 /*
  * Higher level routines for dealing with windows.
 
 /*
  * Higher level routines for dealing with windows.
@@ -24,8 +31,10 @@ static       char *sccsid = "@(#)win.c       3.6 84/04/07";
  * 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;
 
@@ -36,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);
@@ -58,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;
@@ -112,6 +121,8 @@ char *label;
        w->ww_mapnl = 1;
        w->ww_hasframe = 1;
        w->ww_nointr = 1;
        w->ww_mapnl = 1;
        w->ww_hasframe = 1;
        w->ww_nointr = 1;
+       w->ww_noupdate = 1;
+       w->ww_unctrl = 1;
        w->ww_id = -1;
        w->ww_center = 1;
        (void) setlabel(w, label);
        w->ww_id = -1;
        w->ww_center = 1;
        (void) setlabel(w, label);
@@ -217,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;
 {
@@ -228,23 +269,30 @@ register struct ww *w;
 char always;
 {
        int c;
 char always;
 {
        int c;
+       char uc = w->ww_unctrl;
 
        if (!always && w->ww_cur.r < w->ww_w.b - 2)
                return 0;
        c = waitnl1(w, "[Type escape to abort, any other key to continue]");
 
        if (!always && w->ww_cur.r < w->ww_w.b - 2)
                return 0;
        c = waitnl1(w, "[Type escape to abort, any other key to continue]");
+       w->ww_unctrl = 0;
        wwputs("\033E", w);
        wwputs("\033E", w);
-       return c == CTRL([) ? 2 : 1;
+       w->ww_unctrl = uc;
+       return c == ctrl([) ? 2 : 1;
 }
 
 waitnl1(w, prompt)
 register struct ww *w;
 char *prompt;
 {
 }
 
 waitnl1(w, prompt)
 register struct ww *w;
 char *prompt;
 {
+       char uc = w->ww_unctrl;
+
+       w->ww_unctrl = 0;
        front(w, 0);
        wwprintf(w, "\033Y%c%c\033p%s\033q ",
                w->ww_w.nr - 1 + ' ', ' ', prompt);     /* print on last line */
        wwcurtowin(w);
        while (wwpeekc() < 0)
                wwiomux();
        front(w, 0);
        wwprintf(w, "\033Y%c%c\033p%s\033q ",
                w->ww_w.nr - 1 + ' ', ' ', prompt);     /* print on last line */
        wwcurtowin(w);
        while (wwpeekc() < 0)
                wwiomux();
+       w->ww_unctrl = uc;
        return wwgetc();
 }
        return wwgetc();
 }