A continuation of this thread: http://forums.codeblocks.org/index.php/topic,8309.0.html (http://forums.codeblocks.org/index.php/topic,8309.0.html). (A new thread since I can now provide some code... 8))
I believe I tracked the source of the bug down to some weird behaviour on the part of the wx's clipboard...
This particular code blurb illustrates the problem:
wxDataFormatId type = wxDF_PRIVATE;
//First, try putting something into the clipboard
wxTheClipboard->Open()
wxCustomDataObject* data = new wxCustomDataObject(type);
//now fill data with something
wxTheClipboard->SetData(data);
wxTheClipboard->Close()
//now lets see if we can get it back
wxTheClipboard->Open()
wxCustomDataObject test_data(type);
bool weHaveData = wxTheClipboard->GetData(test_data);
wxTheClipboard->Close()
This roughly follows the pathway between ScintillaWX::CopyToClipboard and ScintillaWX::Paste.
I have observed that the data is returned if and only if type is either wxDF_UNICODETEXT or wxDF_TEXT. The clipboard appears to discard anything else. Since the block pasting relies on the custom data block of the type wxDF_PRIVATE, it naturally gets discarded and fails to work. I tried replacing wxDF_PRIVATE with wxDF_UNICODETEXT, and voila, the block pasting worked. This is naturally a hack, and probably unsuitable to solve this.
So, anyone have any idea what is going on here? Some bug in the clipboard that only allows to put text onto it?
Success!
Turns out the person who coded that part of wxScintilla did not know how to work with the clipboard...
I don't know how to do diffs unfortunately, but here are the two lines that need to be changed:
Line 505: ScintillaWX.cpp
Change from:
wxCustomDataObject selData(wxDF_PRIVATE);
to
wxCustomDataObject selData(wxDataFormat(wxString(wxT("rect_data"))));
Line 558: ScintillaWX.cpp
Change from:
wxCustomDataObject* rectData = new wxCustomDataObject (wxDF_PRIVATE);
to
wxCustomDataObject* rectData = new wxCustomDataObject (wxDataFormat(wxString(wxT("rect_data"))));
This makes block pasting work. It is maybe a little hacky... But it works.
The pasting behaviour is still a little suboptimal, but at least it actually uses the correct rect data, and does a pretty good job at pasting blocks. I'll fix the remaining annoyances in the actual PasteRectangular algorithm when I get the chance...