File: x_zzledt.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 (155 lines) | stat: -rw-r--r-- 4,616 bytes parent folder | download | duplicates (2)
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
/* Copyright (C) 1998-2002 Chancelier Jean-Philippe */
/* INRIA 2003 Allan CORNET */

/************************************
 * reading functions for scilab 
 ************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef STRICT
#define STRICT
#endif
#include "../os_specific/win_mem_alloc.h" /* MALLOC */
#include "wcommon.h"
#include "wtext.h"
/*-----------------------------------------------------------------------------------*/
char save_prompt[10];
/* Fonction Rcuperant la ligne  executer par Scilab */

extern void InvalidateCursor( void ); 
extern char input_line[MAX_LINE_LEN + 1];
extern BOOL ScilabIsStarting;
extern void SetReadyOrNotForAnewLign(BOOL Ready);
extern void GetCurrentPrompt(char *CurrentPrompt);

extern int GetSaveHistoryAfterNcommands(void);
extern char * getfilenamehistory(void);
extern void write_history(char *filename);
extern LPTW GetTextWinScilab(void);
extern void SendCTRLandAKey(int code);
extern BOOL IsWindowInterface(void);
extern int C2F (scilines) (int *nl, int *nc);
/*-----------------------------------------------------------------------------------*/
char copycur_line[1024];
BOOL PutLineInBuffer=FALSE;
void ChangeCursorWhenScilabIsReady(void);
int NumberOfCommands=0;
/*-----------------------------------------------------------------------------------*/
/***********************************************************************
 * line editor win32 version 
 * Input function for Scilab 
 * zzledt1 for scilab 
 * zzledt  for scilab -nw 
 **********************************************************************/

/**** Warning here : eof can be true  ***/
#ifdef __STDC__
void C2F (zzledt) (char *buffer, int *buf_size, int *len_line, int *eof, int* interrupt, int *modex, long int dummy1)
#else
void C2F (zzledt) (buffer, buf_size, len_line, eof, interrupt, modex, dummy1)
     char *buffer;
     int *buf_size;
     int *len_line;
     int *eof;
     int *interrupt;
     int *modex;
     long int dummy1;		/* added by FORTRAN to give buffer length */
#endif
{
  int i;
  extern BOOL PutLineInBuffer;
  extern char copycur_line[1024];

  GetCurrentPrompt(save_prompt);

  ChangeCursorWhenScilabIsReady();
  C2F (sxevents) ();
  if (*modex) SetReadyOrNotForAnewLign(TRUE); /* Pret  recevoir depuis la thread Coller */
  set_is_reading (TRUE);
  if (PutLineInBuffer)
  {
	  SendCTRLandAKey(CTRLU);
	  write_scilab(copycur_line);
	  PutLineInBuffer=FALSE;
  }
  
  i = read_line (save_prompt,*interrupt);
  
  if (i==-1) 
  { /* dynamic menu canceled read SS*/
    *len_line = 0;
    *eof = -1;
    //set_is_reading (FALSE);
    return;
  }
  strncpy (buffer, input_line, *buf_size);
  *len_line = strlen (buffer);
  /** fprintf(stderr,"[%s,%d]\n",buffer,*len_line); **/
  *eof = (i == 1) ? TRUE : FALSE;
  set_is_reading (FALSE);
  C2F (sxevents) ();

  /* see savehistory */
  NumberOfCommands++;
  if ( ( GetSaveHistoryAfterNcommands() == NumberOfCommands ) && ( GetSaveHistoryAfterNcommands() > 0) )
  {
	  char *filenamehistory=NULL;
	
	  filenamehistory=getfilenamehistory();
	  write_history( filenamehistory );
	  FREE(filenamehistory);

	  NumberOfCommands=0;
  }

  return;
}
/*-----------------------------------------------------------------------------------*/
void ChangeCursorWhenScilabIsReady(void)
{
  if ( (IsWindowInterface()) && (ScilabIsStarting) )
  {
	HCURSOR hCursor;
	LPTW lptw=GetTextWinScilab();
	int NumsMenu = 0;
	int nl=0, nc=0;
	HMENU hMenu=NULL;
		
	hCursor=LoadCursor(  lptw->hInstance,IDC_ARROW);
	SetClassLong(lptw->hWndParent, GCL_HCURSOR,	(LONG) hCursor); 
	SetClassLong(lptw->hWndText,GCL_HCURSOR,(LONG) hCursor); 
	InvalidateCursor(); 
	hMenu=GetMenu(lptw->hWndParent);
	NumsMenu=GetMenuItemCount (hMenu);
	EnableNMenus(lptw,NumsMenu);
	EnableToolBar(lptw);

	ScilabIsStarting=FALSE;

	ShowWindow (lptw->hWndParent,SW_SHOWDEFAULT);
	BringWindowToTop (lptw->hWndParent);
	SetFocus(lptw->hWndParent);
	SetFocus(lptw->hWndText);
	
	/* Initialize 'lines' */
	nc = lptw->ClientSize.x / lptw->CharSize.x;
	nl = lptw->ClientSize.y / lptw->CharSize.y;
	/** send number of lines info to scilab **/
	if ((lptw->ClientSize.x>0) && (lptw->ClientSize.y>0))	C2F (scilines) (&nl, &nc);

  }
}
/*-----------------------------------------------------------------------------------*/
void SaveCurrentLine(BOOL RewriteLineAtPrompt)
{
	extern char cur_line[1024];

	if ( (get_is_reading ()) && (PutLineInBuffer == FALSE) )
	{
		strcpy(copycur_line,cur_line);
		if (RewriteLineAtPrompt) PutLineInBuffer=TRUE;
	}
}
/*-----------------------------------------------------------------------------------*/