forked from MarkHofmann11/WWIVEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWECHAT.PAS
268 lines (248 loc) · 5.34 KB
/
WECHAT.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
UNIT WEChat;
{$DEFINE CAN_OVERLAY}
{$I WEGLOBAL.PAS}
{$V-}
{ -- Chat module for WWIVEdit 2.4
-- Written By:
-- Adam Caldwell
--
-- This code is limited Public Domain. See WWIVEDIT.PAS for more details.
--
-- Purpose: To do what was previously un-doable... Create a two
-- way (split screen) color chat, using the BBS I/O routines (and some
-- fancy programming).
-- }
INTERFACE
PROCEDURE Chat(LineLen,ScreenHeight:integer);
IMPLEMENTATION
USES WEKbd, WEString, WEOutput, WEVars, WEInput,WEESM;
PROCEDURE TwoWayChat(Title:string; LineLen,ScreenHeight:integer);
TYPE
stringl=STRING[81];
VAR
ch:char;
x:integer;
s:string;
lastlocal:boolean;
RemoteTop : integer;
lx,ly,rx,ry : integer;
RemoteBottom : integer;
temp : string;
PROCEDURE WordWrap(VAR s1:StringL; VAR s2:string);
VAR
i,x:integer;
BEGIN
s2:='';
x:=length(s1);
WHILE (x>0) AND (NOT (s1[x]=' ')) DO
dec(x);
IF x<>0 THEN
BEGIN
s2 := copy(s1,x+1,length(s1)-x);
moveleft(length(s1)-x);
clreol;
system.delete(s1,x+1,length(s2));
END;
writeln;
END;
PROCEDURE IncRY;
VAR x:integer;
BEGIN
inc(ry);
rx:=1;
IF ry>RemoteBottom THEN
BEGIN
FOR x:=1 TO 4 DO
BEGIN
Screen[RemoteTop+x-1].l:=Screen[RemoteBottom-4+x].l;
gotoxy(1,RemoteTop+x-1);
write(screen[remoteTop+x-1].l);
clreol;
END;
FOR x:=RemoteTop+4 TO RemoteBottom DO
BEGIN
Screen[x].l:='';
gotoxy(1,x);
clreol;
END;
ry:=RemoteTop+4;
rx:=1;
END;
gotoxy(rx,ry);
END;
PROCEDURE IncLY;
VAR x:integer;
BEGIN
inc(ly);
lx:=1;
IF ly>RemoteTop-2 THEN
BEGIN
FOR x:=1 TO 4 DO
BEGIN
Screen[x].l:=Screen[RemoteTop-6+x].l;
gotoxy(1,x);
write(Screen[x].l);
clreol;
END;
FOR x:=5 TO RemoteTop-2 DO
BEGIN
gotoxy(1,x);
Screen[x].l:='';
clreol;
END;
ly:=5;
lx:=1;
END;
gotoxy(lx,ly);
END;
PROCEDURE ControlX(l:integer);
BEGIN
Screen[l].l:='';
gotoxy(1,l);
clreol;
END;
PROCEDURE ControlW(l:integer; VAR x:integer);
BEGIN
WHILE (x>0) AND (screen[l].l[x]<>' ') DO
BEGIN
write(#8#32#8);
dec(x);
END;
screen[l].l[0]:=chr(x);
inc(x);
END;
BEGIN
FOR x:=1 TO MaxPhyLines DO
screen[x].l:='';
clrscr;
lastlocal:=true;
RemoteTop:=ScreenHeight DIV 2;
RemoteBottom := ScreenHeight-2;
lx:=1; ly:=2;
rx:=1; ry:=13;
SeperateLocalInput;
Ansic('7');
write('Chat mode:');
gotoxy(1,RemoteTop-1);
ansic('3');
writeln(dup('=',(LineLen-length(title)) div 2)+c4+Title+c3+dup('=',(LineLen-length(title)) div 2));
ansic('2');
gotoxy(lx,ly);
s:='';
REPEAT
REPEAT UNTIL KeyPressedL OR KeyPressed;
IF KeyPressedL THEN
BEGIN
ch:=readkeyL;
IF not LastLocal THEN
BEGIN
gotoxy(lx,ly);
ansic('2');
LastLocal:=true;
END;
IF NOT (ch IN [#0..#31]) THEN
BEGIN
Screen[ly].l:=Screen[ly].l+ch;
write(ch);
inc(lx);
IF lx>=LineLen THEN
BEGIN
wordwrap(screen[ly].l,temp);
IncLY;
screen[ly].l:=temp;
write(temp);
lx:=length(temp)+1;
END;
END
ELSE IF ch=^X THEN BEGIN ControlX(ly); lx:=1; END
ELSE IF ch=^W THEN ControlW(ly,lx)
ELSE IF ch=#13 THEN IncLY
ELSE IF ch=#27 THEN ch:=#255
ELSE IF ch=#0 THEN BEGIN
ch:=readkeyL;
IF ch=#68 THEN ch:=#255 ELSE ch:=#0;
END
ELSE IF ch=#8 THEN
IF lx>1 THEN BEGIN
dec(lx);
write(#8#32#8);
delete(Screen[ly].l,lx,1);
END
END
ELSE IF KeyPressed THEN
BEGIN
ch:=readkey;
IF lastlocal THEN
BEGIN
gotoxy(rx,ry);
ansic('1');
LastLocal:=false;
END;
IF NOT (Ch IN [#0..#31,#255]) THEN
BEGIN
Screen[ry].l:=Screen[ry].l+ch;
write(ch);
inc(rx);
IF rx>=LineLen THEN
BEGIN
wordwrap(screen[ry].l,temp);
incRY;
screen[ry].l:=temp;
write(temp);
rx:=length(temp)+1;
END;
END
ELSE IF ch=^X THEN BEGIN ControlX(ry); rx:=1; END
ELSE IF ch=^W THEN ControlW(ry,rx)
ELSE IF ch=#13 THEN IncRY
ELSE IF ch=#8 THEN
IF rx>1 THEN BEGIN
dec(rx);
write(#8#32#8);
delete(screen[ry].l,rx,1);
END
END
UNTIL ch=#255;
MergeLocalInput;
END;
PROCEDURE SafeChat(LineLen:integer);
VAR
ch:char;
done:boolean;
BEGIN
clrscr;
writeln(C7+'Chat Mode:');
Ansic('0');
REPEAT
ch:=readkey;
CASE ch OF
#13 : write(#13#10);
#8 : write(#8#32);
END;
IF ch=#0 THEN BEGIN
ch:=readkey;
done:=ch=#68;
END ELSE
IF ch=#27 THEN BEGIN
ch:=GetKey(True);
IF ch=#0 Then Done:=true
ELSE ch:=Readkey;
END
ELSE IF NOT (ch IN [#27,#13,#10]) THEN write(ch);
UNTIL done;
END;
PROCEDURE Chat(LineLen,ScreenHeight:integer);
{ Calls TwoWayChat, and then restores the screen afterwards }
VAR
ch:char;
BEGIN
ch:=DisplayColor;
IF (ScreenSize Div 160<27) AND (ScreenHeight>24) THEN ScreenHeight:=24;
IF Setting.ChatMode=0 THEN
TwoWayChat(Gets(XSTR+26),LineLen,ScreenHeight)
ELSE
SafeChat(LineLen);
ansic(ch);
ForcedRedisplay;
END;
END.