| 1 | Index: Editor.pm |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- Editor.pm (revision 9154) |
|---|
| 4 | +++ Editor.pm (working copy) |
|---|
| 5 | @@ -742,8 +742,9 @@ |
|---|
| 6 | |
|---|
| 7 | sub on_smart_highlight_begin { |
|---|
| 8 | my ( $self, $event ) = @_; |
|---|
| 9 | - |
|---|
| 10 | my $selection = $self->GetSelectedText; |
|---|
| 11 | + |
|---|
| 12 | + $self->put_text_to_clipboard($selection, 1); |
|---|
| 13 | my $selection_length = length $selection; |
|---|
| 14 | return if $selection_length == 0; |
|---|
| 15 | |
|---|
| 16 | @@ -783,7 +784,7 @@ |
|---|
| 17 | $self->SetStyling( $style->{len}, 32 ); |
|---|
| 18 | } |
|---|
| 19 | } |
|---|
| 20 | - |
|---|
| 21 | + |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | sub on_smart_highlight_end { |
|---|
| 25 | @@ -799,11 +800,10 @@ |
|---|
| 26 | my $text = $self->GetSelectedText; |
|---|
| 27 | if ( Padre::Constant::WXGTK and defined $text and $text ne '' ) { |
|---|
| 28 | |
|---|
| 29 | - # Only on X11 based platforms |
|---|
| 30 | - # Wx::wxTheClipboard->UsePrimarySelection(1); |
|---|
| 31 | - $self->put_text_to_clipboard($text); |
|---|
| 32 | + |
|---|
| 33 | + $self->put_text_to_clipboard($text,1); |
|---|
| 34 | |
|---|
| 35 | - # Wx::wxTheClipboard->UsePrimarySelection(0); |
|---|
| 36 | + |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | my $doc = $self->{Document}; |
|---|
| 40 | @@ -821,18 +821,20 @@ |
|---|
| 41 | # TODO: Sometimes there are unexpected effects when using the middle button. |
|---|
| 42 | # It seems that another event is doing something but not within this module. |
|---|
| 43 | # Please look at ticket #390 for details! |
|---|
| 44 | - |
|---|
| 45 | - Padre::Current->editor->Paste; |
|---|
| 46 | - |
|---|
| 47 | + Wx::wxTheClipboard->UsePrimarySelection(1); |
|---|
| 48 | + if (Padre::Constant::WIN32) |
|---|
| 49 | + { |
|---|
| 50 | + Padre::Current->editor->Paste; |
|---|
| 51 | + } |
|---|
| 52 | + |
|---|
| 53 | my $doc = $self->{Document}; |
|---|
| 54 | if ( $doc->can('event_on_middle_up') ) { |
|---|
| 55 | $doc->event_on_middle_up( $self, $event ); |
|---|
| 56 | } |
|---|
| 57 | - |
|---|
| 58 | + Wx::wxTheClipboard->UsePrimarySelection(0); |
|---|
| 59 | $event->Skip; |
|---|
| 60 | return; |
|---|
| 61 | } |
|---|
| 62 | - |
|---|
| 63 | sub on_right_down { |
|---|
| 64 | my $self = shift; |
|---|
| 65 | my $event = shift; |
|---|
| 66 | @@ -1125,10 +1127,9 @@ |
|---|
| 67 | |
|---|
| 68 | sub Paste { |
|---|
| 69 | my $self = shift; |
|---|
| 70 | - |
|---|
| 71 | - # Workaround for Copy/Paste bug ticket #390 |
|---|
| 72 | + |
|---|
| 73 | my $text = $self->get_text_from_clipboard; |
|---|
| 74 | - |
|---|
| 75 | + |
|---|
| 76 | if ($text) { |
|---|
| 77 | |
|---|
| 78 | # Conversion of pasted text is really needed since it usually comes |
|---|
| 79 | @@ -1191,28 +1192,41 @@ |
|---|
| 80 | return $paste; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | +# put_text_to_clipboard |
|---|
| 84 | +# $self->put_text_to_clipboard($text, $clipboard_Number ) |
|---|
| 85 | +# where X11 based display systems |
|---|
| 86 | +# clipboard number is either the GTK clipboard or the X11 |
|---|
| 87 | +# clipboard. Clipboard 1 is used for normal X11 copy onselect and |
|---|
| 88 | +# paste on middle button. Has no affect on windows. |
|---|
| 89 | +# Puts Text on the clipboard |
|---|
| 90 | + |
|---|
| 91 | sub put_text_to_clipboard { |
|---|
| 92 | - my ( $self, $text ) = @_; |
|---|
| 93 | + my ( $self, $text , $clipboard) = @_; |
|---|
| 94 | @_ = (); # Feeble attempt to kill Scalars Leaked |
|---|
| 95 | - |
|---|
| 96 | - return if $text eq ''; |
|---|
| 97 | - |
|---|
| 98 | + |
|---|
| 99 | + |
|---|
| 100 | + if (!defined($clipboard)){ |
|---|
| 101 | + $clipboard = 0 ; |
|---|
| 102 | + } |
|---|
| 103 | + |
|---|
| 104 | + if ($text eq ''){return;} |
|---|
| 105 | # Backup last clipboard value: |
|---|
| 106 | $self->{Clipboard_Old} = $self->get_text_from_clipboard; |
|---|
| 107 | - |
|---|
| 108 | - # if $self->{Clipboard_Old} ne $self->get_text_from_clipboard; |
|---|
| 109 | - |
|---|
| 110 | + |
|---|
| 111 | + |
|---|
| 112 | + |
|---|
| 113 | Wx::wxTheClipboard->Open; |
|---|
| 114 | + Wx::wxTheClipboard->UsePrimarySelection($clipboard); |
|---|
| 115 | Wx::wxTheClipboard->SetData( Wx::TextDataObject->new($text) ); |
|---|
| 116 | Wx::wxTheClipboard->Close; |
|---|
| 117 | - |
|---|
| 118 | + |
|---|
| 119 | return; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | sub get_text_from_clipboard { |
|---|
| 123 | |
|---|
| 124 | my $self = shift; |
|---|
| 125 | - |
|---|
| 126 | + |
|---|
| 127 | my $text = ''; |
|---|
| 128 | Wx::wxTheClipboard->Open; |
|---|
| 129 | if ( Wx::wxTheClipboard->IsSupported(Wx::wxDF_TEXT) ) { |
|---|