Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / sources / int / herc.c
1 /*     Loglan82 Compiler&Interpreter\r
2      Copyright (C) 1993 Institute of Informatics, University of Warsaw\r
3      Copyright (C)  1993, 1994 LITA, Pau\r
4      \r
5      This program is free software; you can redistribute it and/or modify\r
6      it under the terms of the GNU General Public License as published by\r
7      the Free Software Foundation; either version 2 of the License, or\r
8      (at your option) any later version.\r
9      \r
10      This program is distributed in the hope that it will be useful,\r
11      but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13      GNU General Public License for more details.\r
14      \r
15              You should have received a copy of the GNU General Public License\r
16              along with this program; if not, write to the Free Software\r
17              Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
18 \r
19  contacts:  Andrzej.Salwicki@univ-pau.fr\r
20 \r
21 or             Andrzej Salwicki\r
22                 LITA   Departement d'Informatique\r
23                 Universite de Pau\r
24                 Avenue de l'Universite\r
25                 64000 Pau   FRANCE\r
26                  tel.  ++33 59923154    fax. ++33 59841696\r
27 \r
28 =======================================================================\r
29 */\r
30 \r
31 #include "nonstand.h"\r
32 \r
33 typedef int word;\r
34 \r
35 #include <X11/cursorfont.h>\r
36 #include <X11/keysym.h>\r
37 \r
38 /*#include <X11/Xos.h>*/\r
39 #include <X11/Xlib.h>\r
40 #include <X11/Xutil.h>\r
41 #include <X11/Xatom.h>\r
42 \r
43 #include <X11/MwmUtil.h>\r
44 \r
45 #include <stdio.h>\r
46 #include <math.h>\r
47 #include <ctype.h>\r
48 \r
49 XSizeHints    theHints;\r
50 Display       *theDisp;\r
51 int           theDepth, theScreen, dispcells;\r
52 Colormap      theCmap;\r
53 Window        rootW, window, father;\r
54 GC            theGC;\r
55 unsigned long fcol,bcol,white,black,style=1;\r
56 Font          mfont;\r
57 XFontStruct   *mfinfo;\r
58 Visual        *theVisual;\r
59 XImage        *theImage;\r
60 XClientMessageEvent toFatherEv;\r
61 XEvent event;\r
62 Cursor theCursor;\r
63 \r
64 int iWIDE,iHIGH;\r
65 int mouse_x=0,mouse_y=0,mouse_l=0,mouse_r=0,mouse_c=0,\r
66                         mouse_l_prs=0,mouse_r_prs=0,mouse_c_prs=0,\r
67                         mouse_l_p_x=0,mouse_r_p_x=0,mouse_c_p_x=0,\r
68                         mouse_l_p_y=0,mouse_r_p_y=0,mouse_c_p_y=0,\r
69                         mouse_l_rel=0,mouse_r_rel=0,mouse_c_rel=0,\r
70                         mouse_l_r_x=0,mouse_r_r_x=0,mouse_c_r_x=0,\r
71                         mouse_l_r_y=0,mouse_r_r_y=0,mouse_c_r_y=0;\r
72 int tracking=0;\r
73 #define END_OF_TRACK -9999\r
74 \r
75 Pixmap pixmap;\r
76 \r
77 #define get_shrt(w)  w=(int)(*(pars++));\r
78 #define get_word(w)  w=((int)(pars[0])&0xffff)|((int)pars[1]<<16); pars+=2;\r
79 \r
80 #define put_shrt(w)  toFatherEv.data.s[cnt++] = (short)(w);\r
81 #define put_word(w)  toFatherEv.data.s[cnt++] = (short)((w) & 0xffff); \\r
82                      toFatherEv.data.s[cnt++] = (short)(((w) >> 16) & 0xffff);\r
83 #define snd_father   toFatherEv.type=ClientMessage;     \\r
84                      toFatherEv.format = 16;            \\r
85                      XSendEvent(theDisp,father,False,NoEventMask,&toFatherEv); \\r
86                      XFlush(theDisp);\r
87 \r
88 #ifndef NO_PROTOTYPES\r
89 void RealiseCmd(int,short *);\r
90 #else\r
91 void RealiseCmd();\r
92 #endif\r
93 \r
94 \r
95 static char *application_name="IIUWGRAPH";\r
96 \r
97 \r
98 #define QSIZE 256\r
99 static KeySym keycodes[QSIZE];\r
100 static int keyhead=0,keytail=0;\r
101 \r
102 main(argc, argv)\r
103     int   argc;\r
104     char *argv[];\r
105 {\r
106    int w=0;\r
107    int i;\r
108    int events=0;\r
109 \r
110    father = atoi(argv[1]);\r
111 \r
112    for( i=2; i<argc; i++ )  argv[i-1]=argv[i];\r
113    argc--;\r
114 \r
115    if ((theDisp = XOpenDisplay(NULL)) == NULL){\r
116       fprintf (stderr,"\n%s:  Can't open display\n", argv[0]);\r
117       exit(1);\r
118    }\r
119 \r
120    theScreen = DefaultScreen(theDisp);\r
121    theDepth  = DefaultDepth(theDisp, theScreen);\r
122    rootW     = RootWindow(theDisp,theScreen);\r
123    fcol=white= WhitePixel(theDisp,theScreen);\r
124    bcol=black= BlackPixel(theDisp,theScreen);\r
125    theVisual = DefaultVisual(theDisp,theScreen);\r
126    theCmap   = XCreateColormap(theDisp,rootW,theVisual,AllocNone);\r
127    dispcells = DisplayCells(theDisp, theScreen);\r
128    theCursor = XCreateFontCursor(theDisp,XC_arrow);\r
129 \r
130    iWIDE = 720;  iHIGH = 348;\r
131 \r
132    if ((mfinfo = XLoadQueryFont(theDisp,"fixed"))==NULL){\r
133       fprintf (stderr,"\n%s:  Can't open 'fixed' font\n", argv[0]);\r
134       exit(1);\r
135    }\r
136    mfont=mfinfo->fid;\r
137 \r
138    theHints.width =iWIDE;\r
139    theHints.height=iHIGH;\r
140    theHints.flags=PSize;\r
141    window = XCreateSimpleWindow(theDisp,rootW,10,10,iWIDE,iHIGH,3,fcol,bcol);\r
142 \r
143    XSetStandardProperties(theDisp,window,"HERCULES","HERCULES",\r
144                           None,argv,argc,theHints);\r
145    XDefineCursor(theDisp,window,theCursor);\r
146 \r
147    XChangeProperty(theDisp,window,XA_WM_CLASS,XA_STRING,8,PropModeReplace,\r
148                    application_name,strlen(application_name));\r
149 \r
150    {\r
151       struct {\r
152          long   flags;\r
153          long   functions;\r
154          long   decorations;\r
155          int    input_mode;\r
156       } hints;\r
157       Atom a=XInternAtom(theDisp,_XA_MWM_HINTS,False);\r
158       hints.flags       =   MWM_HINTS_FUNCTIONS;\r
159       hints.functions   =   MWM_FUNC_CLOSE | MWM_FUNC_MOVE;\r
160       hints.decorations =   0;\r
161       hints.input_mode  =   0;\r
162       XChangeProperty(theDisp,window,a,a,32,PropModeReplace,&hints,4);\r
163    }\r
164 \r
165    theGC = XCreateGC(theDisp,window,0,0);\r
166    XSetFont(theDisp,theGC,mfont);\r
167    XSetForeground(theDisp,theGC,fcol);\r
168    XSetBackground(theDisp,theGC,bcol);\r
169 \r
170    XSelectInput(theDisp,window,\r
171                 ExposureMask |\r
172                 KeyPressMask |\r
173                 PointerMotionMask |\r
174                 ButtonPressMask |\r
175                 ButtonReleaseMask\r
176                );\r
177    XMapRaised(theDisp,window);\r
178 \r
179    pixmap = XCreatePixmap(theDisp,window,iWIDE,iHIGH,theDepth);\r
180 \r
181    for(;;){\r
182 \r
183       XNextEvent(theDisp,&event);\r
184 \r
185       switch (event.type){\r
186 \r
187          case Expose:\r
188             {\r
189                int x=event.xexpose.x;\r
190                int y=event.xexpose.y;\r
191                int w=event.xexpose.width;\r
192                int h=event.xexpose.height;\r
193                int cnt=0;\r
194                XCopyArea(theDisp,pixmap,window,theGC,x,y,w,h,x,y);\r
195                if( events==0 ){\r
196                   put_word(window);\r
197                   snd_father\r
198                }\r
199                events=1;\r
200             }\r
201             break;\r
202 \r
203          case ClientMessage:\r
204             RealiseCmd( (int)(event.xclient.message_type),event.xclient.data.s);\r
205             break;\r
206 \r
207          case MappingNotify:\r
208             if( event.xmapping.request == MappingModifier  ||\r
209                 event.xmapping.request == MappingKeyboard )\r
210             XRefreshKeyboardMapping(&event);\r
211             break;\r
212 \r
213          case KeyPress:\r
214             {\r
215                KeySym key;\r
216                char ch;\r
217                int i=XLookupString( &(event.xkey), &ch, 1, &key, NULL );\r
218 \r
219                if( i>0 )\r
220                   if( ch == '\177' )   keycodes[ keytail++ ] = -83;\r
221                   else                 keycodes[ keytail++ ] = (int)ch;\r
222                else\r
223                if( key == NoSymbol )  break;\r
224                else\r
225                if( IsModifierKey( key ) )  break;\r
226                else\r
227                {\r
228                   int to_return = 0;\r
229                   switch( key ){\r
230                      case XK_F1    : to_return = -59; break;\r
231                      case XK_F2    : to_return = -60; break;\r
232                      case XK_F3    : to_return = -61; break;\r
233                      case XK_F4    : to_return = -62; break;\r
234                      case XK_F5    : to_return = -63; break;\r
235                      case XK_F6    : to_return = -64; break;\r
236                      case XK_F7    : to_return = -65; break;\r
237                      case XK_F8    : to_return = -66; break;\r
238                      case XK_F9    : to_return = -67; break;\r
239                      case XK_F10   : to_return = -68; break;\r
240                      case XK_Home  : to_return = -71; break;\r
241                      case XK_Left  : to_return = -75; break;\r
242                      case XK_Up    : to_return = -72; break;\r
243                      case XK_Right : to_return = -77; break;\r
244                      case XK_Down  : to_return = -80; break;\r
245                      case XK_End   : to_return = -79; break;\r
246                      case XK_Insert: to_return = -82; break;\r
247                      case XK_Break : to_return =  -3; break;\r
248                      case XK_Prior : to_return = -73; break;\r
249                      case XK_Next  : to_return = -81; break;\r
250                   }\r
251                   if( to_return!=0 )   keycodes[ keytail++ ] = to_return;\r
252                   else break;\r
253                }\r
254 \r
255                if( keytail == QSIZE ) keytail = 0;\r
256                if( keytail == keyhead ){\r
257                   keytail -- ;\r
258                   if( keytail < 0 )  keytail = QSIZE ;\r
259                }\r
260             }\r
261             break;\r
262 \r
263          case MotionNotify:\r
264          case ButtonPress:\r
265          case ButtonRelease:\r
266             mouse_x = event.xmotion.x;\r
267             mouse_y = event.xmotion.y;\r
268             if( event.type == ButtonPress ){\r
269                switch( event.xbutton.button ){\r
270                   case Button1 : mouse_l=1; mouse_l_prs++;\r
271                                  mouse_l_p_x = mouse_x;\r
272                                  mouse_l_p_y = mouse_y;\r
273                                  if( tracking ){\r
274                                     tracking = 0;\r
275                                     RealiseCmd( END_OF_TRACK, NULL );\r
276                                  }\r
277                                  break;\r
278                   case Button2 : mouse_c=1; mouse_c_prs++;\r
279                                  mouse_c_p_x = mouse_x;\r
280                                  mouse_c_p_y = mouse_y;\r
281                                  break;\r
282                   case Button3 : mouse_r=1; mouse_r_prs++;\r
283                                  mouse_r_p_x = mouse_x;\r
284                                  mouse_r_p_y = mouse_y;\r
285                                  break;\r
286                }\r
287             }\r
288             if( event.type == ButtonRelease ){\r
289                switch( event.xbutton.button ){\r
290                   case Button1 : mouse_l=0; mouse_l_rel++;\r
291                                  mouse_l_r_x = mouse_x;\r
292                                  mouse_l_r_y = mouse_y;\r
293                                  break;\r
294                   case Button2 : mouse_c=0; mouse_c_rel++;\r
295                                  mouse_c_r_x = mouse_x;\r
296                                  mouse_c_r_y = mouse_y;\r
297                                  break;\r
298                   case Button3 : mouse_r=0; mouse_r_rel++;\r
299                                  mouse_r_r_x = mouse_x;\r
300                                  mouse_r_r_y = mouse_y;\r
301                                  break;\r
302                }\r
303             }\r
304             break;\r
305 \r
306       } /* end of switch */\r
307 \r
308    } /* end of for */\r
309 \r
310 }\r
311 \r
312 \r
313 \r
314 word cmd=0,w,h,x,y,curx,cury,kolb,wwyp,p,q,r,color;\r
315 word alfa,beta,aspect;\r
316 char c;\r
317 XImage *image;\r
318 XImage *XGetImage();\r
319 \r
320 \r
321 \r
322 void RealiseCmd( cmd, pars ) int cmd; short *pars; {\r
323 \r
324    int i=1;\r
325    int cnt=0;\r
326 \r
327    switch( cmd ){\r
328 \r
329       case CLS :\r
330          XSetForeground(theDisp,theGC,bcol);\r
331          XFillRectangle(theDisp,pixmap,theGC,0,0,iWIDE,iHIGH);\r
332          XFillRectangle(theDisp,window,theGC,0,0,iWIDE,iHIGH);\r
333          XSetForeground(theDisp,theGC,fcol);\r
334          break;\r
335 \r
336       case GROFF :\r
337          XFreePixmap(theDisp,pixmap);\r
338          XDestroyWindow(theDisp,window);\r
339          XCloseDisplay(theDisp);\r
340          exit(0);\r
341          break;\r
342 \r
343       case INKEY :\r
344          {\r
345             int keycode=0;\r
346             if( keyhead != keytail ){\r
347                keycode  = keycodes[ keyhead++ ];\r
348                if( keyhead == QSIZE )  keyhead = 0;\r
349             }\r
350             put_word(keycode)\r
351             snd_father\r
352          }\r
353          break;\r
354 \r
355       case POINT :\r
356          get_shrt( x );\r
357          get_shrt( y );\r
358          XDrawPoint(theDisp,pixmap,theGC,x,y);\r
359          XDrawPoint(theDisp,window,theGC,x,y);\r
360          break;\r
361 \r
362       case DRAW :\r
363          get_shrt( curx );\r
364          get_shrt( cury );\r
365          get_shrt( x );\r
366          get_shrt( y );\r
367          XDrawLine(theDisp,pixmap,theGC,curx,cury,x,y);\r
368          XDrawLine(theDisp,window,theGC,curx,cury,x,y);\r
369          break;\r
370 \r
371       case CIRB :\r
372          get_shrt( x );\r
373          get_shrt( y );\r
374          get_shrt( r );\r
375          get_shrt( aspect );\r
376          get_shrt( alfa );\r
377          get_shrt( beta );\r
378          XDrawArc(theDisp,pixmap,theGC,x,y,r,aspect,alfa,beta);\r
379          XDrawArc(theDisp,window,theGC,x,y,r,aspect,alfa,beta);\r
380          break;\r
381 \r
382       case HFILL :\r
383          get_shrt( curx );\r
384          get_shrt( cury );\r
385          get_shrt( x );\r
386          XDrawLine(theDisp,pixmap,theGC,curx,cury,x,cury);\r
387          XDrawLine(theDisp,window,theGC,curx,cury,x,cury);\r
388          break;\r
389 \r
390       case VFILL :\r
391          get_shrt( curx );\r
392          get_shrt( cury );\r
393          get_shrt( y );\r
394          XDrawLine(theDisp,pixmap,theGC,curx,cury,curx,y);\r
395          XDrawLine(theDisp,window,theGC,curx,cury,curx,y);\r
396          break;\r
397 \r
398       case INPIX :\r
399          get_shrt( x );\r
400          get_shrt( y );\r
401          image=XGetImage(theDisp,pixmap,x,y,1,1,0x7fffffffL,ZPixmap);\r
402          color = XGetPixel(image,0,0);\r
403          XDestroyImage(image);\r
404          put_word(color)\r
405          snd_father\r
406          break;\r
407 \r
408       case GETMAP :\r
409          {\r
410             Pixmap map;\r
411             get_shrt( x );\r
412             get_shrt( y );\r
413             get_shrt( w );\r
414             get_shrt( h );\r
415             if( w>iWIDE ) w=iWIDE;\r
416             if( h>iHIGH ) h=iHIGH;\r
417             map = XCreatePixmap(theDisp,window,w,h,theDepth);\r
418             XCopyArea(theDisp,pixmap,map,theGC,x,y,w,h,0,0);\r
419             put_word(map)\r
420             snd_father\r
421          }\r
422          break;\r
423 \r
424       case PUTMAP :\r
425       case XORMAP :\r
426       case  ORMAP :\r
427          {\r
428             Pixmap map;\r
429             switch( cmd ){\r
430                case XORMAP: XSetFunction(theDisp,theGC,GXxor); break;\r
431                case  ORMAP: XSetFunction(theDisp,theGC,GXor ); break;\r
432             }\r
433             get_word( map );\r
434             get_shrt( curx );\r
435             get_shrt( cury );\r
436             get_shrt( w );\r
437             get_shrt( h );\r
438             if( w>iWIDE ) w=iWIDE;\r
439             if( h>iHIGH ) h=iHIGH;\r
440             XCopyArea(theDisp,map,pixmap,theGC,0,0,w,h,curx,cury);\r
441             XCopyArea(theDisp,map,window,theGC,0,0,w,h,curx,cury);\r
442             if( cmd != PUTMAP )  XSetFunction(theDisp,theGC,GXcopy);\r
443          }\r
444          break;\r
445 \r
446       case COLOR :\r
447          get_shrt( color );\r
448          if( color == 0 )  fcol = black ;\r
449          else              fcol = white ;\r
450          XSetForeground(theDisp,theGC,fcol);\r
451          break;\r
452 \r
453       case BORDER :\r
454          get_shrt( color );\r
455          if( color == 0 )  bcol = black ;\r
456          else              bcol = white ;\r
457          XSetBackground(theDisp,theGC,bcol);\r
458          break;\r
459 \r
460       case STYLE :\r
461       {\r
462          static char style_2[]={ 6, 3 };\r
463          static char style_3[]={ 4, 6 };\r
464          static char style_4[]={ 2, 3 };\r
465          static char style_5[]={ 2, 9 };\r
466 \r
467          get_shrt( style );\r
468          switch( style ){\r
469             case 0:\r
470                XSetForeground(theDisp,theGC,bcol);\r
471                XSetLineAttributes(theDisp,theGC,0,LineSolid,CapButt,JoinMiter);\r
472                break;\r
473             case 1:\r
474                XSetForeground(theDisp,theGC,fcol);\r
475                XSetLineAttributes(theDisp,theGC,0,LineSolid,CapButt,JoinMiter);\r
476                break;\r
477             case 2:\r
478                XSetLineAttributes(theDisp,theGC,0,LineDoubleDash,\r
479                                   CapButt,JoinMiter);\r
480                XSetDashes(theDisp,theGC,0,style_2,2);\r
481                break;\r
482             case 3:\r
483                XSetLineAttributes(theDisp,theGC,0,LineDoubleDash,\r
484                                   CapButt,JoinMiter);\r
485                XSetDashes(theDisp,theGC,0,style_3,2);\r
486                break;\r
487             case 4:\r
488                XSetLineAttributes(theDisp,theGC,0,LineDoubleDash,\r
489                                   CapButt,JoinMiter);\r
490                XSetDashes(theDisp,theGC,0,style_4,2);\r
491                break;\r
492             case 5:\r
493                XSetLineAttributes(theDisp,theGC,0,LineDoubleDash,\r
494                                   CapButt,JoinMiter);\r
495                XSetDashes(theDisp,theGC,0,style_5,2);\r
496                break;\r
497             }\r
498          }\r
499          break;\r
500 \r
501       case HASCII :\r
502          get_shrt( curx );\r
503          get_shrt( cury );\r
504          get_shrt( r );\r
505          if( r==0 ){\r
506             XSetForeground(theDisp,theGC,bcol);\r
507             XFillRectangle(theDisp,pixmap,theGC,curx,cury,8,8);\r
508             XFillRectangle(theDisp,window,theGC,curx,cury,8,8);\r
509             XSetForeground(theDisp,theGC,fcol);\r
510          }else{\r
511             c = (char)r;\r
512             XDrawString(theDisp,pixmap,theGC,curx,cury+8,&c,1);\r
513             XDrawString(theDisp,window,theGC,curx,cury+8,&c,1);\r
514          }\r
515          break;\r
516 \r
517       case STATUS :\r
518          put_shrt(mouse_x)\r
519          put_shrt(mouse_y)\r
520          put_shrt(mouse_l)\r
521          put_shrt(mouse_r)\r
522          put_shrt(mouse_c)\r
523          snd_father\r
524          break;\r
525 \r
526       case GETPRESS :\r
527       case GETRELEASE :\r
528          {\r
529             int button;\r
530             get_shrt(button);\r
531             if( cmd == GETPRESS )\r
532                switch( button ){\r
533 \r
534                   case 0:\r
535                           put_shrt( mouse_l_p_x );\r
536                           put_shrt( mouse_l_p_y );\r
537                           put_shrt( mouse_l_prs );\r
538                           mouse_l_prs=0;\r
539                           break;\r
540 \r
541                   case 1:\r
542                           put_shrt( mouse_r_p_x );\r
543                           put_shrt( mouse_r_p_y );\r
544                           put_shrt( mouse_r_prs );\r
545                           mouse_r_prs=0;\r
546                           break;\r
547 \r
548                   case 2:\r
549                           put_shrt( mouse_c_p_x );\r
550                           put_shrt( mouse_c_p_y );\r
551                           put_shrt( mouse_c_prs );\r
552                           mouse_c_prs=0;\r
553                           break;\r
554 \r
555                   default:put_shrt( 0 );\r
556                           put_shrt( 0 );\r
557                           put_shrt( 0 );\r
558                           break;\r
559 \r
560                }\r
561             else\r
562                switch( button ){\r
563 \r
564                   case 0:\r
565                           put_shrt( mouse_l_r_x );\r
566                           put_shrt( mouse_l_r_y );\r
567                           put_shrt( mouse_l_rel );\r
568                           mouse_l_rel=0;\r
569                           break;\r
570 \r
571                   case 1:\r
572                           put_shrt( mouse_r_r_x );\r
573                           put_shrt( mouse_r_r_y );\r
574                           put_shrt( mouse_r_rel );\r
575                           mouse_r_rel=0;\r
576                           break;\r
577 \r
578                   case 2:\r
579                           put_shrt( mouse_c_r_x );\r
580                           put_shrt( mouse_c_r_y );\r
581                           put_shrt( mouse_c_rel );\r
582                           mouse_c_rel=0;\r
583                           break;\r
584 \r
585                   default:put_shrt( 0 );\r
586                           put_shrt( 0 );\r
587                           put_shrt( 0 );\r
588                           break;\r
589 \r
590                }\r
591             put_shrt(mouse_l)\r
592             put_shrt(mouse_r)\r
593             put_shrt(mouse_c)\r
594             snd_father\r
595          }\r
596          break;\r
597 \r
598       case GETMOVEMENT :\r
599          {\r
600             static int x=0,y=0;\r
601             put_shrt(mouse_x-x)\r
602             put_shrt(mouse_y-y)\r
603             snd_father\r
604             x = mouse_x;\r
605             y = mouse_y;\r
606          }\r
607          break;\r
608 \r
609       case TRACK:\r
610          {\r
611             int x,y;\r
612             get_shrt( x )   /* these parameters are not used */\r
613             get_shrt( y )\r
614             tracking = 1;\r
615             /* now we wait to point and press left button */\r
616          }\r
617          break;\r
618 \r
619       case END_OF_TRACK:\r
620          put_shrt( mouse_x )\r
621          put_shrt( mouse_y )\r
622          snd_father\r
623          break;\r
624 \r
625       default :\r
626          fprintf(stderr,"UKNOWN COMMAND for HERCULES emulation - %d\n",cmd);\r
627          fflush(stderr);\r
628          XFreePixmap(theDisp,pixmap);\r
629          XDestroyWindow(theDisp,window);\r
630          XCloseDisplay(theDisp);\r
631          exit(7);\r
632 \r
633    }\r
634 \r
635 }\r
636 \r