1 |
root |
1.1 |
#! perl -w |
2 |
|
|
|
3 |
|
|
# ---------------------------------------------------------------------- |
4 |
|
|
# File: macosx-clipboard |
5 |
|
|
# ---------------------------------------------------------------------- |
6 |
sf-exg |
1.4 |
# |
7 |
root |
1.1 |
# All portions of code are copyright by their respective author/s. |
8 |
|
|
# Copyright (c) 2006 Samuel Ljungkvist <salj@triplefusion.net> |
9 |
root |
1.3 |
# 2009 Reza Jelveh <reza.jelveh@gmail.com> |
10 |
root |
1.1 |
# |
11 |
|
|
# This program is free software; you can redistribute it and/or modify |
12 |
|
|
# it under the terms of the GNU General Public License as published by |
13 |
|
|
# the Free Software Foundation; either version 2 of the License, or |
14 |
|
|
# (at your option) any later version. |
15 |
|
|
# |
16 |
|
|
# This program is distributed in the hope that it will be useful, |
17 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
# GNU General Public License for more details. |
20 |
|
|
# |
21 |
|
|
# You should have received a copy of the GNU General Public License |
22 |
|
|
# along with this program; if not, write to the Free Software |
23 |
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 |
|
|
# ---------------------------------------------------------------------- |
25 |
|
|
|
26 |
root |
1.6 |
=head1 NAME |
27 |
root |
1.1 |
|
28 |
root |
1.6 |
macosx-clipboard and macosx-clipboard-native |
29 |
|
|
|
30 |
root |
1.7 |
=head1 DESCRIPTION |
31 |
root |
1.6 |
|
32 |
|
|
These two modules implement an extended clipboard for Mac OS X. They are |
33 |
|
|
used like this: |
34 |
|
|
|
35 |
|
|
URxvt.perl-ext-common: default,macosx-clipboard |
36 |
|
|
URxvt.keysym.M-c: perl:macosx-clipboard:copy |
37 |
|
|
URxvt.keysym.M-v: perl:macosx-clipboard:paste |
38 |
|
|
|
39 |
|
|
The difference between them is that the native variant requires a |
40 |
|
|
perl from apple's devkit or so, and C<macosx-clipboard> requires the |
41 |
|
|
C<Mac::Pasteboard> module, works with other perls, has fewer bugs, is |
42 |
|
|
simpler etc. etc. |
43 |
|
|
|
44 |
|
|
=cut |
45 |
root |
1.1 |
|
46 |
root |
1.3 |
use Mac::Pasteboard; |
47 |
ayin |
1.2 |
|
48 |
root |
1.3 |
my $pasteboard = new Mac::Pasteboard; |
49 |
ayin |
1.2 |
|
50 |
root |
1.1 |
sub copy { |
51 |
|
|
my ($self) = @_; |
52 |
|
|
|
53 |
root |
1.3 |
$pasteboard->clear; |
54 |
|
|
$pasteboard->copy ($self->selection); |
55 |
|
|
|
56 |
root |
1.1 |
() |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
sub paste { |
60 |
|
|
my ($self) = @_; |
61 |
|
|
|
62 |
root |
1.3 |
my $str = $pasteboard->paste; |
63 |
|
|
utf8::decode $str; |
64 |
|
|
$self->tt_write ($self->locale_encode ($str)); |
65 |
|
|
|
66 |
root |
1.1 |
() |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
sub on_user_command { |
70 |
|
|
my ($self, $cmd) = @_; |
71 |
|
|
|
72 |
|
|
if ($cmd eq "macosx-clipboard:copy") { |
73 |
|
|
$self->copy; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
if ($cmd eq "macosx-clipboard:paste") { |
77 |
|
|
$self->paste; |
78 |
|
|
} |
79 |
root |
1.3 |
|
80 |
root |
1.1 |
() |
81 |
|
|
} |
82 |
|
|
|