inter.c File Reference

#include <strings.h>
#include "x_ptyxP.h"
#include "x_data.h"
#include "machine.h"
#include "All-extern-x.h"
#include "All-extern.h"
#include "xscion.h"
#include "TclEvents.h"
#include "dynamic_menus.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xos.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include "inter.h"
#include <sys/select.h>
#include <stdlib.h>
#include "Os_specific.h"
#include "Xscilab.ad.h"

Include dependency graph for inter.c:

Go to the source code of this file.

Defines

#define LF   0x000a
#define MAXBUFFSIZE   256

Functions

int Scierror __PARAMS ((int iv, char *fmt,...))
int Xscilab __PARAMS ((Display **dpy, Widget *topwid))
void xevents1 __PARAMS ((void))
int GetWITH_GUI (void)
int IsClick_menu (void)
void Click_menu (int n)
int charfromclick (void)
int IntoEmacs (void)
int C2F() checkevts (int *i)
static void basic_scilab_mask (Display **dpy)
void sci_tk_activate (void)
void DisplayInit (char *string, Display **dpy, Widget *toplevel)
int Xorgetchar (int interrupt)
int C2F() sxevents ()
static void str_to_xterm (char *string, int nbytes)
static void str_to_xterm_nw (char *string, int nbytes)
void write_scilab (char *s)

Variables

static int ClickMenu = 0
static char buffstring [MAXBUFFSIZE]
static int lenbuffstring
static int posinbuff = 0
static fd_set Select_mask_ref
static fd_set select_mask
static fd_set Write_mask_ref
static fd_set write_mask
static int inter_max_plus1 = 0
Display * the_dpy = (Display *) NULL
int BasicScilab = 1
XtAppContext app_con
static int intoemacs = 0
static String bgfallback_resources []
static XtActionsRec actionProcs []
static int Xsocket = 0
static int fd_in = 0
static int fd_out = 0
static int fd_err = 0


Define Documentation

#define LF   0x000a

Definition at line 57 of file inter.c.

#define MAXBUFFSIZE   256

Definition at line 58 of file inter.c.

Referenced by str_to_xterm_nw().


Function Documentation

void xevents1 __PARAMS ( (void)   ) 

int Xscilab __PARAMS ( (Display **dpy, Widget *topwid)   ) 

int Scierror __PARAMS ( (int iv, char *fmt,...)   ) 

hpux uses time.h instead of select.h

static void basic_scilab_mask ( Display **  dpy  )  [static]

Definition at line 178 of file inter.c.

References fd_err, fd_in, fd_out, Max, and XTKsocket.

Referenced by DisplayInit(), and sci_tk_activate().

00179 {
00180   Xsocket = ConnectionNumber(*dpy);
00181   fd_in = fileno(stdin) ;
00182   fd_out = fileno(stdout);
00183   fd_err = fileno(stderr);
00184 
00185   FD_ZERO(&Select_mask_ref);
00186   FD_SET(fd_in , &Select_mask_ref);
00187   FD_SET(Xsocket, &Select_mask_ref);
00188 #ifdef WITH_TK 
00189   if ( XTKsocket != 0 ) FD_SET(XTKsocket, &Select_mask_ref);
00190 #endif 
00191   FD_ZERO(&Write_mask_ref);
00192   /* the two next FD_SET causes select not to wait 
00193    * 
00194    */
00195   /* FD_SET(fd_out,&Write_mask_ref);
00196      FD_SET(fd_err,&Write_mask_ref);*/
00197 
00198   inter_max_plus1 = Max(fd_in,Xsocket);      
00199   inter_max_plus1 = Max(fd_out,inter_max_plus1);
00200   inter_max_plus1 = Max(fd_err,inter_max_plus1);
00201 #ifdef WITH_TK 
00202   inter_max_plus1 = Max(XTKsocket,inter_max_plus1);
00203 #endif 
00204   inter_max_plus1++;
00205 }  

Here is the caller graph for this function:

int charfromclick ( void   ) 

Definition at line 383 of file inter.c.

Referenced by Xorgetchar().

00384 {
00385   if (posinbuff==lenbuffstring-1)
00386     {
00387       ClickMenu=0;
00388     }
00389   if (posinbuff==lenbuffstring)
00390     return(9999);
00391   else
00392     return(buffstring[posinbuff++]);
00393 }

Here is the caller graph for this function:

int C2F() checkevts ( int i  ) 

Definition at line 91 of file inter.c.

References getINXscilab(), i, and Max.

00092 {
00093   *i= Max(getINXscilab(),1-BasicScilab);
00094   return(0);
00095 }

Here is the call graph for this function:

void Click_menu ( int  n  ) 

Definition at line 377 of file inter.c.

Referenced by str_to_xterm_nw().

00378 {
00379   ClickMenu=n;
00380   return;
00381 }

Here is the caller graph for this function:

void DisplayInit ( char *  string,
Display **  dpy,
Widget *  toplevel 
)

Definition at line 139 of file inter.c.

