tt_tab moved to ttinit.c
[unix-history] / usr / src / usr.bin / window / cmd3.c
index af694ca..981fcd8 100644 (file)
@@ -1,66 +1,41 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      1.7 83/07/28";
+static char sccsid[] = "@(#)cmd3.c     3.12 %G%";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
+#include "string.h"
 
 
-struct ww *getwin();
-struct ww *openwin();
-char *strtime();
-
-doclose(w)
+c_close(w)
 register struct ww *w;
 {
        char didit = 0;
 register struct ww *w;
 {
        char didit = 0;
-       struct ww *w1;
+       register i;
 
        if (w != 0) {
 
        if (w != 0) {
-               if (w == selwin)
-                       setselwin(0);
-               wwclose(w);
+               closewin(w);
                didit++;
        } else {
                didit++;
        } else {
-               for (w = wwhead; w;) {
-                       if (w == cmdwin) {
-                               w = w->ww_next;
+               for (i = 0; i < NWINDOW; i++) {
+                       if ((w = window[i]) == 0)
                                continue;
                                continue;
-                       }
-                       w = (w1 = w)->ww_next;
-                       if (w1 == selwin)
-                               setselwin(0);
-                       if (w->ww_state == WW_HASPROC && w->ww_pid == 0) {
-                               wwprintf(cmdwin, "%d: pid == 0.  ",
-                                       w->ww_ident);
-                       } else {
-                               wwclose(w1);
-                               didit++;
-                       }
+                       closewin(w);
+                       didit++;
                }
        }
        if (selwin == 0) {
                }
        }
        if (selwin == 0) {
-               for (w = wwhead; w && w == cmdwin; w = w->ww_next)
-                       ;
-               setselwin(w);
+               if (lastselwin != 0)
+                       setselwin(lastselwin);
+               else {
+                       for (i = 0; i < NWINDOW && window[i] == 0; i++)
+                               ;
+                       if (i < NWINDOW)
+                               setselwin(window[i]);
+               }
        }
        if (didit)
                reframe();
 }
 
        }
        if (didit)
                reframe();
 }
 
-/*
-doescape()
-{
-       char buf[2];
-
-       wwputs("New escape character? ", cmdwin);
-       wwsetcursor(WCurRow(cmdwin->ww_win), WCurCol(cmdwin->ww_win));
-       while ((*buf = bgetc()) < 0)
-               bread();
-       buf[1] = 0;
-       setescape(buf);
-       wwputs("\r\n", cmdwin);
-}
-*/
-
 setescape(esc)
 register char *esc;
 {
 setescape(esc)
 register char *esc;
 {
@@ -73,33 +48,13 @@ register char *esc;
                escapec = *esc;
 }
 
                escapec = *esc;
 }
 
-/*
-dolabel()
-{
-       register struct ww *w;
-       char buf[30];
-       char *malloc();
-
-       if ((w = getwin()) == 0)
-               return;
-       wwprintf(cmdwin, "Label for window %d? ", w->ww_ident);
-       bgets(buf, sizeof buf, cmdwin);
-       setlabel(w, buf);
-       wwputs("\r\n", cmdwin);
-}
-*/
-
 setlabel(w, label)
 register struct ww *w;
 char *label;
 {
 setlabel(w, label)
 register struct ww *w;
 char *label;
 {
-       char *malloc();
-
        if (w->ww_label != 0)
        if (w->ww_label != 0)
-               free(w->ww_label);
-       w->ww_label = malloc(strlen(label) + 1);
-       strcpy(w->ww_label, label);
-       wwunframe(w);           /* cover up the old label */
-       wwframe(w);
-       labelwin(w);
+               str_free(w->ww_label);
+       if ((w->ww_label = str_cpy(label)) == 0)
+               return -1;
+       return 0;
 }
 }