Newer
Older
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
/* inkey.cpp */
/* Synchronet single key input function (no wait) */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "sbbs.h"
#define LAST_STAT_LINE 16
#define nosound()
/****************************************************************************/
/* Returns character if a key has been hit remotely and responds */
/* Called from functions getkey, msgabort and main_sec */
/****************************************************************************/
char sbbs_t::inkey(long mode)
{
char str[512];
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
uchar ch=0;
uint i,j;
if(keybuftop!=keybufbot) {
ch=keybuf[keybufbot++];
if(keybufbot==KEY_BUFSIZE)
keybufbot=0;
} else
ch=incom();
if(ch==0) {
if(!(mode&K_GETSTR) || mode&K_LOWPRIO || cfg.node_misc&NM_LOWPRIO)
mswait(1);
return(0);
}
if(cfg.node_misc&NM_7BITONLY
&& (!(sys_status&SS_USERON) || useron.misc&NO_EXASCII))
ch&=0x7f;
timeout=time(NULL);
if(ch==3) { /* Ctrl-C Abort */
sys_status|=SS_ABORT;
if(mode&K_SPIN) /* back space once if on spinning cursor */
bputs("\b \b");
return(0); }
if(ch==26 && action!=NODE_PCHT) { /* Ctrl-Z toggle raw input mode */
if(mode&K_SPIN)
bputs("\b ");
SAVELINE;
attr(LIGHTGRAY);
CRLF;
bputs(text[RawMsgInputModeIsNow]);
if(console&CON_RAW_IN)
bputs(text[OFF]);
else
bputs(text[ON]);
console^=CON_RAW_IN;
CRLF;
CRLF;
RESTORELINE;
lncntr=0;
if(action!=NODE_MAIN && action!=NODE_XFER)
return(26);
return(0); }
if(console&CON_RAW_IN) /* ignore ctrl-key commands if in raw mode */
return(ch);
if(ch<SP) { /* Control chars */
if(ch==LF) /* ignore LF's in not in raw mode */
return(0);
if(ch==15) { /* Ctrl-O toggles pause temporarily */
useron.misc^=UPAUSE;
return(0); }
if(ch==0x10) { /* Ctrl-P Private node-node comm */
if(!(sys_status&SS_USERON))
return(0); /* keep from being recursive */
if(mode&K_SPIN)
bputs("\b ");
if(sys_status&SS_SPLITP) {
#if 0 /* screen size */
if((scrnbuf=(uchar*)MALLOC((24L*80L)*2L))==NULL) {
errormsg(WHERE,ERR_ALLOC,nulstr,(24L*80L)*2L);
return(CR); }
gettext(1,1,80,24,scrnbuf);
x=lclwx();
y=lclwy();
CLS;
#endif
}
else {
SAVELINE;
attr(LIGHTGRAY);
CRLF; }
nodesync(); /* read any waiting messages */
nodemsg(); /* send a message */
SYNC;
if(sys_status&SS_SPLITP) {
#if 0 /* screen size */
lncntr=0;
CLS;
for(i=0;i<((24*80)-1)*2;i+=2) {
if(scrnbuf[i+1]!=curatr)
attr(scrnbuf[i+1]);
outchar(scrnbuf[i]); }
FREE(scrnbuf);
GOTOXY(x,y);
#endif
}
else {
CRLF;
RESTORELINE; }
lncntr=0;
return(0); }
if(ch==21) { /* Ctrl-U Users online */
if(!(sys_status&SS_USERON))
return(0);
if(mode&K_SPIN)
bputs("\b ");
if(sys_status&SS_SPLITP) {
#if 0 /* screen size */
if((scrnbuf=(uchar*)MALLOC((24L*80L)*2L))==NULL) {
errormsg(WHERE,ERR_ALLOC,nulstr,(24L*80L)*2L);
return(CR); }
gettext(1,1,80,24,scrnbuf);
x=lclwx();
y=lclwy();
CLS;
#endif
}
else {
SAVELINE;
attr(LIGHTGRAY);
CRLF; }
whos_online(true); /* list users */
ASYNC;
if(sys_status&SS_SPLITP) {
#if 0 /* screen size */
CRLF;
nodesync();
pause();
CLS;
for(i=0;i<((24*80)-1)*2;i+=2) {
if(scrnbuf[i+1]!=curatr)
attr(scrnbuf[i+1]);
outchar(scrnbuf[i]); }
FREE(scrnbuf);
GOTOXY(x,y);
#endif
}
else {
CRLF;
RESTORELINE; }
lncntr=0;
return(0); }
if(ch==20 && !(sys_status&SS_SPLITP)) { /* Ctrl-T Time information */
if(!(sys_status&SS_USERON))
return(0);
if(mode&K_SPIN)
bputs("\b ");
SAVELINE;
attr(LIGHTGRAY);
now=time(NULL);
bprintf(text[TiLogon],timestr(&logontime));
bprintf(text[TiNow],timestr(&now));
bprintf(text[TiTimeon]
,sectostr(now-logontime,tmp));
bprintf(text[TiTimeLeft]
,sectostr(timeleft,tmp));
SYNC;
RESTORELINE;
lncntr=0;
return(0); }
if(ch==11 && !(sys_status&SS_SPLITP)) { /* Ctrl-k Control key menu */
if(!(sys_status&SS_USERON))
return(0);
if(mode&K_SPIN)
bputs("\b ");
SAVELINE;
attr(LIGHTGRAY);
lncntr=0;
bputs(text[ControlKeyMenu]);
ASYNC;
RESTORELINE;
lncntr=0;
return(0); }
if(ch==ESC && console&CON_R_INPUT) {
if(mode&K_GETSTR)
i=60; // 3 seconds in GETSTR mode
else
i=20; // 1 second otherwise
for(;i && !rioctl(RXBC);i--)
mswait(50);
if(!i) // timed-out waiting for '['
return(ESC);
ch=incom();
if(ch!='[') {
ungetkey(ESC);
ungetkey(ch);
return(0); }
i=j=0;
autoterm|=ANSI; /* <ESC>[x means they have ANSI */
if(!(useron.misc&ANSI) && useron.misc&AUTOTERM && sys_status&SS_USERON
&& useron.number) {
useron.misc|=ANSI;
putuserrec(&cfg,useron.number,U_MISC,8,ultoa(useron.misc,str,16)); }
while(i<10 && j<30) { /* up to 3 seconds */
if(rioctl(RXBC)) {
ch=incom();
if(ch!=';' && !isdigit(ch) && ch!='R') { /* other ANSI */
switch(ch) {
case 'A':
return(0x1e); /* ctrl-^ (up arrow) */
case 'B':
return(LF); /* ctrl-j (dn arrow) */
case 'C':
return(0x6); /* ctrl-f (rt arrow) */
case 'D':
return(0x1d); /* ctrl-] (lf arrow) */
case 'H':
return(0x2); /* ctrl-b (beg line) */
case 'K':
return(0x5); /* ctrl-e (end line) */
}
ungetkey(ESC);
ungetkey('[');
for(j=0;j<i;j++)
ungetkey(str[j]);
ungetkey(ch);
return(0); }
if(ch=='R') { /* cursor position report */
if(i && !(useron.rows)) { /* auto-detect rows */
str[i]=0;
rows=atoi(str);
if(rows<5 || rows>99) rows=24; }
return(0); }
str[i++]=ch; }
else {
mswait(100);
j++; } }
ungetkey(ESC); /* should only get here if time-out */
ungetkey('[');
for(j=0;j<i;j++)
ungetkey(str[j]);
return(0); }
} /* end of control chars */
return(ch);
}