To be short: Can we revert this one?
Although this is a really nice feature the way it is implemented in revision 3003 just doesn't work. OK, it probably works on windows but on Linux this revision made things worse than before.
The reason is: Linux (or the X-Window-System or even another component, not sure which one) implements this feature on its own (or at least a part of it) and thus this feature workes across all running applications (in theory). Before revision 3003 you could mark any text in any application (except Code::Blocks) and paste it to any application (including Code::Blocks) using the middle mouse button. The other way round, that means mark any text in Code::Blocks and try to paste it anywhere did not work, the marked text was just ignored and the old contents of the clipboard were used.
After revision 3003 things have changed but gone worse: Marking text in Code::Blocks and pasting it in any other application using the middle mouse button does still not work - nothing surprising here as the code from revision 3003 doens't do anything in this direction.
The other way (that is, marking text in any application except Code::Blocks and pasting it to Code::Blocks) still works, as long as there is no text selected in Code::Blocks. Marking text in Code::Blocks and pasting it to itself works, as long as the clipboard (or - to be precise - the primary selection) is empty.
But if you try to paste to Code::Blocks while there is text selected in Code::Blocks *and* the primary selection is not empty, *both* texts are pasted into the Code::Blocks editor. This is really scary...
Anyway, I would suggest to leave this code untouched for windows (if it works there) and completly remove it for wxGTK-builds because this feature is handled there in the subsystem.
One drawback is of course: Selecting text in Code::Blocks doesn't use this text as primary selection. The solution for this problem probably lies in the code of wxScintilla. A part of sdk/wxscintilla/srx/ScintillaWX.cpp looks like this:
// This is called by the Editor base class whenever something is selected
void ScintillaWX::ClaimSelection() {
#if 0
// Until wxGTK is able to support using both the primary selection and the
// clipboard at the same time I think it causes more problems than it is
// worth to implement this method. Selecting text should not clear the
// clipboard. --Robin
#ifdef __WXGTK__
// Put the selected text in the PRIMARY selection
if (currentPos != anchor) {
SelectionText st;
CopySelectionRange(&st);
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(true);
wxString text = sci2wx(st.s, st.len);
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->UsePrimarySelection(false);
wxTheClipboard->Close();
}
}
#endif
#endif
}
As you can see it implements this feature for wxGTK - but it is deactivated. If we want this feature on Linux we should probably re-activate this pice of code instead of using the code from revision 3003.