Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
wxScintilla rectangular/block pasting bug
SiegeLord:
A continuation of this thread: 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:
--- Code: ---
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()
--- End code ---
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?
SiegeLord:
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:
--- Code: ---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"))));
--- End code ---
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...
MortenMacFly:
--- Quote from: SiegeLord on May 15, 2008, 06:51:53 am ---I'll fix the remaining annoyances in the actual PasteRectangular algorithm when I get the chance...
--- End quote ---
Nice work! Just to tell you that I am tracking this... will try myself and look for side effects...
Jenna:
I tried your patch on linux (64 debian unstable/experimental) and on W2K, both seem to work without any problems.
--- Quote from: SiegeLord on May 10, 2008, 01:35:16 am ---A continuation of this thread: http://forums.codeblocks.org/index.php/topic,8309.0.html. (A new thread since I can now provide some code... 8))
--- End quote ---
I would prefer not to open a new topic for the same thing, because I sometimes watch threads using the notify ability, what of course does not work if a new topic is opened.
MortenMacFly:
--- Quote from: MortenMacFly on May 15, 2008, 08:52:39 am ---will try myself and look for side effects...
--- End quote ---
So far no issues (but a working paste behaviour) under Windows here, too...
Navigation
[0] Message Index
[#] Next page
Go to full version