Re: how do I place text into clipboard on Linux?
by tlm (Prior) on May 02, 2005 at 00:02 UTC
|
use Tk;
my $selection = MainWindow->new->SelectionGet;
print $selection, $/;
| [reply] [d/l] |
|
|
This probably not exatly what I want
by "Perl to help me with clipboard" I meant that I copied something into clipboard elsewhere (not in my application), then run my one-liner and have in my clipboard something else.
Say, I start Mozilla, make a selection, and then in menu item "Edit->Copy" place a selection into clipboard.
Can I write a one-liner to, say, upcase contents of clipboard, when I paste it elsewhere, I will see upcased content of selection in that Mozilla, which could be un-selected to the moment already?
Also, it must work without X11 also.
In win32 I do this as:
perl -MWin32::Clipboard -we "$clip=Win32::Clipboard;$clip->Set(uc($clip->Get())"
my last example is lenghty, but I have wrappers so my actual one-liner is much shorter.
| [reply] [d/l] |
|
|
| [reply] |
|
|
use Tk::Clipboard;
my $mw = MainWindow->new();
... ## after having what you want to copy...
$mw->clipboardClear; ## prepare the clipboard (ne
+w entry)
$mw->clipboardAppend($selected_list); ## copy it (see perldoc)
Please, read the perldoc for more types of data that could be added to the clipboard.
It defaults to strings.
If you don't use clipboardClear before the second or successive copies, it concatenates what you copy...
| [reply] [d/l] |
Re: how do I place text into clipboard on Linux?
by starbolin (Hermit) on May 02, 2005 at 00:52 UTC
|
A quick search of CPAN shows
Tk::clipboard
and
Clipboard
Have you looked at these?
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] |
|
|
| [reply] |
Re: how do I place text into clipboard on Linux?
by zentara (Cardinal) on May 02, 2005 at 11:22 UTC
|
Also, it must work without X11.I'm not sure that can be done in a "universal manner". Think about how the clipboard works...it needs X11. In a console, for instance, I use "midnight commander's clipboard", which saves it's content to a file in ~/.mc. In X you have the "mouse clipboard" and the "X clipboard" and sometimes the internal clipboards of each application. In Windows, the consoles and the Window's are tightly integrated, but in linux, they are totally separate.
I would go to freshmeat and search for "clipboard", then see how they do it.
I'm not really a human, but I play one on earth.
flash japh
| [reply] |
|
|
thanks, that helps.
Also, it probably reasonable using some "xclip" application, which I am not aware of...
Also, "gvim" behaves reasonably, may be searching there also will help.
| [reply] |
Re: how do I place text into clipboard on Linux?
by Cody Pendant (Prior) on May 02, 2005 at 11:34 UTC
|
Doesn't Linux have pbcopy?
($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print
| [reply] |
|
|
| [reply] |
Re: how do I place text into clipboard on Linux?
by starbolin (Hermit) on May 02, 2005 at 17:06 UTC
|
The most universal solution is the utility xcb which has been ported to many unices.
I found ports for Linux, Debian, SUSE, FreeBSD, AIX and HPUX. Unfortunately it is not completely universal ( for instance, Mac OS uses pbcut/pbpaste ) nor is it perl but it does seem to be the easiest way to get from A to B.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] |