-
Notifications
You must be signed in to change notification settings - Fork 6
/
WEDEFAUL.PAS
243 lines (228 loc) · 5.06 KB
/
WEDEFAUL.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
UNIT WEDefaul;
{$DEFINE CAN_OVERLAY}
{$I WEGLOBAL.PAS}
{ -- User Defaults Module for WWIVEdit 2.3
-- Purpose: Allow a user to set up ceartain defaults
-- }
INTERFACE
PROCEDURE EditDefaults;
IMPLEMENTATION
USES WEVars, WEOutput, WEInput, WEString, WEFunc, WEInit, DOS,
WEUser, WEMouse, WEESM;
CONST
Nfields=7;
NStates=5;
MaxKeyFiles = 50;
NReply=2;
ReplyType : ARRAY[0..NReply] OF String[12] = (
'Never','E-Mail Only','Always');
FUNCTION Element(from:string; n:integer):String;
VAR
p:integer;
BEGIN
WHILE n>1 DO
BEGIN
p:=pos('/',from);
dec(n);
delete(from,1,p);
END;
p:=pos('/',from);
IF p>0 THEN delete(from,p,length(from)-p+1);
Element:=from;
END;
PROCEDURE GetScreenState;
VAR
i:integer;
ch:char;
s:string;
BEGIN
NL;
s:=GetS(XSTR+14);
FOR i:=1 TO NStates DO
writeln(C2+'<'+C1+chr(i+64)+C2+'>'+c5+' '+Element(s,i));
writeln(C2+'<'+C1+'Q'+C2+'>'+C5+'uit');
NL;
write(C2+'Choice > [ABCDEQ] ');
ch:=ReadSet(['A'..'E','Q']);
IF ch<>'Q' THEN
BEGIN
ScreenState:=ord(ch)-65;
SetTopScreen(ScreenState);
info.screenstate:=screenstate;
END;
END;
PROCEDURE GetScreenHeight;
VAR s:string;
BEGIN
nl;
XWrite(15);
writeln(C1+cstr(ScreenHeight)+C5+' rows high.');
XWrite(16);
write(' ['+cstr(ScreenHeight)+'] ');
SimpleInput(s,2);
info.screenheight:=value(s);
IF info.screenheight=0 THEN info.screenheight:=ScreenHeight;
ScreenHeight:=info.screenheight;
SetTopScreen(ScreenState); { Forces some things to be recalculated }
END;
PROCEDURE GetInsertMode;
BEGIN
info.insertmode:=NOT info.insertmode;
insertmode:=NOT info.insertmode;
END;
PROCEDURE GetTimingConstant;
VAR
s:string;
BEGIN
nl;
XWritelns(0,3);
XWrite(4);
writeln(Setting.Ticks DIV 100,'.');
nl;
XWrite(5);
SimpleInput(s,3);
IF s<>'' THEN
IF (value(s)>=0) AND (value(s)<256) THEN
BEGIN
info.ticks:=value(s);
ESC_ticks:=info.ticks*100;
IF ESC_ticks=0 THEN ESC_ticks:=setting.ticks;
END;
END;
FUNCTION Usable(FileInfo:KeyInfoRec):boolean;
VAR
ok : boolean;
BEGIN
ok:=(thisuser.sl>=FileInfo.Min_SL);
IF (FileInfo.Local_Only AND NOT Setting.Local) THEN OK:=false;
Usable:=ok;
END;
PROCEDURE GetKeyName;
VAR
sr : SearchRec;
f : File;
Des: KeyInfoRec;
nfound : integer;
Map: ARRAY[1..MaxKeyFiles] OF String[8];
s : string;
choice : integer;
okset: charset;
i : integer;
ch:char;
BEGIN
writeln;
XWriteln(6);
nfound:=0;
FindFirst(ConfigDir+'*'+keyExt,0,sr);
WHILE DOSError=0 DO
BEGIN
assign(f,ConfigDir+sr.name);
reset(f,1);
blockread(f,des,sizeof(des));
close(f);
IF Usable(des) THEN
BEGIN
inc(nfound);
writeln(C1+Cstr(nfound)+'. '+C2+LJustify(FName(sr.Name),8)+
C3+' - '+C1+des.description);
Map[nfound]:=Fname(sr.name);
END;
FindNext(sr);
END;
write(C2,'Choice > [');
okset:=['Q'];
FOR i:=1 TO Nfound DO
BEGIN
okset:=okset+[chr(i+ord('0'))];
write(chr(i+ord('0')));
END;
write('Q] '+C1);
ch:=readset(okset);
choice:=ord(ch)-ord('0');
IF (choice>0) AND (choice<=nfound) THEN
BEGIN
info.KeyFile:=Map[choice];
KeyName:=info.KeyFile;
LoadKeyBindings(KeyName);
END;
END;
PROCEDURE GetReplyStatus;
VAR
i:integer;
okset:charset;
ch:char;
BEGIN
writeln;
XWritelns(7,10);
FOR i:=0 TO NReply DO
writeln(C1,i+1,C3,'. ',c5,ReplyType[i]);
writeln;
XWrite(11);
writeln(Info.AskReply+1);
write(C2+'Choice [');
okset:=['Q'];
FOR i:=0 TO NReply DO
BEGIN
write(chr(i+ord('1')));
okset:=okset+[chr(i+ord('1'))];
END;
write('Q] ');
ch:=readset(okset);
IF ch<>'Q' THEN Info.AskReply:=ord(ch)-ord('1');
END;
PROCEDURE EditDefaults;
VAR
i : integer;
ch : char;
s:string;
BEGIN
REPEAT
clrscr;
IF Setting.Mouse AND MouseInstalled THEN HideMouse;
XWrite(12);
write(C1+VERSION);
XWriteln(13);
NL;
FOR i:=1 TO NFields DO
BEGIN
s:=GetS(Xdefaults+i-1);
s:=s+dup(' ',25-length(s));
write(C2+'<'+C1+chr(i+64)+C2+'>'+c5+' '+s+' '+C3+': '+C1);
CASE i OF
1 : writeln(Element(GetS(XSTR+14),info.ScreenState+1));
2 : BEGIN
write(info.screenheight);
IF info.screenheight=0 THEN write(' (',ScreenHeight,')');
NL;
END;
3 : IF NOT info.InsertMode
THEN XWriteln(17)
ELSE XWriteln(18);
4 : IF Info.ticks>0
THEN writeln(Info.ticks)
ELSE writeln(Setting.ticks);
5 : writeln(TransformString(KeyName));
6 : writeln(ReplyType[Info.AskReply]);
7 : IF info.asktag
THEN writeln('Yes')
ELSE writeln('No');
END;
END;
IF Setting.Mouse AND MouseInstalled THEN ShowMouse;
writeln(C2+'<'+C1+'Q'+C2+'>'+C5+'uit');
NL;
write(C2+'Choice > ');
ch:=ReadSet(['A'..'G','Q']);
NL;
CASE CH OF
'A' : GetScreenState;
'B' : GetScreenHeight;
'C' : GetInsertMode;
'D' : GetTimingConstant;
'E' : GetKeyName;
'F' : GetReplyStatus;
'G' : Info.AskTag:=NOT Info.AskTag;
END;
UNTIL ch='Q';
END;
END.