References basic_scilab_mask(), count, IntoEmacs(), NULL, optionDescList, and Xscilab().

Referenced by ChangeBandF(), CreatePopupWindow(), GetChilds(), GetFileWindow(), GetScreenDPI(), initgraphic(), InitXsession(), sci_tk_activate(), ShellFormCreate(), and ShellFormCreateOld().

00140 {
00141   static XrmOptionDescRec *optionDescList = NULL;
00142   static Display *dpy1;
00143   static Widget toplevel1;
00144   static int count=0;
00145   int argc=0;
00146   char *argv = 0;
00147   if ( count > 0) 
00148     {
00149       *dpy=dpy1;
00150       *toplevel=toplevel1;
00151       return;
00152     }
00153   count++;
00154   Xscilab(dpy,toplevel);
00155   if ( *toplevel != (Widget) NULL)
00156     {
00157       toplevel1 = *toplevel;
00158       dpy1 = *dpy;
00159     }
00160   else
00161     {
00162       *toplevel=toplevel1=XtAppInitialize (&app_con,"Xscilab",optionDescList,
00163                                            0,&argc, (String *)argv,
00164                                            bgfallback_resources,(ArgList) NULL,(Cardinal) 0);
00165       XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs));
00166       the_dpy = *dpy=dpy1=XtDisplay(toplevel1);
00167       BasicScilab = 0;
00168       basic_scilab_mask(dpy);
00169       intoemacs=IntoEmacs();
00170     }
00171   XSync(dpy1,0);
00172 }

Here is the call graph for this function:

Here is the caller graph for this function:

int GetWITH_GUI ( void   ) 

TODO : comment

Returns:

Definition at line 297 of file inisci-c.c.

00298 {
00299         return WITH_GUI;
00300 }

int IntoEmacs ( void   ) 

Definition at line 85 of file inter.c.

References getenv().

Referenced by DisplayInit().

