Loading common/common.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ #include "common.h" #include "macros.h" #include "build_version.h" #include <wx/process.h> /*****************************/ wxString GetBuildVersion() Loading @@ -30,7 +30,9 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxS /*********************************************************************************************/ { // All sizes are in 1/1000 inch m_Size = size; m_Offset = offset, m_Name = name; m_Size = size; m_Offset = offset; m_Name = name; // Adjust the default value for margins to 400 mils (0,4 inch or 10 mm) m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400; Loading Loading @@ -205,6 +207,7 @@ wxString GenDate() wxT( "jan" ), wxT( "feb" ), wxT( "mar" ), wxT( "apr" ), wxT( "may" ), wxT( "jun" ), wxT( "jul" ), wxT( "aug" ), wxT( "sep" ), wxT( "oct" ), wxT( "nov" ), wxT( "dec" ) }; time_t buftime; struct tm* Date; wxString string_date; Loading Loading @@ -241,6 +244,14 @@ void* MyMalloc( size_t nb_octets ) } bool ProcessExecute( const wxString& aCommandLine, int aFlags ) { wxProcess* process = wxProcess::Open( aCommandLine, aFlags ); return process != NULL; } /************************************/ void* MyZMalloc( size_t nb_octets ) /************************************/ Loading common/eda_doc.cpp +221 −202 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ /*****************************************/ void WinEDA_App::ReadPdfBrowserInfos() /*****************************************/ /* Read from Common config the Pdf browser choice */ { Loading @@ -32,17 +33,22 @@ void WinEDA_App::ReadPdfBrowserInfos() m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), TRUE ); m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), wxEmptyString ); } if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; if( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; } /*****************************************/ void WinEDA_App::WritePdfBrowserInfos() /*****************************************/ /* Write into Common config the Pdf browser choice */ { if ( ! m_EDA_CommonConfig ) return; if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; if( !m_EDA_CommonConfig ) return; if( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault ); m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser ); } Loading @@ -69,6 +75,7 @@ static const wxFileTypeInfo EDAfallbacks[] = wxT( "eeschema -p %s" ), wxT( "sch document (from Kicad)" ), wxT( "sch" ), wxT( "SCH" ), NULL ), // must terminate the table with this! wxFileTypeInfo() }; Loading @@ -78,13 +85,14 @@ static const wxFileTypeInfo EDAfallbacks[] = bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, const wxString& DocName ) /*********************************************************************/ /* Launch the viewer for the doc file DocName (mime type) LibPath is the doc file search path: (kicad/library) DocName is the short filename with ext. Wildcarts are allowed Seach file is made in LibPath/doc/DocName if DocName is starting by http: or ftp: or www. the default internet browser is launched /* Launch the viewer for the doc file DocName (mime type) * LibPath is the doc file search path: * (kicad/library) * DocName is the short filename with ext. Wildcarts are allowed * Seach file is made in LibPath/doc/DocName * * if DocName is starting by http: or ftp: or www. the default internet browser is launched */ { wxString docpath, fullfilename; Loading @@ -93,7 +101,8 @@ wxString command; bool success = FALSE; // Is an internet url wxString url_header[3] = {wxT("http:"), wxT("ftp:"),wxT("www.") }; static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) { if( DocName.First( url_header[ii] ) == 0 ) //. seems an internet url Loading @@ -104,7 +113,8 @@ bool success = FALSE; } /* Compute the full file name */ if ( wxIsAbsolutePath(DocName) ) fullfilename = DocName; if( wxIsAbsolutePath( DocName ) ) fullfilename = DocName; else { docpath = LibPath + wxT( "doc/" ); Loading @@ -118,6 +128,7 @@ bool success = FALSE; #endif wxString mask( wxT( "*" ) ), extension; #ifdef __WINDOWS__ mask += wxT( ".*" ); extension = wxT( ".*" ); Loading @@ -136,7 +147,8 @@ bool success = FALSE; TRUE, /* true = ne change pas le repertoire courant */ wxPoint( -1, -1 ) ); if ( fullfilename.IsEmpty() ) return FALSE; if( fullfilename.IsEmpty() ) return FALSE; } if( !wxFileExists( fullfilename ) ) Loading @@ -152,6 +164,7 @@ bool success = FALSE; { wxFileType* filetype; wxFileName CurrentFileName( fullfilename ); wxString ext, type; ext = CurrentFileName.GetExt(); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); Loading @@ -168,9 +181,11 @@ bool success = FALSE; if( filetype ) { wxFileType::MessageParameters params( fullfilename, type ); success = filetype->GetOpenCommand( &command, params ); delete filetype; if ( success ) wxExecute(command); if( success ) ProcessExecute( command ); } if( !success ) Loading @@ -179,7 +194,7 @@ bool success = FALSE; if( ext == wxT( "pdf" ) ) { success = TRUE; command.Empty(); if ( wxFileExists( wxT("/usr/bin/xpdf")) ) if( wxFileExists( wxT( "/usr/bin/kpdf" ) ) ) command = wxT( "xpdf " ) + fullfilename; else if( wxFileExists( wxT( "/usr/bin/konqueror" ) ) ) command = wxT( "konqueror " ) + fullfilename; Loading @@ -188,10 +203,11 @@ bool success = FALSE; if( command.IsEmpty() ) // not started { DisplayError( frame, _(" Cannot find the PDF viewer (xpdf, gpdf or konqueror) in /usr/bin/") ); _( " Cannot find the PDF viewer (kpdf, gpdf or konqueror) in /usr/bin/" ) ); success = FALSE; } else wxExecute(command); else ProcessExecute( command ); } else #endif Loading @@ -202,7 +218,6 @@ bool success = FALSE; } } } else { command = g_EDA_Appl->m_PdfBrowser; Loading @@ -211,9 +226,8 @@ bool success = FALSE; success = TRUE; AddDelimiterString( fullfilename ); command += wxT( " " ) + fullfilename; wxExecute(command); ProcessExecute( command ); } else { Line.Printf( _( "Cannot find Pdf viewer %s" ), command.GetData() ); Loading @@ -224,39 +238,44 @@ bool success = FALSE; return success; } /******************************************************************/ int KeyWordOk( const wxString& KeyList, const wxString& Database ) /******************************************************************/ /* Recherche si dans le texte Database on retrouve tous les mots cles donnes dans KeyList ( KeyList = suite de mots cles separes par des espaces Retourne: 0 si aucun mot cle trouv 1 si mot cle trouv * cles donnes dans KeyList ( KeyList = suite de mots cles * separes par des espaces * Retourne: * 0 si aucun mot cle trouv * 1 si mot cle trouv */ { wxString KeysCopy, DataList; if( KeyList.IsEmpty() ) return(0); if( KeyList.IsEmpty() ) return 0; KeysCopy = KeyList; KeysCopy.MakeUpper(); DataList = Database; DataList.MakeUpper(); wxStringTokenizer Token( KeysCopy, wxT( " \n\r" ) ); while( Token.HasMoreTokens() ) { wxString Key = Token.GetNextToken(); // Search Key in Datalist: wxStringTokenizer Data( DataList, wxT( " \n\r" ) ); while( Data.HasMoreTokens() ) { wxString word = Data.GetNextToken(); if ( word == Key ) return 1; // Key found ! if( word == Key ) return 1; // Key found ! } } // keyword not found return(0); return 0; } common/gestfich.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -533,7 +533,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para { if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; wxExecute( FullFileName ); ProcessExecute( FullFileName ); return 0; } Loading Loading @@ -748,7 +748,7 @@ void OpenPDF( const wxString& file ) } if( !command.IsEmpty() ) wxExecute( command ); ProcessExecute( command ); } Loading @@ -771,5 +771,5 @@ void OpenFile( const wxString& file ) delete filetype; if( success && !command.IsEmpty() ) wxExecute( command ); ProcessExecute( command ); } eeschema/netform.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -342,7 +342,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, CommandFile += wxT( " " ) + TmpFullFileName; CommandFile += wxT( " " ) + FullFileName; wxExecute( CommandFile, wxEXEC_SYNC ); ProcessExecute( CommandFile, wxEXEC_SYNC ); } Loading include/common.h +16 −4 Original line number Diff line number Diff line Loading @@ -354,6 +354,18 @@ class WinEDA_DrawPanel; /* COMMON.CPP */ /** * Function ProcessExecute * runs a child process. * @param aCommandLine The process and any arguments to it all in a single string. * @param aFlags The same args as allowed for wxExecute() * @return bool - true if success, else false */ bool ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC ); wxString ReturnPcbLayerName( int layer_number, bool is_filename = FALSE ); /* Return the name of the layer number "layer_number". Loading Loading
common/common.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ #include "common.h" #include "macros.h" #include "build_version.h" #include <wx/process.h> /*****************************/ wxString GetBuildVersion() Loading @@ -30,7 +30,9 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size, const wxPoint& offset, const wxS /*********************************************************************************************/ { // All sizes are in 1/1000 inch m_Size = size; m_Offset = offset, m_Name = name; m_Size = size; m_Offset = offset; m_Name = name; // Adjust the default value for margins to 400 mils (0,4 inch or 10 mm) m_LeftMargin = m_RightMargin = m_TopMargin = m_BottomMargin = 400; Loading Loading @@ -205,6 +207,7 @@ wxString GenDate() wxT( "jan" ), wxT( "feb" ), wxT( "mar" ), wxT( "apr" ), wxT( "may" ), wxT( "jun" ), wxT( "jul" ), wxT( "aug" ), wxT( "sep" ), wxT( "oct" ), wxT( "nov" ), wxT( "dec" ) }; time_t buftime; struct tm* Date; wxString string_date; Loading Loading @@ -241,6 +244,14 @@ void* MyMalloc( size_t nb_octets ) } bool ProcessExecute( const wxString& aCommandLine, int aFlags ) { wxProcess* process = wxProcess::Open( aCommandLine, aFlags ); return process != NULL; } /************************************/ void* MyZMalloc( size_t nb_octets ) /************************************/ Loading
common/eda_doc.cpp +221 −202 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ /*****************************************/ void WinEDA_App::ReadPdfBrowserInfos() /*****************************************/ /* Read from Common config the Pdf browser choice */ { Loading @@ -32,17 +33,22 @@ void WinEDA_App::ReadPdfBrowserInfos() m_PdfBrowserIsDefault = m_EDA_CommonConfig->Read( wxT( "PdfBrowserIsDefault" ), TRUE ); m_PdfBrowser = m_EDA_CommonConfig->Read( wxT( "PdfBrowserName" ), wxEmptyString ); } if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; if( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; } /*****************************************/ void WinEDA_App::WritePdfBrowserInfos() /*****************************************/ /* Write into Common config the Pdf browser choice */ { if ( ! m_EDA_CommonConfig ) return; if ( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; if( !m_EDA_CommonConfig ) return; if( m_PdfBrowser.IsEmpty() ) m_PdfBrowserIsDefault = TRUE; m_EDA_CommonConfig->Write( wxT( "PdfBrowserIsDefault" ), m_PdfBrowserIsDefault ); m_EDA_CommonConfig->Write( wxT( "PdfBrowserName" ), m_PdfBrowser ); } Loading @@ -69,6 +75,7 @@ static const wxFileTypeInfo EDAfallbacks[] = wxT( "eeschema -p %s" ), wxT( "sch document (from Kicad)" ), wxT( "sch" ), wxT( "SCH" ), NULL ), // must terminate the table with this! wxFileTypeInfo() }; Loading @@ -78,13 +85,14 @@ static const wxFileTypeInfo EDAfallbacks[] = bool GetAssociatedDocument( wxFrame* frame, const wxString& LibPath, const wxString& DocName ) /*********************************************************************/ /* Launch the viewer for the doc file DocName (mime type) LibPath is the doc file search path: (kicad/library) DocName is the short filename with ext. Wildcarts are allowed Seach file is made in LibPath/doc/DocName if DocName is starting by http: or ftp: or www. the default internet browser is launched /* Launch the viewer for the doc file DocName (mime type) * LibPath is the doc file search path: * (kicad/library) * DocName is the short filename with ext. Wildcarts are allowed * Seach file is made in LibPath/doc/DocName * * if DocName is starting by http: or ftp: or www. the default internet browser is launched */ { wxString docpath, fullfilename; Loading @@ -93,7 +101,8 @@ wxString command; bool success = FALSE; // Is an internet url wxString url_header[3] = {wxT("http:"), wxT("ftp:"),wxT("www.") }; static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) }; for( int ii = 0; ii < 3; ii++ ) { if( DocName.First( url_header[ii] ) == 0 ) //. seems an internet url Loading @@ -104,7 +113,8 @@ bool success = FALSE; } /* Compute the full file name */ if ( wxIsAbsolutePath(DocName) ) fullfilename = DocName; if( wxIsAbsolutePath( DocName ) ) fullfilename = DocName; else { docpath = LibPath + wxT( "doc/" ); Loading @@ -118,6 +128,7 @@ bool success = FALSE; #endif wxString mask( wxT( "*" ) ), extension; #ifdef __WINDOWS__ mask += wxT( ".*" ); extension = wxT( ".*" ); Loading @@ -136,7 +147,8 @@ bool success = FALSE; TRUE, /* true = ne change pas le repertoire courant */ wxPoint( -1, -1 ) ); if ( fullfilename.IsEmpty() ) return FALSE; if( fullfilename.IsEmpty() ) return FALSE; } if( !wxFileExists( fullfilename ) ) Loading @@ -152,6 +164,7 @@ bool success = FALSE; { wxFileType* filetype; wxFileName CurrentFileName( fullfilename ); wxString ext, type; ext = CurrentFileName.GetExt(); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); Loading @@ -168,9 +181,11 @@ bool success = FALSE; if( filetype ) { wxFileType::MessageParameters params( fullfilename, type ); success = filetype->GetOpenCommand( &command, params ); delete filetype; if ( success ) wxExecute(command); if( success ) ProcessExecute( command ); } if( !success ) Loading @@ -179,7 +194,7 @@ bool success = FALSE; if( ext == wxT( "pdf" ) ) { success = TRUE; command.Empty(); if ( wxFileExists( wxT("/usr/bin/xpdf")) ) if( wxFileExists( wxT( "/usr/bin/kpdf" ) ) ) command = wxT( "xpdf " ) + fullfilename; else if( wxFileExists( wxT( "/usr/bin/konqueror" ) ) ) command = wxT( "konqueror " ) + fullfilename; Loading @@ -188,10 +203,11 @@ bool success = FALSE; if( command.IsEmpty() ) // not started { DisplayError( frame, _(" Cannot find the PDF viewer (xpdf, gpdf or konqueror) in /usr/bin/") ); _( " Cannot find the PDF viewer (kpdf, gpdf or konqueror) in /usr/bin/" ) ); success = FALSE; } else wxExecute(command); else ProcessExecute( command ); } else #endif Loading @@ -202,7 +218,6 @@ bool success = FALSE; } } } else { command = g_EDA_Appl->m_PdfBrowser; Loading @@ -211,9 +226,8 @@ bool success = FALSE; success = TRUE; AddDelimiterString( fullfilename ); command += wxT( " " ) + fullfilename; wxExecute(command); ProcessExecute( command ); } else { Line.Printf( _( "Cannot find Pdf viewer %s" ), command.GetData() ); Loading @@ -224,39 +238,44 @@ bool success = FALSE; return success; } /******************************************************************/ int KeyWordOk( const wxString& KeyList, const wxString& Database ) /******************************************************************/ /* Recherche si dans le texte Database on retrouve tous les mots cles donnes dans KeyList ( KeyList = suite de mots cles separes par des espaces Retourne: 0 si aucun mot cle trouv 1 si mot cle trouv * cles donnes dans KeyList ( KeyList = suite de mots cles * separes par des espaces * Retourne: * 0 si aucun mot cle trouv * 1 si mot cle trouv */ { wxString KeysCopy, DataList; if( KeyList.IsEmpty() ) return(0); if( KeyList.IsEmpty() ) return 0; KeysCopy = KeyList; KeysCopy.MakeUpper(); DataList = Database; DataList.MakeUpper(); wxStringTokenizer Token( KeysCopy, wxT( " \n\r" ) ); while( Token.HasMoreTokens() ) { wxString Key = Token.GetNextToken(); // Search Key in Datalist: wxStringTokenizer Data( DataList, wxT( " \n\r" ) ); while( Data.HasMoreTokens() ) { wxString word = Data.GetNextToken(); if ( word == Key ) return 1; // Key found ! if( word == Key ) return 1; // Key found ! } } // keyword not found return(0); return 0; }
common/gestfich.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -533,7 +533,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para { if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; wxExecute( FullFileName ); ProcessExecute( FullFileName ); return 0; } Loading Loading @@ -748,7 +748,7 @@ void OpenPDF( const wxString& file ) } if( !command.IsEmpty() ) wxExecute( command ); ProcessExecute( command ); } Loading @@ -771,5 +771,5 @@ void OpenFile( const wxString& file ) delete filetype; if( success && !command.IsEmpty() ) wxExecute( command ); ProcessExecute( command ); }
eeschema/netform.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -342,7 +342,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, CommandFile += wxT( " " ) + TmpFullFileName; CommandFile += wxT( " " ) + FullFileName; wxExecute( CommandFile, wxEXEC_SYNC ); ProcessExecute( CommandFile, wxEXEC_SYNC ); } Loading
include/common.h +16 −4 Original line number Diff line number Diff line Loading @@ -354,6 +354,18 @@ class WinEDA_DrawPanel; /* COMMON.CPP */ /** * Function ProcessExecute * runs a child process. * @param aCommandLine The process and any arguments to it all in a single string. * @param aFlags The same args as allowed for wxExecute() * @return bool - true if success, else false */ bool ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC ); wxString ReturnPcbLayerName( int layer_number, bool is_filename = FALSE ); /* Return the name of the layer number "layer_number". Loading