mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
ADDED: Paste tabular contents to parent table.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21109
This commit is contained in:
parent
6ac5ca7fc4
commit
b0663d84cb
@ -714,7 +714,7 @@ void GRID_TRICKS::paste_clipboard()
|
||||
// Some editors use windows linefeeds (\r\n), which wx re-writes to \n\n
|
||||
text.Replace( "\n\n", "\n" );
|
||||
#endif
|
||||
|
||||
m_grid->CommitPendingChanges( true );
|
||||
paste_text( text );
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <wx/log.h>
|
||||
#include <wx/settings.h>
|
||||
#include <confirm.h>
|
||||
#include <grid_tricks.h>
|
||||
|
||||
SCINTILLA_TRICKS::SCINTILLA_TRICKS( wxStyledTextCtrl* aScintilla, const wxString& aBraces,
|
||||
bool aSingleLine,
|
||||
@ -216,6 +217,28 @@ void SCINTILLA_TRICKS::onModified( wxStyledTextEvent& aEvent )
|
||||
|
||||
void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
||||
{
|
||||
auto findGridTricks =
|
||||
[&]() -> GRID_TRICKS*
|
||||
{
|
||||
wxWindow* parent = m_te->GetParent();
|
||||
|
||||
while( parent && !dynamic_cast<WX_GRID*>( parent ) )
|
||||
parent = parent->GetParent();
|
||||
|
||||
if( WX_GRID* grid = dynamic_cast<WX_GRID*>( parent ) )
|
||||
{
|
||||
wxEvtHandler* handler = grid->GetEventHandler();
|
||||
|
||||
while( handler && !dynamic_cast<GRID_TRICKS*>( handler ) )
|
||||
handler = handler->GetNextHandler();
|
||||
|
||||
if( GRID_TRICKS* gridTricks = dynamic_cast<GRID_TRICKS*>( handler ) )
|
||||
return gridTricks;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
wxString c = aEvent.GetUnicodeKey();
|
||||
|
||||
if( m_te->AutoCompActive() )
|
||||
@ -373,7 +396,8 @@ void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
||||
if( m_te->GetSelectionEnd() > m_te->GetSelectionStart() )
|
||||
m_te->DeleteBack();
|
||||
|
||||
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
||||
GRID_TRICKS* gridTricks = nullptr;
|
||||
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
||||
|
||||
if( wxTheClipboard->Open() )
|
||||
{
|
||||
@ -386,21 +410,30 @@ void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
||||
wxTheClipboard->GetData( data );
|
||||
str = data.GetText();
|
||||
|
||||
ConvertSmartQuotesAndDashes( &str );
|
||||
if( str.Contains( '\t' ) )
|
||||
gridTricks = findGridTricks();
|
||||
|
||||
if( m_singleLine )
|
||||
if( !gridTricks )
|
||||
{
|
||||
str.Replace( wxS( "\n" ), wxEmptyString );
|
||||
str.Replace( wxS( "\r" ), wxEmptyString );
|
||||
}
|
||||
ConvertSmartQuotesAndDashes( &str );
|
||||
|
||||
m_te->BeginUndoAction();
|
||||
m_te->AddText( str );
|
||||
m_te->EndUndoAction();
|
||||
if( m_singleLine )
|
||||
{
|
||||
str.Replace( wxS( "\n" ), wxEmptyString );
|
||||
str.Replace( wxS( "\r" ), wxEmptyString );
|
||||
}
|
||||
|
||||
m_te->BeginUndoAction();
|
||||
m_te->AddText( str );
|
||||
m_te->EndUndoAction();
|
||||
}
|
||||
}
|
||||
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
|
||||
if( gridTricks )
|
||||
gridTricks->onKeyDown( aEvent );
|
||||
}
|
||||
else if( aEvent.GetKeyCode() == WXK_BACK )
|
||||
{
|
||||
|
@ -89,6 +89,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Allow various conspiracies between the two tricks handlers
|
||||
friend class SCINTILLA_TRICKS;
|
||||
|
||||
/// Shared initialization for various ctors.
|
||||
void init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user