-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdl_event.c
281 lines (260 loc) · 5.79 KB
/
dl_event.c
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
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
* HypView - (c) - 2006 Philipp Donze
* 2006 - Philipp Donze & Odd Skancke
*
* A replacement hypertext viewer
*
* This file is part of HypView.
*
* HypView 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.
*
* HypView is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HypView; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef __GNUC__
#include <osbind.h>
#else
#include <tos.h>
#endif
#include <gemx.h>
#include "diallib.h"
#include "defs.h"
#if USE_AV_PROTOCOL != NO
#include "include/av.h"
#endif
#if USE_BUBBLEGEM == YES
#include "bubble/bubble.h"
#endif
#if USE_DOCUMENTHISTORY == YES
#include "include/dhst.h"
#endif
extern short _app;
short doneFlag=FALSE, quitApp=FALSE;
void DoKeybd(EVNT *event);
void DoMessage(EVNT *event);
void DoEventDispatch(EVNT *event);
void DoEvent(void);
void DoKeybd(EVNT *event)
{
short ascii=event->key;
#if USE_STGUIDE==YES
short scan=(ascii>>8) & 0xff;
#endif
short kstate=event->kstate;
ConvertKeypress(&ascii,&kstate);
ascii=ascii & 0xff;
if(kstate == (K_CTRL|K_ALT))
{
#if USE_ITEM == YES
if(ascii==' ')
{
FlipIconify();
event->mwhich&=~MU_KEYBD;
}
#endif
}
else if(kstate == (K_CTRL|K_ALT|K_RSHIFT|K_LSHIFT))
{
#if USE_ITEM == YES
if(ascii==' ')
{
short msg[8]={WM_ALLICONIFY,0,0,0,-1,-1,-1,-1}, d;
msg[1]=ap_id;
wind_get(0,WF_TOP, &msg[3],&d, &d, &d);
appl_write(ap_id,16,msg);
event->mwhich&=~MU_KEYBD;
}
#endif
}
else if (kstate == K_CTRL)
{
switch(ascii)
{
case 'Q':
#if USE_MENU==YES
ChooseMenu(ME_FILE, ME_QUIT);
#else
if (_app)
doneFlag=TRUE;
else
RemoveItems();
#endif
event->mwhich&=~MU_KEYBD;
break;
#if USE_ITEM == YES
case 'W':
CycleItems();
event->mwhich&=~MU_KEYBD;
break;
case 'U':
{
short msg[8]={WM_CLOSED,0,0,0,0,0,0,0}, d;
msg[1]=ap_id;
wind_get(0,WF_TOP, &msg[3],&d, &d, &d);
appl_write(ap_id,16,&msg[0]);
event->mwhich&=~MU_KEYBD;
break;
}
#endif
}
}
else if(kstate==0)
{
#if USE_STGUIDE==YES
if(scan == KbHELP) /* HELP */
{
STGuideHelp();
event->mwhich&=~MU_KEYBD;
}
#endif
}
#if USE_GLOBAL_KEYBOARD == YES
if(modal_items<0)
{
if(DoUserKeybd(kstate, scan, ascii))
event->mwhich&=~MU_KEYBD;
}
#endif
#if DEBUG==ON
Debug("Key: %d Scan: %d Ascii: %d -- %c %c %c %c %s%s%s%s%s",
event->key,scan,ascii,ascii,key_table->unshift[scan],
key_table->shift[scan],key_table->caps[scan],
((kstate & K_CTRL) ? ("+CTRL"):("")),
((kstate & K_ALT) ? ("+ALT"):("")),
((kstate & K_LSHIFT) ? ("+LSHIFT"):("")),
((kstate & K_RSHIFT) ? ("+RSHIFT"):("")),
((kstate & 0x10/*KbNUM*/) ? ("+NUM"):("")));
#endif
}
void DoMessage(EVNT *event)
{
if(event->msg[2]>0) /* erweiterte Message ?? */
{
short *xmsg;
xmsg=(short *)Mxalloc(event->msg[2],3); /* Platz vorbereiten */
if(xmsg!=NULL)
{
appl_read(ap_id,event->msg[2],xmsg); /* "Message" lesen */
Mfree(xmsg); /* Speicher freigeben */
}
else
form_alert(1,tree_addr[DIAL_LIBRARY][DI_MEMORY_ERROR].ob_spec.free_string);
}
switch((unsigned short)event->msg[0])
{
#if USE_MENU==YES
case MN_SELECTED:
ChooseMenu(event->msg[3], event->msg[4]);
break;
#endif
case AP_TERM:
quitApp=TRUE;
#if USE_MENU==YES
ChooseMenu(ME_FILE, ME_QUIT);
#else
doneFlag=TRUE;
#endif
break;
#if USE_DRAGDROP==YES
case AP_DRAGDROP:
DragDrop(event->msg);
break;
#endif
#if USE_AV_PROTOCOL != NO
#if USE_AV_PROTOCOL >= 2
case VA_PROTOSTATUS: /* Server bestaetigt Anmeldung */
DoVA_PROTOSTATUS(event->msg);
break;
#endif
#if USE_AV_PROTOCOL == 3
case VA_SETSTATUS:
case VA_FILEFONT:
case VA_CONFONT:
case VA_OBJECT:
case VA_CONSOLEOPEN:
case VA_WINDOPEN:
case VA_PROGSTART:
case VA_DRAGACCWIND:
case VA_COPY_COMPLETE:
case VA_THAT_IZIT:
case VA_DRAG_COMPLETE:
case VA_FONTCHANGED:
case VA_XOPEN:
case VA_VIEWED:
case VA_FILECHANGED:
case VA_FILECOPIED:
case VA_FILEDELETED:
case VA_PATH_UPDATE:
case AV_STARTED:
DoVA_Message(event->msg);
break;
#endif
case VA_START: /* Kommandozeile bergeben */
DoVA_START(event->msg);
break;
case AV_SENDCLICK: /* Mausklick gemeldet (BubbleGEM) */
event->mwhich=MU_BUTTON;
event->mx=event->msg[3];
event->my=event->msg[4];
event->mbutton=event->msg[5];
event->kstate=event->msg[6];
event->mclicks=event->msg[7];
DoEventDispatch(event);
break;
case AV_SENDKEY: /* Tastendruck gemeldet (BubbleGEM) */
event->mwhich=MU_KEYBD;
event->kstate=event->msg[3];
event->key=event->msg[4];
DoEventDispatch(event);
break;
#endif
#if USE_BUBBLEGEM==YES
case BUBBLEGEM_REQUEST:
Bubble(event->msg[4],event->msg[5]);
break;
case BUBBLEGEM_ACK:
break;
#endif
#if USE_DOCUMENTHISTORY == YES
case DHST_ACK:
DhstFree(event->msg);
break;
#endif
#if DEBUG==ON
default:
Debug("Message :%d %x erhalten",event->msg[0],event->msg[0]);
break;
#endif
}
}
void DoEventDispatch(EVNT *event)
{
#if USE_USER_EVENTS == YES
DoUserEvents(event);
#endif
if(event->mwhich & MU_BUTTON)
DoButton(event);
if(event->mwhich & MU_KEYBD)
DoKeybd(event);
#if USE_ITEM == YES
ItemEvent(event);
#endif
if(event->mwhich & MU_MESAG)
DoMessage(event);
}
void DoEvent(void)
{
EVNT event;
EVNT_multi(EVENTS, MBCLICKS, MBMASK, MBSTATE, MBLOCK1, MBLOCK2,
WAIT,&event);
DoEventDispatch(&event);
}