comparison spopt.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
comparison
equal deleted inserted replaced
2:fba0b6e6cdc7 3:5a977ccbc7a9
1 /* $Id: spopt.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */
2
3 #ifdef SHORT_PACKETS
4 /*
5 */
6 #include "copyright.h"
7
8 #include <stdio.h>
9 #include <ctype.h>
10 #include "Wlib.h"
11 #include "defs.h"
12 #include "struct.h"
13 #include "data.h"
14 #include "packets.h"
15
16 /*
17 * Refresh item i
18 */
19
20 void
21 sprefresh(i)
22 int i;
23 {
24 char buf[BUFSIZ];
25
26 switch (i) {
27
28 case SPK_VFIELD:
29 sprintf(buf, "%seceive variable and short packets",
30 recv_short ? "R" : "Don't r");
31 break;
32 case SPK_MFIELD:
33 sprintf(buf, "%seceive messages", recv_mesg ? "R" : "Don't r");
34 break;
35 case SPK_KFIELD:
36 sprintf(buf, "%seceive kill messages", recv_kmesg ? "R" : "Don't r");
37 break;
38 case SPK_WFIELD:
39 sprintf(buf, "%seceive warning messages", recv_warn ? "R" : "Don't r");
40 break;
41 case SPK_TFIELD:
42 sprintf(buf, "Receive threshold: %s_", recv_threshold_s);
43 break;
44 case SPK_WHYFIELD:
45 sprintf(buf, "%sdd why dead messages", why_dead ? "A" : "Don't a");
46 break;
47 case SPK_DONE:
48 sprintf(buf, "Done");
49 break;
50 }
51
52 W_WriteText(spWin, 0, i, textColor, buf, strlen(buf), 0);
53 }
54
55 void
56 spwindow()
57 {
58 register int i;
59
60 for (i = 0; i < SPK_NUMFIELDS; i++)
61 sprefresh(i);
62
63 /* Map window */
64 W_MapWindow(spWin);
65 }
66
67 void
68 spdone()
69 {
70 /* Unmap window */
71 W_UnmapWindow(spWin);
72 }
73
74 void
75 spaction(data)
76 W_Event *data;
77 {
78 int v;
79 register int i;
80 register char *cp;
81
82 switch (data->y) {
83
84 case SPK_VFIELD:
85 if (data->type == W_EV_BUTTON) {
86 if (recv_short)
87 sendShortReq(SPK_VOFF);
88 else
89 sendShortReq(SPK_VON);
90 }
91 break;
92
93 case SPK_MFIELD:
94 if (data->type == W_EV_BUTTON) {
95 if (recv_mesg)
96 sendShortReq(SPK_MOFF);
97 else
98 sendShortReq(SPK_MON);
99 }
100 break;
101
102 case SPK_KFIELD:
103 if (data->type == W_EV_BUTTON) {
104 if (recv_kmesg)
105 sendShortReq(SPK_M_NOKILLS);
106 else
107 sendShortReq(SPK_M_KILLS);
108 }
109 break;
110
111 case SPK_WFIELD:
112 if (data->type == W_EV_BUTTON) {
113 if (recv_warn)
114 sendShortReq(SPK_M_NOWARN);
115 else
116 sendShortReq(SPK_M_WARN);
117 }
118 break;
119
120 case SPK_TFIELD:
121 if (data->type == W_EV_KEY) {
122 switch (data->key) {
123 case '\b':
124 case '\177':
125 cp = recv_threshold_s;
126 i = strlen(cp);
127 if (i > 0) {
128 cp += i - 1;
129 *cp = '\0';
130 }
131 break;
132 case '\025':
133 case '\030':
134 recv_threshold_s[0] = '\0';
135 break;
136
137 default:
138 if (data->key >= '0' && data->key <= '9') {
139 cp = recv_threshold_s;
140 i = strlen(cp);
141 if (i < 4) {
142 cp += i;
143 cp[1] = '\0';
144 cp[0] = data->key;
145 }
146 }
147 break;
148 }
149 sprefresh(SPK_TFIELD);
150 }
151 break;
152
153 case SPK_WHYFIELD:
154 if (F_feature_packets && data->type == W_EV_BUTTON) {
155 if (why_dead)
156 sendFeature("WHY_DEAD", 'S', 0, 0, 0);
157 else
158 sendFeature("WHY_DEAD", 'S', 1, 0, 0);
159 }
160 break;
161 case SPK_DONE:
162
163 if (data->type == W_EV_BUTTON) {
164 if (sscanf(recv_threshold_s, "%d", &v) != 1)
165 strcpy(recv_threshold_s, "0");
166 else if (recv_threshold != v) {
167 recv_threshold = v;
168 sendThreshold(recv_threshold);
169 }
170 spdone();
171 }
172 break;
173
174 }
175 }
176
177 #endif