mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-07 18:15:32 +00:00
Pretty-print clipboard data.
This commit is contained in:
parent
f9238f58f4
commit
dfbbb5afa1
eeschema
pcbnew
@ -52,6 +52,7 @@
|
||||
#include "symbol_saveas_type.h"
|
||||
|
||||
#include <widgets/symbol_filedlg_save_as.h>
|
||||
#include <io/kicad/kicad_io_utils.h>
|
||||
|
||||
|
||||
void SYMBOL_EDIT_FRAME::UpdateTitle()
|
||||
@ -1213,6 +1214,9 @@ void SYMBOL_EDIT_FRAME::CopySymbolToClipboard()
|
||||
SCH_IO_KICAD_SEXPR::FormatLibSymbol( tmp.get(), formatter );
|
||||
}
|
||||
|
||||
std::string prettyData = formatter.GetString();
|
||||
KICAD_FORMAT::Prettify( prettyData );
|
||||
|
||||
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
||||
|
||||
auto clipboard = wxTheClipboard;
|
||||
@ -1221,7 +1225,7 @@ void SYMBOL_EDIT_FRAME::CopySymbolToClipboard()
|
||||
if( !clipboardLock || !clipboard->IsOpened() )
|
||||
return;
|
||||
|
||||
auto data = new wxTextDataObject( wxString( formatter.GetString().c_str(), wxConvUTF8 ) );
|
||||
auto data = new wxTextDataObject( wxString( prettyData.c_str(), wxConvUTF8 ) );
|
||||
clipboard->SetData( data );
|
||||
|
||||
clipboard->Flush();
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include <wx/log.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <io/kicad/kicad_io_utils.h>
|
||||
#include "sch_edit_table_tool.h"
|
||||
|
||||
#ifdef KICAD_IPC_API
|
||||
@ -1341,16 +1342,19 @@ bool SCH_EDITOR_CONTROL::doCopy( bool aUseDuplicateClipboard )
|
||||
|
||||
plugin.Format( &selection, &selPath, schematic, &formatter, true );
|
||||
|
||||
std::string prettyData = formatter.GetString();
|
||||
KICAD_FORMAT::Prettify( prettyData );
|
||||
|
||||
if( selection.IsHover() )
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
|
||||
|
||||
if( aUseDuplicateClipboard )
|
||||
{
|
||||
m_duplicateClipboard = formatter.GetString();
|
||||
m_duplicateClipboard = prettyData;
|
||||
return true;
|
||||
}
|
||||
|
||||
return SaveClipboard( formatter.GetString() );
|
||||
return SaveClipboard( prettyData );
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <sch_textbox.h>
|
||||
#include <wx/textdlg.h> // for wxTextEntryDialog
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <io/kicad/kicad_io_utils.h>
|
||||
|
||||
SYMBOL_EDITOR_EDIT_TOOL::SYMBOL_EDITOR_EDIT_TOOL() :
|
||||
EE_TOOL_BASE( "eeschema.SymbolEditTool" ),
|
||||
@ -919,7 +920,10 @@ int SYMBOL_EDITOR_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
|
||||
for( SCH_ITEM& item : symbol->GetDrawItems() )
|
||||
item.ClearFlags( STRUCT_DELETED );
|
||||
|
||||
if( SaveClipboard( formatter.GetString() ) )
|
||||
std::string prettyData = formatter.GetString();
|
||||
KICAD_FORMAT::Prettify( prettyData );
|
||||
|
||||
if( SaveClipboard( prettyData ) )
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.h>
|
||||
#include <kicad_clipboard.h>
|
||||
#include <kidialog.h>
|
||||
#include <io/kicad/kicad_io_utils.h>
|
||||
|
||||
CLIPBOARD_IO::CLIPBOARD_IO():
|
||||
PCB_IO_KICAD_SEXPR(CTL_FOR_CLIPBOARD ),
|
||||
@ -397,6 +398,9 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
||||
m_formatter.Print( 0, "\n)" );
|
||||
}
|
||||
|
||||
std::string prettyData = m_formatter.GetString();
|
||||
KICAD_FORMAT::Prettify( prettyData );
|
||||
|
||||
// These are placed at the end to minimize the open time of the clipboard
|
||||
wxLogNull doNotLog; // disable logging of failed clipboard actions
|
||||
auto clipboard = wxTheClipboard;
|
||||
@ -405,12 +409,11 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
||||
if( !clipboardLock || !clipboard->IsOpened() )
|
||||
return;
|
||||
|
||||
clipboard->SetData( new wxTextDataObject( wxString( m_formatter.GetString().c_str(),
|
||||
wxConvUTF8 ) ) );
|
||||
clipboard->SetData( new wxTextDataObject( wxString( prettyData.c_str(), wxConvUTF8 ) ) );
|
||||
|
||||
clipboard->Flush();
|
||||
|
||||
#ifndef __WXOSX__
|
||||
#ifndef __WXOSX__
|
||||
// This section exists to return the clipboard data, ensuring it has fully
|
||||
// been processed by the system clipboard. This appears to be needed for
|
||||
// extremely large clipboard copies on asynchronous linux clipboard managers
|
||||
@ -424,7 +427,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
||||
clipboard->GetData( data );
|
||||
ignore_unused( data.GetText() );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -475,7 +478,9 @@ void CLIPBOARD_IO::SaveBoard( const wxString& aFileName, BOARD* aBoard,
|
||||
|
||||
m_out = &formatter;
|
||||
|
||||
m_out->Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n", SEXPR_BOARD_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
|
||||
m_out->Print( 0, "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n",
|
||||
SEXPR_BOARD_FILE_VERSION,
|
||||
GetMajorMinorVersion().c_str().AsChar() );
|
||||
|
||||
Format( aBoard, 1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user