tt_tab moved to ttinit.c
[unix-history] / usr / src / usr.bin / window / cmd3.c
index faa87b8..981fcd8 100644 (file)
@@ -1,44 +1,60 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      1.1 83/07/18";
+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(c)
+c_close(w)
+register struct ww *w;
 {
 {
-       register struct ww *w;
+       char didit = 0;
+       register i;
 
 
-       switch (c) {
-       case 'c':
-               if ((w = getwin()) == 0)
-                       break;
-               if (w == selwin)
-                       setselwin(0);
-               wwclose(w);
-               break;
-       case 'C':
-       case 'Z':
-               for (w = wwhead; w;) {
-                       if (w != cmdwin
-                           && (w->ww_state == WW_DEAD || c == 'Z')) {
-                               struct ww *w1;
-                               w = (w1 = w)->ww_next;
-                               if (w1 == selwin)
-                                       setselwin(0);
-                               wwclose(w1);
-                       } else
-                               w = w->ww_next;
+       if (w != 0) {
+               closewin(w);
+               didit++;
+       } 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();
+}
+
+setescape(esc)
+register char *esc;
+{
+       if (*esc == '^') {
+               if (esc[1] != 0)
+                       escapec = esc[1] & 0x1f;
+               else
+                       escapec = '^';
+       } 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;
 }
 }