Commit | Line | Data |
---|---|---|
57f965d5 | 1 | #ifndef lint |
57c34fd1 | 2 | static char *sccsid = "@(#)cmd3.c 3.9 84/01/13"; |
57f965d5 EW |
3 | #endif |
4 | ||
5 | #include "defs.h" | |
0d290ee3 EW |
6 | #include "value.h" |
7 | #include "var.h" | |
b2618f9d | 8 | #include "string.h" |
57f965d5 | 9 | |
0d290ee3 EW |
10 | c_variable() |
11 | { | |
7555c083 | 12 | register struct ww *w; |
0d290ee3 EW |
13 | int printvar(); |
14 | ||
7555c083 | 15 | if ((w = openiwin(wwnrow - 3, "Variables")) == 0) { |
0d290ee3 EW |
16 | error("Can't open variable window: %s.", wwerror()); |
17 | return; | |
18 | } | |
7555c083 EW |
19 | if (var_walk(printvar, (int)w) >= 0) |
20 | waitnl(w); | |
21 | closeiwin(w); | |
0d290ee3 EW |
22 | } |
23 | ||
7555c083 EW |
24 | printvar(w, r) |
25 | register struct ww *w; | |
0d290ee3 EW |
26 | register struct var *r; |
27 | { | |
7555c083 EW |
28 | if (more(w, 0) == 2) |
29 | return -1; | |
57c34fd1 | 30 | (void) wwprintf(w, "%16s\t", r->r_name); |
0d290ee3 EW |
31 | switch (r->r_val.v_type) { |
32 | case V_STR: | |
57c34fd1 | 33 | (void) wwprintf(w, "%s\n", r->r_val.v_str); |
0d290ee3 EW |
34 | break; |
35 | case V_NUM: | |
57c34fd1 | 36 | (void) wwprintf(w, "%d\n", r->r_val.v_num); |
0d290ee3 EW |
37 | break; |
38 | case V_ERR: | |
57c34fd1 | 39 | (void) wwprintf(w, "ERROR\n"); |
0d290ee3 EW |
40 | break; |
41 | } | |
7555c083 | 42 | return 0; |
0d290ee3 EW |
43 | } |
44 | ||
85af59e4 | 45 | c_close(w) |
c417b691 | 46 | register struct ww *w; |
57f965d5 | 47 | { |
c417b691 | 48 | char didit = 0; |
85af59e4 | 49 | register i; |
57f965d5 | 50 | |
c0893e4e | 51 | if (w != 0) { |
85af59e4 | 52 | closewin(w); |
c417b691 | 53 | didit++; |
c0893e4e | 54 | } else { |
85af59e4 EW |
55 | for (i = 0; i < NWINDOW; i++) { |
56 | if ((w = window[i]) == 0) | |
c0893e4e | 57 | continue; |
a4c3bba5 | 58 | closewin(w); |
85af59e4 | 59 | didit++; |
57f965d5 | 60 | } |
57f965d5 EW |
61 | } |
62 | if (selwin == 0) { | |
7c0483b9 EW |
63 | if (lastselwin != 0) |
64 | setselwin(lastselwin); | |
65 | else { | |
66 | for (i = 0; i < NWINDOW && window[i] == 0; i++) | |
67 | ; | |
68 | if (i < NWINDOW) | |
69 | setselwin(window[i]); | |
70 | } | |
57f965d5 | 71 | } |
c417b691 EW |
72 | if (didit) |
73 | reframe(); | |
57f965d5 | 74 | } |
0de7ca29 | 75 | |
0de7ca29 EW |
76 | setescape(esc) |
77 | register char *esc; | |
78 | { | |
79 | if (*esc == '^') { | |
80 | if (esc[1] != 0) | |
81 | escapec = esc[1] & 0x1f; | |
82 | else | |
83 | escapec = '^'; | |
84 | } else | |
85 | escapec = *esc; | |
86 | } | |
c0893e4e | 87 | |
c0893e4e EW |
88 | setlabel(w, label) |
89 | register struct ww *w; | |
90 | char *label; | |
91 | { | |
92 | if (w->ww_label != 0) | |
b2618f9d EW |
93 | str_free(w->ww_label); |
94 | if ((w->ww_label = str_cpy(label)) == 0) | |
85af59e4 | 95 | return -1; |
85af59e4 | 96 | return 0; |
c0893e4e | 97 | } |