Convert smart quotes and dashes to ASCII in DRC rules.

Fixes https://gitlab.com/kicad/code/kicad/issues/5135
This commit is contained in:
Jeff Young 2020-08-10 18:16:22 +01:00
parent 0a6a91b5ad
commit de6314e3b5
2 changed files with 41 additions and 4 deletions

View File

@ -23,10 +23,12 @@
#include <fctsys.h>
#include <kicad_string.h>
#include <scintilla_tricks.h>
#include <wx/stc/stc.h>
#include <gal/color4d.h>
#include <dialog_shim.h>
#include <wx/clipbrd.h>
SCINTILLA_TRICKS::SCINTILLA_TRICKS( wxStyledTextCtrl* aScintilla, const wxString& aBraces ) :
m_te( aScintilla ),
@ -66,7 +68,13 @@ SCINTILLA_TRICKS::SCINTILLA_TRICKS( wxStyledTextCtrl* aScintilla, const wxString
void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
{
if( aEvent.GetKeyCode() == WXK_TAB )
wxString c = aEvent.GetUnicodeKey();
if( ConvertSmartQuotesAndDashes( &c ) )
{
m_te->AddText( c );
}
else if( aEvent.GetKeyCode() == WXK_TAB )
{
if( aEvent.ControlDown() )
{
@ -107,7 +115,25 @@ void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
}
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'V' )
{
m_te->Paste();
if( m_te->GetSelectionEnd() > m_te->GetSelectionStart() )
m_te->DeleteBack();
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
wxTextDataObject data;
wxString str;
wxTheClipboard->GetData( data );
str = data.GetText();
ConvertSmartQuotesAndDashes( &str );
m_te->AddText( str );
}
wxTheClipboard->Close();
}
}
else if( aEvent.GetKeyCode() == WXK_BACK )
{

View File

@ -294,7 +294,18 @@ bool PANEL_SETUP_RULES::TransferDataToWindow()
wxFileName rulesFile( rulesFilepath );
if( rulesFile.FileExists() )
m_textEditor->LoadFile( rulesFile.GetFullPath() );
{
wxTextFile file( rulesFile.GetFullPath() );
if( file.Open() )
{
for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
{
ConvertSmartQuotesAndDashes( &str );
m_textEditor->AddText( str << '\n' );
}
}
}
m_originalText = m_textEditor->GetText();