Fixup clipboard usage a bit more.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2002-08-26 17:50:44 +00:00
parent a8fae7f78d
commit 45c6a92768
2 changed files with 36 additions and 24 deletions

View File

@ -321,11 +321,12 @@ void ScintillaWX::Copy() {
if (currentPos != anchor) { if (currentPos != anchor) {
SelectionText st; SelectionText st;
CopySelectionRange(&st); CopySelectionRange(&st);
wxTheClipboard->Open(); if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
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->Close(); wxTheClipboard->Close();
}
} }
} }
@ -335,12 +336,13 @@ void ScintillaWX::Paste() {
ClearSelection(); ClearSelection();
wxTextDataObject data; wxTextDataObject data;
bool gotData; bool gotData = FALSE;
wxTheClipboard->Open(); if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data); gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close(); wxTheClipboard->Close();
}
if (gotData) { if (gotData) {
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText()); wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf); int len = strlen(buf);
@ -356,12 +358,16 @@ void ScintillaWX::Paste() {
bool ScintillaWX::CanPaste() { bool ScintillaWX::CanPaste() {
bool canPaste = FALSE; bool canPaste = FALSE;
bool didOpen;
if (! wxTheClipboard->IsOpened()) { if ( (didOpen = !wxTheClipboard->IsOpened()) )
wxTheClipboard->Open(); wxTheClipboard->Open();
if (wxTheClipboard->IsOpened()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close(); if (didOpen)
wxTheClipboard->Close();
} }
return canPaste; return canPaste;
} }

View File

@ -321,11 +321,12 @@ void ScintillaWX::Copy() {
if (currentPos != anchor) { if (currentPos != anchor) {
SelectionText st; SelectionText st;
CopySelectionRange(&st); CopySelectionRange(&st);
wxTheClipboard->Open(); if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
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->Close(); wxTheClipboard->Close();
}
} }
} }
@ -335,12 +336,13 @@ void ScintillaWX::Paste() {
ClearSelection(); ClearSelection();
wxTextDataObject data; wxTextDataObject data;
bool gotData; bool gotData = FALSE;
wxTheClipboard->Open(); if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
gotData = wxTheClipboard->GetData(data); gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close(); wxTheClipboard->Close();
}
if (gotData) { if (gotData) {
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText()); wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(data.GetText());
int len = strlen(buf); int len = strlen(buf);
@ -356,12 +358,16 @@ void ScintillaWX::Paste() {
bool ScintillaWX::CanPaste() { bool ScintillaWX::CanPaste() {
bool canPaste = FALSE; bool canPaste = FALSE;
bool didOpen;
if (! wxTheClipboard->IsOpened()) { if ( (didOpen = !wxTheClipboard->IsOpened()) )
wxTheClipboard->Open(); wxTheClipboard->Open();
if (wxTheClipboard->IsOpened()) {
wxTheClipboard->UsePrimarySelection(); wxTheClipboard->UsePrimarySelection();
canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT); canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
wxTheClipboard->Close(); if (didOpen)
wxTheClipboard->Close();
} }
return canPaste; return canPaste;
} }