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