WinConsole.c File Reference

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

Include dependency graph for WinConsole.c:

Go to the source code of this file.

Functions

typedef UINT (WINAPI *GetWindowModuleFileNamePROC)(HWND
void RenameConsole (void)
void CreateScilabConsole (int ShowBanner)
void CloseScilabConsole (void)
void UpdateConsoleColors (void)
void SaveConsoleColors (void)
void RestoreConsoleColors (void)
BOOL IsWindowInterface (void)
int IsConsoleMode (void)
int FindFreeScilexNumber (void)
void HideScilex (void)
void ShowScilex (void)
void SwitchConsole (void)
void SetWindowMode (BOOL ON)
int GetConsoleState (void)
void SetConsoleState (int state)

Variables

static CONSOLE_SCREEN_BUFFER_INFO csbiInfoSave
char ScilexConsoleName [MAX_PATH]
static BOOL WindowMode
static int Windows_Console_State
typedef LPTSTR
typedef UINT


Function Documentation

void CloseScilabConsole ( void   ) 

Definition at line 78 of file WinConsole.c.

Referenced by Windows_Main().

00079 {
00080         fclose(stdout);
00081         fclose(stderr);
00082         FreeConsole();
00083 }

Here is the caller graph for this function:

void CreateScilabConsole ( int  ShowBanner  ) 

Definition at line 39 of file WinConsole.c.

References FALSE, FindFreeScilexNumber(), HideScilex(), line, NameConsole, NULL, SCI_VERSION_STRING, ScilexConsoleName, and Windows_Console_State.

Referenced by Windows_Main().

00040 {
00041         HMENU hmenuConsole = NULL;
00042         int Current_Number_of_Scilex=-1; 
00043 
00044         Windows_Console_State=0; /* Console DOS Cachée par défaut */
00045         AllocConsole();
00046 
00047         Current_Number_of_Scilex=FindFreeScilexNumber();
00048         wsprintf(ScilexConsoleName,"%s %s (%d)",NameConsole,SCI_VERSION_STRING,Current_Number_of_Scilex);
00049         SetConsoleTitle(ScilexConsoleName);
00050 
00051         CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CONSOLE_TEXTMODE_BUFFER,NULL);
00052     freopen("CONOUT$", "wb", stdout); /* redirect stdout --> CONOUT$*/
00053         freopen("CONOUT$", "wb", stderr); /* redirect stderr --> CONOUT$*/
00054         
00055         if (ShowBanner)
00056         {
00057                 char line[80];
00058 
00059                 strcpy(line,"        ___________________________________________\r\n");
00060                 printf(line);
00061             wsprintf(line,"                         %s\r\n\n",SCI_VERSION_STRING);
00062                 printf(line);
00063                 strcpy(line,"                  Copyright (c) 1989-2007          \r\n");
00064                 printf(line);
00065                 strcpy(line,"              Consortium Scilab (INRIA, ENPC)      \r\n");
00066                 printf(line);
00067         strcpy(line,"        ___________________________________________\r\n\r\n");
00068                 printf(line);
00069         }
00070 
00071         // Desactive croix dans la console
00072         hmenuConsole=GetSystemMenu(GetConsoleWindow(), FALSE);
00073         DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
00074 
00075         HideScilex(); /* Cache la fenetre Console */
00076 }

Here is the call graph for this function:

Here is the caller graph for this function:

int FindFreeScilexNumber ( void   ) 

Definition at line 138 of file WinConsole.c.

References MAX_PATH, NULL, SCI_VERSION_STRING, and UINT.

Referenced by CreateScilabConsole().

00139 {
00140         HWND hScilexN=NULL;
00141         int Number_of_Scilex=0;
00142         char NameScilex[MAX_PATH];
00143 
00144         wsprintf(NameScilex,"%s (%d)",SCI_VERSION_STRING,Number_of_Scilex);
00145         hScilexN=FindWindow(NULL,NameScilex);
00146         while ( hScilexN )
00147         {
00148                 UINT NbChar=0;
00149                 char FileName[MAX_PATH+1];
00150                 strcpy(FileName,"");
00151 
00152                 NbChar=GetWindowModuleFileName(hScilexN,FileName,MAX_PATH);
00153                 
00154                 if (NbChar>0)
00155                 {
00156                         Number_of_Scilex++;
00157                         wsprintf(NameScilex,"%s (%d)",SCI_VERSION_STRING,Number_of_Scilex);
00158                         hScilexN=FindWindow(NULL,NameScilex);
00159                 }
00160                 else
00161                 {
00162                         hScilexN=NULL;
00163                 }
00164         }
00165 
00166         return Number_of_Scilex;
00167 }

