-#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1
-
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
if ( IsDirectionKey(keyCode) )
{
// just continue the old selection
- if ( m_Selecting )
+ if ( m_Selecting && event.ShiftDown() )
+ m_llist->ContinueSelection();
+ else
{
+ m_llist->DiscardSelection();
+ m_Selecting = false;
if( event.ShiftDown() )
- m_llist->ContinueSelection();
- else
{
- m_llist->DiscardSelection();
- m_Selecting = false;
+ m_Selecting = true;
+ m_llist->StartSelection();
}
}
- else if( event.ShiftDown() )
- {
- m_Selecting = true;
- m_llist->StartSelection();
- }
}
// If needed, make cursor visible:
{
case 'c':
// this should work even in read-only mode
- Copy();
+ Copy(TRUE, TRUE);
break;
case 's': // search
Find("");
m_llist->DeleteToEndOfLine();
SetDirty();
break;
+ case 'c':
+ Copy(TRUE, TRUE);
+ break;
case 'v':
- Paste();
+ Paste( TRUE );
break;
case 'x':
Cut();
)
{
if(m_WrapMargin > 0 && isspace(keyCode))
- m_llist->WrapLine(m_WrapMargin);
- m_llist->Insert((char)keyCode);
+ {
+ bool wrapped = m_llist->WrapLine(m_WrapMargin);
+ // donĀ“t insert space as first thing in line
+ // after wrapping:
+ if(! wrapped || m_llist->GetCursorPos().x != 0)
+ m_llist->Insert((char)keyCode);
+ }
+ else
+ m_llist->Insert((char)keyCode);
SetDirty();
}
else
// ----------------------------------------------------------------------------
void
-wxLayoutWindow::Paste(bool primary)
+wxLayoutWindow::Paste(bool usePrivate, bool primary)
{
// this only has an effect under X11:
- if(primary) wxTheClipboard->UsePrimarySelection();
+ wxTheClipboard->UsePrimarySelection(primary);
// Read some text
if (wxTheClipboard->Open())
{
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
- wxLayoutDataObject wxldo;
- if ( wxTheClipboard->GetData(wxldo) )
+ if(usePrivate)
{
- //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
- wxLayoutImportText(m_llist, wxldo.GetLayoutData());
+ wxLayoutDataObject wxldo;
+ if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
+ {
+ if(wxTheClipboard->GetData(wxldo))
+ {
+ wxTheClipboard->Close();
+ wxString str = wxldo.GetLayoutData();
+ m_llist->Read(str);
+ SetDirty();
+ RequestUpdate();
+ return;
+ }
+ }
+ }
+ wxTextDataObject data;
+ if (wxTheClipboard->IsSupported( data.GetFormat() )
+ && wxTheClipboard->GetData(data) )
+ {
+ wxTheClipboard->Close();
+ wxString text = data.GetText();
+ wxLayoutImportText( m_llist, text);
SetDirty();
+ RequestUpdate();
+ return;
}
- else
-#endif
+ }
+ // if everything failed we can still try the primary:
+ wxTheClipboard->Close();
+ if(! primary) // not tried before
+ {
+ wxTheClipboard->UsePrimarySelection();
+ if (wxTheClipboard->Open())
{
wxTextDataObject data;
if (wxTheClipboard->IsSupported( data.GetFormat() )
wxString text = data.GetText();
wxLayoutImportText( m_llist, text);
SetDirty();
+ RequestUpdate();
}
+ wxTheClipboard->Close();
}
- wxTheClipboard->Close();
}
}
bool
-wxLayoutWindow::Copy(bool invalidate)
+wxLayoutWindow::Copy(bool invalidate, bool privateFormat, bool primary)
{
// Calling GetSelection() will automatically do an EndSelection()
// on the list, but we need to take a note of it, too:
m_llist->EndSelection();
}
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
- // the data object which holds all different data objects, one for each
- // format we support
- wxDataObjectComposite *data = new wxDataObjectComposite;
-#endif
-
wxLayoutDataObject *wldo = new wxLayoutDataObject;
wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate);
if(! llist)
- {
- delete wldo;
- delete data;
return FALSE;
- }
// Export selection as text:
wxString text;
wxLayoutExportObject *exp;
}
delete llist;
- bool rc;
// The exporter always appends a newline, so we chop it off if it
// is there:
{
text = text.Mid(0,len-1);
}
- if (wxTheClipboard->Open())
+#if 0
+if(! primary) // always copy as text-only to primary selection
{
-#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
- data->Add(wldo, TRUE /* preferred */);
- data->Add(new wxTextDataObject(text));
+ wxTheClipboard->UsePrimarySelection();
+ if (wxTheClipboard->Open())
+ {
+ wxTextDataObject *data = new wxTextDataObject( text );
+ wxTheClipboard->SetData( data );
+ wxTheClipboard->Close();
+ }
+ }
#endif
- rc = wxTheClipboard->SetData( data );
+
+ wxTheClipboard->UsePrimarySelection(primary);
+ if (wxTheClipboard->Open())
+ {
+ wxTextDataObject *data = new wxTextDataObject( text );
+ bool rc;
+
+ rc = wxTheClipboard->SetData( data );
+ if(privateFormat)
+ rc |= wxTheClipboard->SetData( wldo );
wxTheClipboard->Close();
+ return rc;
}
else
- rc = FALSE;
-
- delete wldo;
- delete data;
- return rc;
+ delete wldo;
+
+ return FALSE;
}
bool
-wxLayoutWindow::Cut(void)
+wxLayoutWindow::Cut(bool privateFormat, bool usePrimary)
{
- if(Copy(false)) // do not invalidate selection after copy
+ if(Copy(false, privateFormat, usePrimary)) // do not invalidate selection after copy
{
m_llist->DeleteSelection();
SetDirty();