Unify string lists of forbidden footprint chars
We have forbidden lists maintained in 3 separate locations. This causes a bit of confusion as to which is correct. This makes the list uniform but remains to place the character set in a single location.
This commit is contained in:
parent
7b2d6ab40e
commit
43768b71c0
|
@ -374,10 +374,16 @@ bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType )
|
||||||
if( aUniChar < ' ' )
|
if( aUniChar < ' ' )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// This list of characters is also duplicated in validators.cpp and
|
||||||
|
// class_module.cpp
|
||||||
|
// TODO: Unify forbidden character lists
|
||||||
switch( aUniChar )
|
switch( aUniChar )
|
||||||
{
|
{
|
||||||
case ':':
|
case ':':
|
||||||
case '/':
|
case '/':
|
||||||
|
case '\t':
|
||||||
|
case '\n':
|
||||||
|
case '\r':
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
|
|
|
@ -68,20 +68,14 @@ void GRID_CELL_TEXT_EDITOR::StartingKey( wxKeyEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE_NAME_CHAR_VALIDATOR::FILE_NAME_CHAR_VALIDATOR( wxString* aValue ) :
|
MODULE_NAME_CHAR_VALIDATOR::MODULE_NAME_CHAR_VALIDATOR( wxString* aValue ) :
|
||||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
||||||
{
|
{
|
||||||
// The Windows (DOS) file system forbidden characters already include the forbidden
|
// This list of characters follows the string from class_module.cpp
|
||||||
// file name characters for both Posix and OSX systems. The characters \/:*?|"<> are
|
// which, in turn mimics the strings from lib_id.cpp
|
||||||
// illegal and filtered by the validator.
|
// TODO: Unify forbidden character lists
|
||||||
wxString illegalChars = wxFileName::GetForbiddenChars( wxPATH_DOS );
|
wxString illegalChars = "%$<>\t\n\r\"\\/:";
|
||||||
wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST );
|
SetCharExcludes( illegalChars );
|
||||||
wxArrayString illegalCharList;
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < illegalChars.size(); i++ )
|
|
||||||
illegalCharList.Add( wxString( illegalChars[i] ) );
|
|
||||||
|
|
||||||
SetExcludes( illegalCharList );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ protected:
|
||||||
* footprint names cannot have any characters that would prevent file creation on any platform.
|
* footprint names cannot have any characters that would prevent file creation on any platform.
|
||||||
* The characters \/:*?|"<> are illegal and filtered by the validator.
|
* The characters \/:*?|"<> are illegal and filtered by the validator.
|
||||||
*/
|
*/
|
||||||
class FILE_NAME_CHAR_VALIDATOR : public wxTextValidator
|
class MODULE_NAME_CHAR_VALIDATOR : public wxTextValidator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FILE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL );
|
MODULE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <class_edge_mod.h>
|
#include <class_edge_mod.h>
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <convert_basic_shapes_to_polygon.h>
|
#include <convert_basic_shapes_to_polygon.h>
|
||||||
|
#include <validators.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
|
|
||||||
MODULE::MODULE( BOARD* parent ) :
|
MODULE::MODULE( BOARD* parent ) :
|
||||||
|
@ -1025,8 +1026,11 @@ bool MODULE::IsLibNameValid( const wxString & aName )
|
||||||
|
|
||||||
const wxChar* MODULE::StringLibNameInvalidChars( bool aUserReadable )
|
const wxChar* MODULE::StringLibNameInvalidChars( bool aUserReadable )
|
||||||
{
|
{
|
||||||
static const wxChar invalidChars[] = wxT("%$\t\n\r \"\\/:");
|
// This list of characters is also duplicated in validators.cpp and
|
||||||
static const wxChar invalidCharsReadable[] = wxT("% $ 'tab' 'return' 'line feed' 'space' \\ \" / :");
|
// lib_id.cpp
|
||||||
|
// TODO: Unify forbidden character lists
|
||||||
|
static const wxChar invalidChars[] = wxT("%$<>\t\n\r\"\\/:");
|
||||||
|
static const wxChar invalidCharsReadable[] = wxT("% $ < > 'tab' 'return' 'line feed' \\ \" / :");
|
||||||
|
|
||||||
if( aUserReadable )
|
if( aUserReadable )
|
||||||
return invalidCharsReadable;
|
return invalidCharsReadable;
|
||||||
|
|
|
@ -106,7 +106,7 @@ DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aP
|
||||||
|
|
||||||
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
m_FootprintNameCtrl->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
|
m_FootprintNameCtrl->SetValidator( MODULE_NAME_CHAR_VALIDATOR() );
|
||||||
|
|
||||||
// Set font sizes
|
// Set font sizes
|
||||||
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||||
|
|
|
@ -1046,7 +1046,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName )
|
||||||
if( moduleName.IsEmpty() )
|
if( moduleName.IsEmpty() )
|
||||||
{
|
{
|
||||||
WX_TEXT_ENTRY_DIALOG dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
|
WX_TEXT_ENTRY_DIALOG dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
|
||||||
dlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &moduleName ) );
|
dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &moduleName ) );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return NULL; //Aborted by user
|
return NULL; //Aborted by user
|
||||||
|
|
|
@ -373,7 +373,7 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern,
|
||||||
// Generate footprint. the value is also used as footprint name.
|
// Generate footprint. the value is also used as footprint name.
|
||||||
msg = "L";
|
msg = "L";
|
||||||
WX_TEXT_ENTRY_DIALOG cmpdlg( aPcbFrame, _( "Component Value:" ), wxEmptyString, msg );
|
WX_TEXT_ENTRY_DIALOG cmpdlg( aPcbFrame, _( "Component Value:" ), wxEmptyString, msg );
|
||||||
cmpdlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &msg ) );
|
cmpdlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &msg ) );
|
||||||
|
|
||||||
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
|
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
|
||||||
return nullptr; // Aborted by user
|
return nullptr; // Aborted by user
|
||||||
|
|
Loading…
Reference in New Issue