Here is the caller graph for this function:

int GetConsoleState ( void   ) 

Definition at line 219 of file WinConsole.c.

References Windows_Console_State.

Referenced by C2F(), and SwitchConsole().

00220 {
00221         return Windows_Console_State;
00222 }

Here is the caller graph for this function:

void HideScilex ( void   ) 

Definition at line 170 of file WinConsole.c.

References NULL.

Referenced by C2F(), CreateScilabConsole(), SwitchConsole(), and Windows_Main().

00171 {
00172         HWND hScilex=NULL;
00173         hScilex=GetConsoleWindow();
00174         if (hScilex)
00175         {
00176                 ShowWindow(hScilex,SW_HIDE);    
00177         }
00178 }

Here is the caller graph for this function:

int IsConsoleMode ( void   ) 

V.C 04/2004 Function used to know if we are in window mode (returned value is 1) or in console mode (returned value is 0)

Definition at line 132 of file WinConsole.c.

References WindowMode.

00133 {
00134         return (int)(!WindowMode);
00135 }

BOOL IsWindowInterface ( void   ) 

Definition at line 127 of file WinConsole.c.

References WindowMode.

00128 {
00129         return WindowMode;
00130 }

void RenameConsole ( void   ) 

Definition at line 17 of file WinConsole.c.

References FALSE, MAX_PATH, NameConsole, NULL, SCI_VERSION_STRING, and ScilexConsoleName.

Referenced by Console_Main().

00018 {
00019         HMENU hmenuConsole = NULL;
00020         char CurrentConsoleName[MAX_PATH];
00021         char CurrentConsoleNameTmp[MAX_PATH];
00022 
00023         GetConsoleTitle(CurrentConsoleName,MAX_PATH);
00024         strncpy(CurrentConsoleNameTmp,CurrentConsoleName,strlen(NameConsole));
00025         CurrentConsoleNameTmp[strlen(NameConsole)]='\0';
00026 
00027         if ( strcmp(CurrentConsoleNameTmp,NameConsole) != 0)     
00028         {
00029                 wsprintf(ScilexConsoleName,"%s %s",NameConsole,SCI_VERSION_STRING);
00030                 SetConsoleTitle(ScilexConsoleName);
00031         }
00032 
00033         // Desactive croix dans la console
00034         hmenuConsole=GetSystemMenu(GetConsoleWindow(), FALSE);
00035         DeleteMenu(hmenuConsole, SC_CLOSE, MF_BYCOMMAND);
00036 
00037 }

Here is the caller graph for this function:

void RestoreConsoleColors ( void   ) 

Definition at line 110 of file WinConsole.c.

References csbiInfoSave.

Referenced by TerminateGUI().

00111 {
00112         HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
00113         COORD Coord;
00114         DWORD cWritten;
00115 
00116         Coord.X=0;
00117         Coord.Y=0;
00118 
00119         FillConsoleOutputAttribute( hConsole,
00120                                                                 csbiInfoSave.wAttributes,
00121                                                                 csbiInfoSave.dwSize.X*csbiInfoSave.dwSize.Y,
00122                                                                 Coord,
00123                                                                 &cWritten);
00124         SetConsoleTextAttribute(hConsole,csbiInfoSave.wAttributes);
00125 }

Here is the caller graph for this function:

void SaveConsoleColors ( void   ) 

Definition at line 105 of file WinConsole.c.

References csbiInfoSave.

Referenced by Console_Main().

00106 {
00107         GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfoSave); 
00108 }

Here is the caller graph for this function:

void SetConsoleState ( int  state  ) 

Definition at line 224 of file WinConsole.c.

References Windows_Console_State.

Referenced by C2F(), and SwitchConsole().

00225 {
00226         Windows_Console_State=state;
00227 }

Here is the caller graph for this function:

void SetWindowMode ( BOOL  ON  ) 

Definition at line 214 of file WinConsole.c.

References WindowMode.

Referenced by Console_Main(), and Windows_Main().

00215 {
00216           WindowMode=ON;
00217 }

Here is the caller graph for this function:

void ShowScilex ( void   ) 

Definition at line 181 of file WinConsole.c.

References NULL.

Referenced by C2F(), and SwitchConsole().