00086 {
00087   return(strcmp(getenv("TERM"),"dumb")==0);
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

int IsClick_menu ( void   ) 

Definition at line 372 of file inter.c.

Referenced by Xorgetchar().

00373 {
00374   return(ClickMenu);
00375 }

Here is the caller graph for this function:

void sci_tk_activate ( void   ) 

Definition at line 128 of file inter.c.

References basic_scilab_mask(), DisplayInit(), dpy, NULL, and toplevel.

00129 {
00130   Display *dpy = (Display *) NULL;
00131   Widget toplevel = (Widget) NULL;
00132   /*Cout("You have started Scilab in a mode in which TK is not initialized.\n");
00133     Cout("Trying to initialize \n");*/
00134   DisplayInit("",&dpy,&toplevel);
00135   BasicScilab = 0;
00136   basic_scilab_mask(&dpy);
00137 }

Here is the call graph for this function:

static void str_to_xterm ( char *  string,
int  nbytes 
) [static]

Definition at line 335 of file inter.c.

References _XtermWidgetRec::screen, StringInput(), and term.

Referenced by write_scilab().

00338 {
00339   register TScreen *screen = &term->screen;
00340   StringInput(screen,string,strlen(string));
00341 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void str_to_xterm_nw ( char *  string,
int  nbytes 
) [static]

Definition at line 344 of file inter.c.

References Click_menu(), and MAXBUFFSIZE.

Referenced by write_scilab().

00347 {
00348   posinbuff=0;
00349   if (nbytes>MAXBUFFSIZE-1)
00350     {
00351       Scierror(1020,"%s\n", "The menu  name is too long  to be strored");
00352       return;
00353     }
00354   sprintf(buffstring,string);
00355   buffstring[nbytes]='\n';
00356   lenbuffstring=nbytes+1;
00357   Click_menu(1);
00358 }

Here is the call graph for this function:

Here is the caller graph for this function:

int C2F() sxevents (  ) 

Definition at line 302 of file inter.c.

References BasicScilab, flushTKEvents(), getINXscilab(), GetWITH_GUI(), NULL, TextMessage1(), xevents1(), and XTKsocket.

00303 {
00304         if ( GetWITH_GUI() )
00305         {
00306                   if (getINXscilab()==1) 
00307     {
00308       xevents1();
00309     }
00310   else 
00311     {
00312       XEvent event;
00313       if (BasicScilab) return(0);
00314       if ( the_dpy == (Display *) NULL)  return(0);
00315 #ifdef WITH_TK 
00316       if ( XTKsocket != 0 ) flushTKEvents();
00317 #endif 
00318       if (!XPending (the_dpy))
00319         /* protect against events/errors being swallowed by us or Xlib */
00320         return(0);
00321       do {
00322         XNextEvent (the_dpy, &event);
00323         XtDispatchEvent(&event);
00324       } while (QLength(the_dpy) > 0);
00325     }
00326         }
00327         
00328   return(0);
00329 }

Here is the call graph for this function:

void write_scilab ( char *  s  ) 

Definition at line 360 of file inter.c.

References C2F, i, str_to_xterm(), str_to_xterm_nw(), and xscion().

00362 {
00363   int  i;
00364   C2F(xscion)(&i);
00365   if (i==1)
00366     str_to_xterm(s,strlen(s));
00367   else
00368     str_to_xterm_nw(s,strlen(s));
00369   /*            printf(" asynchronous actions are not supported with -nw option\n");*/
00370 }

Here is the call graph for this function:

int Xorgetchar ( int  interrupt  ) 

Definition at line 224 of file inter.c.

References C2F, charfromclick(), errno, fd_err, fd_in, fd_out, flushTKEvents(), i, IsClick_menu(), ismenu(), LF, NULL, Scistring(), sxevents(), and XTKsocket.

Referenced by GetCharOrEvent().

00226 {
00227   register int i;
00228   static struct timeval select_timeout;
00229   static int state = 0;
00230   if ( BasicScilab) return(getchar());
00231   for( ; ; ) {
00232     XFlush(the_dpy); /* always flush writes before waiting */
00233     fflush(stdout); 
00234     fflush(stderr); 
00235 #ifdef WITH_TK 
00236     flushTKEvents();
00237 #endif 
00238     /* Initialize masks  */
00239     select_mask = Select_mask_ref;
00240     write_mask  = Write_mask_ref;
00241 
00242     select_timeout.tv_sec = 0;
00243     select_timeout.tv_usec = 10;
00244     i = select(inter_max_plus1, &select_mask, &write_mask, (fd_set *)NULL, &select_timeout);
00245     if (i < 0) {
00246       if (errno != EINTR)
00247         { 
00248           Scistring("Error\n");
00249           exit(0);
00250           continue;
00251         }
00252     } 
00253 
00254     /* if there's something to output */
00255     if ( FD_ISSET(fd_out,&write_mask)) { 
00256       fflush(stdout); 
00257     }
00258     if ( FD_ISSET(fd_err,&write_mask)) { 
00259       fflush(stderr); 
00260     }
00261 
00262 #ifdef WITH_TK 
00263     if ( XTKsocket != 0 && FD_ISSET(XTKsocket,&select_mask )) { 
00264       flushTKEvents();
00265     }
00266 #endif 
00267 
00268     /* if there's something to read */
00269     if (FD_ISSET(fd_in,&select_mask) || IsClick_menu()) 
00270       state=1;
00271     else
00272       if (QLength(the_dpy) ||  FD_ISSET(Xsocket,&select_mask ) ||!(intoemacs))
00273         state=0;
00274 
00275     if (state) {
00276       if(IsClick_menu())
00277         i=charfromclick();
00278       else
00279         i=getchar();
00280       if (i==LF) state=0;
00281       return(i);
00282     }
00283         
00284     C2F(sxevents)();
00285     if (interrupt&&(C2F(ismenu)()==1)) return(-1);
00286 
00287   }
00288 
00289 
00290 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

XtActionsRec actionProcs[] [static]

Initial value:

 {
  {"DeleteWindow", DeleteWindow},
  {"SGDeleteWindow", SGDeleteWindow},
  {"KeyboardMapping", KeyboardMapping}
}

Definition at line 110 of file inter.c.

Referenced by main().

XtAppContext app_con

Definition at line 76 of file inter.c.

int BasicScilab = 1

Definition at line 75 of file inter.c.

Referenced by sxevents().

String bgfallback_resources[] [static]

Initial value:

 {

  NULL,
}

Definition at line 99 of file inter.c.

char buffstring[MAXBUFFSIZE] [static]

Definition at line 60 of file inter.c.

int ClickMenu = 0 [static]

Definition at line 59 of file inter.c.

int fd_err = 0 [static]

Definition at line 176 of file inter.c.

Referenced by basic_scilab_mask(), and Xorgetchar().

int fd_in = 0 [static]

Definition at line 176 of file inter.c.

Referenced by basic_scilab_mask(), and Xorgetchar().

int fd_out = 0 [static]

Definition at line 176 of file inter.c.

Referenced by basic_scilab_mask(), and Xorgetchar().

int inter_max_plus1 = 0 [static]

Definition at line 73 of file inter.c.

int intoemacs = 0 [static]

Definition at line 82 of file inter.c.

int lenbuffstring [static]

Definition at line 61 of file inter.c.

int posinbuff = 0 [static]

Definition at line 62 of file inter.c.

fd_set select_mask [static]

Definition at line 72 of file inter.c.

fd_set Select_mask_ref [static]

Definition at line 72 of file inter.c.

Display* the_dpy = (Display *) NULL

Definition at line 74 of file inter.c.

fd_set write_mask [static]

Definition at line 72 of file inter.c.

fd_set Write_mask_ref [static]

Definition at line 72 of file inter.c.

int Xsocket = 0 [static]

Definition at line 176 of file inter.c.

Referenced by main_sci().


Generated on Sun Mar 4 16:04:52 2007 for Scilab [trunk] by  doxygen 1.5.1