File: ScilabXloop.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (174 lines) | stat: -rw-r--r-- 4,156 bytes parent folder | download
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
/* Copyright (C) 1998 Chancelier Jean-Philippe */
/*
 * jpc_Xloop.c : 
 * (1997) : Jean-Philippe Chancelier 
 * 
 */
/*-----------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#ifndef STRICT
#define STRICT
#endif
#include "wresource.h"
#include "wcommon.h"
#include "../machine.h"

#include "Messages.h"
#include "Warnings.h"
#include "Errors.h"


#ifdef WITH_TK
#include "tcl.h"
extern void initTCLTK ();
extern void flushTKEvents ();
extern int  tcl_check_one_event(void);
static int BasicScilab = 1;
#endif
/*-----------------------------------------------------------------------------------*/
/** do I want a scilab or an xscilab (here it means Windows ) */

int INXscilab = 0; /**  XXXX just to use zzledt1 **/

/*-----------------------------------------------------------------------------------*/
void SetNotBasic()
{
	#ifdef WITH_TK
  BasicScilab=0;
  #endif
}
/*-----------------------------------------------------------------------------------*/
int GetBasic() 
{
#ifdef WITH_TK
	 return  BasicScilab;
#else
	 return  0;
#endif
} 
/*-----------------------------------------------------------------------------------*/

void start_sci_gtk() 
{
#ifdef WITH_TK
  initTCLTK();
  BasicScilab = 0;
  flushTKEvents();
#endif
}

/*-----------------------------------------------------------------------------------*/
void SetXsciOn ()
{
switch_rlgets (1);
INXscilab = 1;
#ifdef WITH_TK
  initTCLTK ();
#endif
}
/*-----------------------------------------------------------------------------------*/
int C2F (xscion) (int *i)
{
  *i = INXscilab;
  return (0);
}
/*-----------------------------------------------------------------------------------*/

/* used to know if we must check events 
 * inside the scilab interpreter (parse/*)
 * A faire sous windows 
 */

int C2F(checkevts)(int *i)
{
  /*  *i= INXscilab; */
  #if WITH_TK
  *i= Max(INXscilab,1-BasicScilab);
  #else
  *i= INXscilab;
  #endif
  return(0);
}
/*-----------------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------
 * used to start tk at run time when scilab 
 * was started with scilab -nw 
 * open a display with DisplayInit and initialize 
 * Tk. If TK_Started is set to one then the initialization 
 * was correct.
 *---------------------------------------------------------------------------*/

void sci_tk_activate(void)
{
	#ifdef WITH_TK
  start_sci_gtk();
  initTCLTK();
  BasicScilab = 0;
  #endif
}
/*-----------------------------------------------------------------------------------*/
/*************************************************
 * Dealing with Events on the queue when computing in Scilab 
 * we also try to detect when CTRLC was  activated 
 *************************************************/
extern TW textwin;

void TextMessage1 (int ctrlflag)
{
  MSG msg;
#ifdef WITH_TK
  flushTKEvents ();
#endif
  while (PeekMessage (&msg, 0, 0, 0, PM_NOREMOVE))
    {
#ifdef WITH_TK
      /* check for a tcl/tk event */
      if (Tcl_DoOneEvent (TCL_ALL_EVENTS | TCL_DONT_WAIT) == 1) continue ;
#endif
      PeekMessage (&msg, 0, 0, 0, PM_REMOVE);
      TranslateMessage (&msg);
      DispatchMessage (&msg);
    }
  if (ctrlflag == 1) 
    {
      CtrlCHit (&textwin);
    }
}
/*-----------------------------------------------------------------------------------*/
int C2F (sxevents) ()
{
	#ifdef WITH_TK
  if (INXscilab == 1 || BasicScilab == 0 )
  #else
  if (INXscilab == 1 )
  #endif
    {
      TextMessage1 (1);
    }
  return (0);
}
/*-----------------------------------------------------------------------------------*/
/**********************************************************************
 * For Fortran call 
 **********************************************************************/

static void strip_blank (source)
     char *source;
{
  char *p;
  p = source;
  /* look for end of string */
  while (*p != '\0')
    p++;
  while (p != source)
    {
      p--;
      if (*p != ' ')
	break;
      *p = '\0';
    }
}

/**********************************************************************/