00182 {
00183   HWND hScilex=NULL;
00184   hScilex=GetConsoleWindow();
00185   if (hScilex)
00186   {
00187         ShowWindow(hScilex,SW_SHOWNOACTIVATE);
00188   }
00189 }

Here is the caller graph for this function:

void SwitchConsole ( void   ) 

Definition at line 191 of file WinConsole.c.

References GetConsoleState(), HideScilex(), ScilexConsoleName, SetConsoleState(), and ShowScilex().

Referenced by Callback_CONSOLE(), ON_WND_CONSOLE_WM_SYSCOMMAND(), and ON_WND_TEXT_WM_KEY().

00192 {
00193         switch (GetConsoleState())
00194         {
00195                 /* La fenetre etait cachée , on la restaure */
00196                 case 0:
00197                 {
00198                         ShowScilex();
00199                         SetConsoleState(1);
00200                         SetConsoleTitle(ScilexConsoleName);
00201                 }
00202                 break;
00203                 /* La fenetre etait apparente , on la cache */ 
00204                 case 1:
00205                 {
00206                         HideScilex();
00207                         SetConsoleState(0);
00208                         SetConsoleTitle(ScilexConsoleName);
00209                 }
00210                 break;
00211         }
00212 }

Here is the call graph for this function:

Here is the caller graph for this function:

typedef UINT ( WINAPI *  GetWindowModuleFileNamePROC  ) 

void UpdateConsoleColors ( void   ) 

Definition at line 85 of file WinConsole.c.

References csbiInfoSave.

Referenced by Console_Main().

00086 {
00087           HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
00088           COORD Coord;
00089           DWORD cWritten;
00090 
00091           Coord.X=0;
00092           Coord.Y=0;
00093          
00094           FillConsoleOutputAttribute( hConsole,
00095                                                                   BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED|BACKGROUND_INTENSITY,
00096                                                                   csbiInfoSave.dwSize.X*csbiInfoSave.dwSize.Y,
00097                                                                   Coord,
00098                                                                   &cWritten); 
00099 
00100 
00101           SetConsoleTextAttribute(hConsole,BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED|BACKGROUND_INTENSITY);
00102  
00103 }

Here is the caller graph for this function:


Variable Documentation

CONSOLE_SCREEN_BUFFER_INFO csbiInfoSave [static]

Definition at line 10 of file WinConsole.c.

Referenced by RestoreConsoleColors(), SaveConsoleColors(), and UpdateConsoleColors().

typedef LPTSTR

Definition at line 15 of file WinConsole.c.

Referenced by CreateMyTooltip().

char ScilexConsoleName[MAX_PATH]

Definition at line 11 of file WinConsole.c.

Referenced by CreateScilabConsole(), ON_WND_CONSOLE_WM_CREATE(), RenameConsole(), and SwitchConsole().

typedef UINT

Definition at line 15 of file WinConsole.c.

Referenced by AddMenu(), C2F(), ChooseDlgProc(), ChooseScilabDlgProc(), DDEOpenConnection(), EvaluateSelection(), ExportStyleDlgProc(), FindFreeScilexNumber(), GetScilabSpecialKeyCode(), GetTextFromClipboard(), GetVal(), HelpOn(), InitCheckBIN(), InitCheckCOS(), InitCheckCOSF(), InitCheckDEM(), InitCheckGRAPH(), InitCheckGRAPHB(), InitCheckSAV(), InitCheckSCE(), InitCheckSCI(), InitCheckTST(), IsEmptyClipboard(), LoadGraphMacros(), LoadMacros(), ModifyEntityPickerToolbar(), ON_EVENT_GRAPH_WM_KEYDOWN(), ON_EVENT_GRAPH_WM_KEYUP(), ON_WND_GRAPH_WM_COMMAND(), ON_WND_PARENTGRAPH_WM_KEY(), OpenSelection(), PasteFunction(), PrintSelection(), PutTextInClipboard(), SciPalette(), Statusbar_MenuSelect(), TextCopyClip(), and UpdateFromCheckBox().

BOOL WindowMode [static]

Definition at line 12 of file WinConsole.c.

Referenced by IsConsoleMode(), IsWindowInterface(), and SetWindowMode().

int Windows_Console_State [static]

Definition at line 13 of file WinConsole.c.

Referenced by CreateScilabConsole(), GetConsoleState(), and SetConsoleState().


Generated on Sun Mar 4 15:59:07 2007 for Scilab [trunk] by  doxygen 1.5.1