organized debugging commands
[unix-history] / usr / src / usr.bin / window / cmd3.c
CommitLineData
57f965d5 1#ifndef lint
2b0da92e 2static char *sccsid = "@(#)cmd3.c 3.2 83/08/15";
57f965d5
EW
3#endif
4
5#include "defs.h"
6
85af59e4 7c_close(w)
c417b691 8register struct ww *w;
57f965d5 9{
c417b691 10 char didit = 0;
85af59e4 11 register i;
57f965d5 12
c0893e4e 13 if (w != 0) {
85af59e4 14 closewin(w);
c417b691 15 didit++;
c0893e4e 16 } else {
85af59e4
EW
17 for (i = 0; i < NWINDOW; i++) {
18 if ((w = window[i]) == 0)
c0893e4e 19 continue;
85af59e4
EW
20 closewin(w); /* GROT */
21 didit++;
57f965d5 22 }
57f965d5
EW
23 }
24 if (selwin == 0) {
2b0da92e 25 for (i = 0; i < NWINDOW && window[i] == 0; i++)
57f965d5 26 ;
85af59e4
EW
27 if (i < NWINDOW)
28 setselwin(window[i]);
57f965d5 29 }
c417b691
EW
30 if (didit)
31 reframe();
57f965d5 32}
0de7ca29 33
85af59e4
EW
34closewin(w)
35register struct ww *w;
0de7ca29 36{
85af59e4
EW
37 if (w == selwin)
38 setselwin((struct ww *)0);
39 if (w->ww_id >= 0 && w->ww_id < NWINDOW)
40 window[w->ww_id] = 0;
41 if (w->ww_label)
42 free(w->ww_label);
43 wwdelete(w);
44 wwclose(w);
0de7ca29
EW
45}
46
47setescape(esc)
48register char *esc;
49{
50 if (*esc == '^') {
51 if (esc[1] != 0)
52 escapec = esc[1] & 0x1f;
53 else
54 escapec = '^';
55 } else
56 escapec = *esc;
57}
c0893e4e 58
c0893e4e
EW
59setlabel(w, label)
60register struct ww *w;
61char *label;
62{
bc326b22
EW
63 char *malloc();
64
c0893e4e
EW
65 if (w->ww_label != 0)
66 free(w->ww_label);
85af59e4
EW
67 if ((w->ww_label = malloc((unsigned)strlen(label) + 1)) == 0)
68 return -1;
69 (void) strcpy(w->ww_label, label);
70 return 0;
c0893e4e 71}