diff --git a/common/scintilla_tricks.cpp b/common/scintilla_tricks.cpp index adae90bcf4..8e1694f710 100644 --- a/common/scintilla_tricks.cpp +++ b/common/scintilla_tricks.cpp @@ -23,10 +23,12 @@ #include +#include #include #include #include #include +#include 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 ) { diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 36e08048eb..109a8b5f96 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -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(); @@ -309,7 +320,7 @@ bool PANEL_SETUP_RULES::TransferDataFromWindow() try { - std::vector dummyRules; + std::vector dummyRules; DRC_RULES_PARSER parser( m_frame->GetBoard(), m_textEditor->GetText(), _( "DRC rules" ) );