24
24
#include "version.h"
25
25
#include "strdup_windows.h"
26
26
/*--------------------------------------------------------------------------*/
27
#define NameConsole "Console"
27
#define NameConsole "Console"
28
28
/*--------------------------------------------------------------------------*/
29
29
static CONSOLE_SCREEN_BUFFER_INFO csbiInfoSave;
30
30
static char ScilexConsoleName[MAX_PATH];
31
31
/*--------------------------------------------------------------------------*/
32
32
void UpdateConsoleColors(void)
34
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
41
FillConsoleOutputAttribute( hConsole,
42
BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED|BACKGROUND_INTENSITY,
43
csbiInfoSave.dwSize.X*csbiInfoSave.dwSize.Y,
47
SetConsoleTextAttribute(hConsole,BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED|BACKGROUND_INTENSITY);
34
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
41
FillConsoleOutputAttribute( hConsole,
42
BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY,
43
csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
47
SetConsoleTextAttribute(hConsole, BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
50
50
/*--------------------------------------------------------------------------*/
51
51
void SaveConsoleColors(void)
53
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfoSave);
53
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfoSave);
55
55
/*--------------------------------------------------------------------------*/
56
56
void RestoreConsoleColors(void)
58
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
65
FillConsoleOutputAttribute( hConsole,
66
csbiInfoSave.wAttributes,
67
csbiInfoSave.dwSize.X*csbiInfoSave.dwSize.Y,
70
SetConsoleTextAttribute(hConsole,csbiInfoSave.wAttributes);
58
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
65
FillConsoleOutputAttribute( hConsole,
66
csbiInfoSave.wAttributes,
67
csbiInfoSave.dwSize.X * csbiInfoSave.dwSize.Y,
70
SetConsoleTextAttribute(hConsole, csbiInfoSave.wAttributes);
72
72
/*--------------------------------------------------------------------------*/
73
73
void RenameConsole(void)
76
char CurrentConsoleName[MAX_PATH];
77
char CurrentConsoleNameTmp[MAX_PATH];
79
GetConsoleTitle(CurrentConsoleName,MAX_PATH);
80
strncpy(CurrentConsoleNameTmp,CurrentConsoleName,strlen(NameConsole));
81
CurrentConsoleNameTmp[strlen(NameConsole)]='\0';
83
if ( strcmp(CurrentConsoleNameTmp,NameConsole) != 0)
85
wsprintf(ScilexConsoleName,"%s %s",NameConsole,SCI_VERSION_STRING);
86
SetConsoleTitle(ScilexConsoleName);
89
hScilex = GetConsoleWindow();
92
HMENU hmenuConsole = NULL;
93
// Desactive croix dans la console
94
hmenuConsole = GetSystemMenu(hScilex, FALSE);
95
DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
76
char CurrentConsoleName[MAX_PATH];
77
char CurrentConsoleNameTmp[MAX_PATH];
79
GetConsoleTitle(CurrentConsoleName, MAX_PATH);
80
strncpy(CurrentConsoleNameTmp, CurrentConsoleName, strlen(NameConsole));
81
CurrentConsoleNameTmp[strlen(NameConsole)] = '\0';
83
if ( strcmp(CurrentConsoleNameTmp, NameConsole) != 0)
85
wsprintf(ScilexConsoleName, "%s %s", NameConsole, SCI_VERSION_STRING);
86
SetConsoleTitle(ScilexConsoleName);
89
hScilex = GetConsoleWindow();
92
HMENU hmenuConsole = NULL;
93
// Desactive croix dans la console
94
hmenuConsole = GetSystemMenu(hScilex, FALSE);
95
DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
98
98
/*--------------------------------------------------------------------------*/
99
99
void RestoreExitButton(void)
102
hScilex = GetConsoleWindow();
105
HMENU hmenuConsole = NULL;
106
// Active croix dans la console
107
hmenuConsole = GetSystemMenu(hScilex, FALSE);
108
AppendMenu( hmenuConsole, MF_BYCOMMAND, SC_CLOSE, "&Close Alt+F4" );
102
hScilex = GetConsoleWindow();
105
HMENU hmenuConsole = NULL;
106
// Active croix dans la console
107
hmenuConsole = GetSystemMenu(hScilex, FALSE);
108
AppendMenu( hmenuConsole, MF_BYCOMMAND, SC_CLOSE, "&Close Alt+F4" );
111
111
/*--------------------------------------------------------------------------*/
112
112
void CreateScilabConsole(int ShowBanner)
116
SetConsoleState(0); /* Console DOS Cach�e par d�faut */
119
wsprintf(ScilexConsoleName,"%s %s (%d)",NameConsole,SCI_VERSION_STRING,getCurrentScilabId());
120
SetConsoleTitle(ScilexConsoleName);
122
CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CONSOLE_TEXTMODE_BUFFER,NULL);
123
freopen("CONOUT$", "wb", stdout); /* redirect stdout --> CONOUT$*/
124
freopen("CONOUT$", "wb", stderr); /* redirect stderr --> CONOUT$*/
130
strcpy(line," ___________________________________________\n");
132
wsprintf(line," %s\n\n",SCI_VERSION_STRING);
134
strcpy(line," Consortium Scilab (DIGITEO)\n");
136
strcpy(line," Copyright (c) 1989-2012 (INRIA)\n");
138
strcpy(line," Copyright (c) 1989-2007 (ENPC)\n");
140
strcpy(line," ___________________________________________\n\n");
144
hScilex = GetConsoleWindow();
147
HMENU hmenuConsole = NULL;
148
// Desactive croix dans la console
149
hmenuConsole=GetSystemMenu(hScilex, FALSE);
150
DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
152
/* Cache la fenetre Console */
153
ShowWindow(hScilex,SW_HIDE);
116
SetConsoleState(0); /* Console DOS Cach�e par d�faut */
119
wsprintf(ScilexConsoleName, "%s %s (%d)", NameConsole, SCI_VERSION_STRING, getCurrentScilabId());
120
SetConsoleTitle(ScilexConsoleName);
122
CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
123
freopen("CONOUT$", "wb", stdout); /* redirect stdout --> CONOUT$*/
124
freopen("CONOUT$", "wb", stderr); /* redirect stderr --> CONOUT$*/
130
strcpy(line, " ___________________________________________\n");
132
wsprintf(line, " %s\n\n", SCI_VERSION_STRING);
134
strcpy(line, " Scilab Enterprises\n");
136
strcpy(line, " Copyright (c) 2011-2012 (Scilab Enterprises)\n");
138
strcpy(line, " Copyright (c) 1989-2012 (INRIA)\n");
140
strcpy(line, " Copyright (c) 1989-2007 (ENPC)\n");
142
strcpy(line, " ___________________________________________\n\n");
146
hScilex = GetConsoleWindow();
149
HMENU hmenuConsole = NULL;
150
// Desactive croix dans la console
151
hmenuConsole = GetSystemMenu(hScilex, FALSE);
152
DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
154
/* Cache la fenetre Console */
155
ShowWindow(hScilex, SW_HIDE);
156
158
/*--------------------------------------------------------------------------*/
157
159
void CloseScilabConsole(void)
163
165
/*--------------------------------------------------------------------------*/
164
166
char *getScilexConsoleName(void)
166
char *retName = NULL;
168
char *retName = NULL;
168
if (strlen(ScilexConsoleName) > 0)
170
retName = strdup(ScilexConsoleName);
170
if (strlen(ScilexConsoleName) > 0)
172
retName = strdup(ScilexConsoleName);
174
176
/*--------------------------------------------------------------------------*/
175
177
int getXConsoleScreenSize(void)
177
return (csbiInfoSave.srWindow.Right - csbiInfoSave.srWindow.Left);
179
return (csbiInfoSave.srWindow.Right - csbiInfoSave.srWindow.Left);
179
181
/*--------------------------------------------------------------------------*/
180
182
int getYConsoleScreenSize(void)
182
return (csbiInfoSave.srWindow.Bottom - csbiInfoSave.srWindow.Top);
184
return (csbiInfoSave.srWindow.Bottom - csbiInfoSave.srWindow.Top);
184
186
/*--------------------------------------------------------------------------*/