Hi everyone,
I already send a mail here about my copy/paste that doesn't work between
Chromium and Pharo3/4.
Since I use more and more Pharo and I don't want to move from Chromium,
I tried to find a solution to my problem and so I did.
Ok, I must admit, it's brutal but I managed to get the content from the
clipboard (after copying something from chromium) using 'xclip -o' with
PipeableOSProcess help.
So I looked at
Clipboard>>clipboardText
| string decodedString |
string := self primitiveClipboardText.
(string isEmpty
or: [string = contents asString])
ifTrue: [^ contents].
decodedString := string convertFromWithConverter: UTF8TextConverter new.
decodedString := decodedString replaceAll: 10 asCharacter with: 13
asCharacter.
^ decodedString = contents asString
ifTrue: [contents]
ifFalse: [decodedString asText].
and overrided it in UnixClipboard>>clipboardText as follow:
UnixClipboard>>clipboardText
| string decodedString |
string := (PipeableOSProcess command: '/usr/bin/xclip -o') output.
decodedString := string convertFromWithConverter: UTF8TextConverter new.
decodedString := decodedString replaceAll: 10 asCharacter with: 13
asCharacter.
^ decodedString = contents asString
ifTrue: [contents]
ifFalse: [decodedString asText].
This trick works pretty well for me even if I'm sure it's not the best
way to do it.
I saw that it's possible to get the content of x11 clipboard in C using
x11 libs but I think it would be a waste of time to implement it and
then call C code from Pharo since I think the way I did it is fast
enough. So that's why I choose this quick solution.
Anyway, I send this mail to inform that I made with this called
XClipboard, simply load it with:
Gofer new
url: 'http://smalltalkhub.com/mc/JulienDelplanque/XClipboard/main';
package: #ConfigurationOfXClipboard;
load.
ConfigurationOfXClipboard loadDevelopment.
if you want to look at it.
What do you think about it? Is there a better way to do that easily?
Does anyone see a problem with this "quick fix"?
As I said for me it works well for the moment but I can't be certain it
will in any case.
Thanks in advance,
Julien