Enable the use of the primary selection
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a0421c774c
commit
e5abfc486b
@ -508,8 +508,8 @@ void ScintillaWX::Paste() {
|
|||||||
wxTextDataObject data;
|
wxTextDataObject data;
|
||||||
bool gotData = false;
|
bool gotData = false;
|
||||||
|
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
gotData = wxTheClipboard->GetData(data);
|
gotData = wxTheClipboard->GetData(data);
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
@ -537,8 +537,8 @@ void ScintillaWX::Paste() {
|
|||||||
|
|
||||||
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
|
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
|
||||||
#if wxUSE_CLIPBOARD
|
#if wxUSE_CLIPBOARD
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
|
wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
@ -555,12 +555,12 @@ bool ScintillaWX::CanPaste() {
|
|||||||
bool didOpen;
|
bool didOpen;
|
||||||
|
|
||||||
if (Editor::CanPaste()) {
|
if (Editor::CanPaste()) {
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
didOpen = !wxTheClipboard->IsOpened();
|
didOpen = !wxTheClipboard->IsOpened();
|
||||||
if ( didOpen )
|
if ( didOpen )
|
||||||
wxTheClipboard->Open();
|
wxTheClipboard->Open();
|
||||||
|
|
||||||
if (wxTheClipboard->IsOpened()) {
|
if (wxTheClipboard->IsOpened()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
|
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
|
||||||
if (didOpen)
|
if (didOpen)
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
@ -591,28 +591,24 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is called by the Editor base class whenever something is selected
|
// This is called by the Editor base class whenever something is selected.
|
||||||
|
// For wxGTK we can put this text in the primary selection and then other apps
|
||||||
|
// can paste with the middle button.
|
||||||
void ScintillaWX::ClaimSelection() {
|
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__
|
#ifdef __WXGTK__
|
||||||
// Put the selected text in the PRIMARY selection
|
// Put the selected text in the PRIMARY selection
|
||||||
if (currentPos != anchor) {
|
if (currentPos != anchor) {
|
||||||
SelectionText st;
|
SelectionText st;
|
||||||
CopySelectionRange(&st);
|
CopySelectionRange(&st);
|
||||||
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
|
||||||
wxString text = stc2wx(st.s, st.len);
|
wxString text = stc2wx(st.s, st.len);
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -891,12 +887,12 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
|||||||
pdoc->BeginUndoAction();
|
pdoc->BeginUndoAction();
|
||||||
wxTextDataObject data;
|
wxTextDataObject data;
|
||||||
bool gotData = false;
|
bool gotData = false;
|
||||||
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
|
||||||
gotData = wxTheClipboard->GetData(data);
|
gotData = wxTheClipboard->GetData(data);
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (gotData) {
|
if (gotData) {
|
||||||
wxString text = wxTextBuffer::Translate(data.GetText(),
|
wxString text = wxTextBuffer::Translate(data.GetText(),
|
||||||
wxConvertEOLMode(pdoc->eolMode));
|
wxConvertEOLMode(pdoc->eolMode));
|
||||||
|
@ -508,8 +508,8 @@ void ScintillaWX::Paste() {
|
|||||||
wxTextDataObject data;
|
wxTextDataObject data;
|
||||||
bool gotData = false;
|
bool gotData = false;
|
||||||
|
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
gotData = wxTheClipboard->GetData(data);
|
gotData = wxTheClipboard->GetData(data);
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
@ -537,8 +537,8 @@ void ScintillaWX::Paste() {
|
|||||||
|
|
||||||
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
|
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
|
||||||
#if wxUSE_CLIPBOARD
|
#if wxUSE_CLIPBOARD
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
|
wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
@ -555,12 +555,12 @@ bool ScintillaWX::CanPaste() {
|
|||||||
bool didOpen;
|
bool didOpen;
|
||||||
|
|
||||||
if (Editor::CanPaste()) {
|
if (Editor::CanPaste()) {
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
didOpen = !wxTheClipboard->IsOpened();
|
didOpen = !wxTheClipboard->IsOpened();
|
||||||
if ( didOpen )
|
if ( didOpen )
|
||||||
wxTheClipboard->Open();
|
wxTheClipboard->Open();
|
||||||
|
|
||||||
if (wxTheClipboard->IsOpened()) {
|
if (wxTheClipboard->IsOpened()) {
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
|
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
|
||||||
if (didOpen)
|
if (didOpen)
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
@ -591,28 +591,24 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is called by the Editor base class whenever something is selected
|
// This is called by the Editor base class whenever something is selected.
|
||||||
|
// For wxGTK we can put this text in the primary selection and then other apps
|
||||||
|
// can paste with the middle button.
|
||||||
void ScintillaWX::ClaimSelection() {
|
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__
|
#ifdef __WXGTK__
|
||||||
// Put the selected text in the PRIMARY selection
|
// Put the selected text in the PRIMARY selection
|
||||||
if (currentPos != anchor) {
|
if (currentPos != anchor) {
|
||||||
SelectionText st;
|
SelectionText st;
|
||||||
CopySelectionRange(&st);
|
CopySelectionRange(&st);
|
||||||
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
|
||||||
wxString text = stc2wx(st.s, st.len);
|
wxString text = stc2wx(st.s, st.len);
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(text));
|
wxTheClipboard->SetData(new wxTextDataObject(text));
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -891,12 +887,12 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
|
|||||||
pdoc->BeginUndoAction();
|
pdoc->BeginUndoAction();
|
||||||
wxTextDataObject data;
|
wxTextDataObject data;
|
||||||
bool gotData = false;
|
bool gotData = false;
|
||||||
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
if (wxTheClipboard->Open()) {
|
if (wxTheClipboard->Open()) {
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
|
||||||
gotData = wxTheClipboard->GetData(data);
|
gotData = wxTheClipboard->GetData(data);
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
if (gotData) {
|
if (gotData) {
|
||||||
wxString text = wxTextBuffer::Translate(data.GetText(),
|
wxString text = wxTextBuffer::Translate(data.GetText(),
|
||||||
wxConvertEOLMode(pdoc->eolMode));
|
wxConvertEOLMode(pdoc->eolMode));
|
||||||
|
Loading…
Reference in New Issue
Block a user