-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPUXMMAIN.c
218 lines (196 loc) · 6.31 KB
/
PUXMMAIN.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
/*PUXMMAIN.c*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
#define EXTERN
/* that is, EXTERN is blank, so PKIN.H will do initial declarations */
#include "PKIN.h"
#include "PKINDLOG.h"
/***** main ****************************************************************/
int main(int argc, char** argv) /*main is of type int !? 130121*/
{
/*Ltestprint = TRUE;*/ /*test option, compile as TRUE to invoke,*/
Ltestprint = 0; /* as FALSE for distribution, can also set in Kludges */
Lerr = 0;
if(Ltestprint) {printf("entered main(argc== %d, argv)\n",argc);}
mainsetup(&argc, argv); /*____INIT.c*/
/*calls beginnings(), then control returns here*/
/*Lnewfile will be set if launched with a file name*/
if(Ltestprint)
{
printf("->loop: Lcommanded %d, Lnewfile %d, Lnewpass %d, Lgetranges %d\n"
,Lcommanded,Lnewfile,Lnewpass,Lgetranges);
}
/*beginning & final endless event loop: program ends sitting here */
/* so messages can be read*/
for (;;)
{/*beginning & final endless event loop*/
mainlooprouter(); /*PKININIT, common router, calls HandleEvent()*/
if(Lerr) break;
if(Lquiet==0) /*was Lcommanded 990402*/
HandleEvent(); /*____MAIN.c*/
}/*beginning & final endless event loop*/
return(0);
}
/*___main()_________________________________________________________________*/
/****HandleEvent()***********************************************************/
/* The main event dispatcher. This routine called */
/* repeatedly by the event-controlled loops, (it handles only one event).*/
void HandleEvent()
{
XEvent theevent;
XtAppNextEvent(app_context,&theevent); /* get the next event */
XtDispatchEvent(&theevent);
}
/*___HandleEvent()__________________________________________________________*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****HandleloopEvent()*******************************************************/
/* Minor event dispatcher, esp. for aborting endless runs. Called */
/* repeatedly by the processing loop, (it handles only one event). */
int HandleloopEvent()
{
int ireturn = 0;
#ifdef UNIX_X11
XEvent theevent;
/*ref: Johnson&Reichard,2nd Ed,Motif,MIS Press,1993, pg 387*/
KeySym keysym;
XComposeStatus compose_status;
int length, size;
char string[10];
#endif
#ifdef MACINTOSH
EventRecord theevent;
int ok = 1;
long charCode = 0;
if(Lappleevents==0) ok = GetNextEvent( everyEvent, &theevent); /*m*/
else ok = WaitNextEvent(everyEvent, &theevent, 0, nil); /*m*/
if(ok)
{/*ok*/
switch (theevent.what)
{/*switch*/
case keyDown:
charin = (theEvent.message & charCodeMask);
if ((theEvent.modifiers & cmdKey) != 0)
{
; /*ignore*/
}
else if (charin != 0) /* meaningful text key */
{
charCode = BitAnd(theEvent.message, charCodeMask);
if(charCode==46) /* . */ /* ascii code */
{
ireturn = 1;
}
}
break;
}/*switch*/
}/*ok*/
return(ireturn);
#endif /*MACINTOSH*/
#ifdef UNIX_X11
if(XtAppPending(app_context)) /*960325*/
{
XtAppNextEvent(app_context,&theevent); /* get the next event */
if(theevent.type == KeyPress)
{
size = 1; /*which is guess work , but really need only one byte*/
length = XLookupString((XKeyEvent*)&theevent
,string,size,&keysym,&compose_status);
if(length>0 && length<=9)
{
string[length] = '\0';
if( string[0] == '.' ) /* '.' program interruption*/
{
ireturn = 1;
}
}
}
}/*960325*/
return(ireturn);
#endif /*UNIX_X11*/
}
/*___HandleloopEvent()______________________________________________________*/
/****getkeydownstate()*******************************************************/
int getkeydownstate()
{
int ireturn;
ireturn = 0;
if(Lquiet==0) /*was Lcommanded before 990402*/
{
if( HandleloopEvent() ) ireturn = 1;
}
return(ireturn);
}
/*___getkeydownstate()______________________________________________________*/
/****makecursoractive()******************************************************/
void makecursoractive()
{
#ifdef UNIX_X11
/*
printf("called makecursoractive() with Lcursoractive==%d, activecursor:%ld\n"
,Lcursoractive,activecursor);
*/
if(Lquiet==0) /*was Lcommanded before 990402*/
{
if(!Lcursoractive)
{
XDefineCursor(dpy,drawWindow,activecursor);
Lcursoractive = 1;
}
}
#endif
#ifdef MACINTOSH
InitCursor(); /*m*/
#endif
#ifdef PCWINDOWS
SetCursor(activecursor); /*????*/
#endif
}
/*___makecursoractive()_____________________________________________________*/
/****makecursorwait()********************************************************/
void makecursorwait()
{
#ifdef UNIX_X11
/*
printf("called makecursorwait() with Lcursoractive==%d, waitcursor:%ld\n"
,Lcursoractive,waitcursor);
*/
if(Lquiet) /*was Lcommanded before 990402*/
{
if(Lcursoractive)
{
XDefineCursor(dpy,drawWindow,waitcursor);
Lcursoractive = 0;
}
}
#endif
#ifdef MACINTOSH
SetCursor(*waitcursor); /*m*/
#endif
#ifdef PCWINDOWS
SetCursor(waitcursor)
#endif
}
/*___makecursorwait()_______________________________________________________*/
/****cursorstandard()*******************************************************/
void cursorstandard()
{
makecursoractive();
}
/*___cursorstandard()______________________________________________________*/
/****cursorshowwait()******************************************************/
void cursorshowwait()
{
makecursorwait();
}
/*___cursorshowwait()_____________________________________________________*/
/****condition()*************************************************************/
void condition(char strg[256]){;}
/*___condition()____________________________________________________________*/
/****recondition()***********************************************************/
void recondition(char strg[256]){;}
/*___recondition()__________________________________________________________*/
/****TickCount()-dummy-******************************************************/
long TickCount()
{
return(0);
}
/*___TickCount()-dummy-_____________________________________________________*/