tt_tab moved to ttinit.c
[unix-history] / usr / src / usr.bin / window / cmd3.c
index 6b94d4b..981fcd8 100644 (file)
@@ -1,71 +1,41 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      1.4 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(flag, w)
+c_close(w)
 register struct ww *w;
 {
        char didit = 0;
 register struct ww *w;
 {
        char didit = 0;
+       register i;
 
 
-       switch (flag) {
-       case CLOSE_ONE:
-               if (w == 0)
-                       break;
-               if (w == selwin)
-                       setselwin(0);
-               wwclose(w);
+       if (w != 0) {
+               closewin(w);
                didit++;
                didit++;
-               break;
-       case CLOSE_DEAD:
-       case CLOSE_ALL:
-               for (w = wwhead; w;) {
-                       if (w != cmdwin
-                           && (w->ww_state == WW_DEAD || flag == CLOSE_ALL)) {
-                               struct ww *w1;
-                               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++;
-                               }
-                       } else
-                               w = w->ww_next;
+       } else {
+               for (i = 0; i < NWINDOW; i++) {
+                       if ((w = window[i]) == 0)
+                               continue;
+                       closewin(w);
+                       didit++;
                }
                }
-               break;
        }
        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;
 {
@@ -77,3 +47,14 @@ register char *esc;
        } else
                escapec = *esc;
 }
        } else
                escapec = *esc;
 }
+
+setlabel(w, label)
+register struct ww *w;
+char *label;
+{
+       if (w->ww_label != 0)
+               str_free(w->ww_label);
+       if ((w->ww_label = str_cpy(label)) == 0)
+               return -1;
+       return 0;
+}