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 |
sf-exg |
1.9 |
macosx-clipboard - Mac OS X clipboard support |
29 |
|
|
|
30 |
|
|
=head1 SYNOPSIS |
31 |
|
|
|
32 |
|
|
urxvt -pe macosx-clipboard |
33 |
root |
1.6 |
|
34 |
root |
1.7 |
=head1 DESCRIPTION |
35 |
root |
1.6 |
|
36 |
sf-exg |
1.9 |
This extension implements commands to interact with the Mac OS X |
37 |
|
|
clipboard and requires the C<Mac::Pasteboard> module. It is used like |
38 |
|
|
this: |
39 |
root |
1.6 |
|
40 |
|
|
URxvt.keysym.M-c: perl:macosx-clipboard:copy |
41 |
|
|
URxvt.keysym.M-v: perl:macosx-clipboard:paste |
42 |
|
|
|
43 |
|
|
=cut |
44 |
root |
1.1 |
|
45 |
root |
1.3 |
use Mac::Pasteboard; |
46 |
ayin |
1.2 |
|
47 |
root |
1.3 |
my $pasteboard = new Mac::Pasteboard; |
48 |
ayin |
1.2 |
|
49 |
root |
1.1 |
sub copy { |
50 |
|
|
my ($self) = @_; |
51 |
|
|
|
52 |
root |
1.3 |
$pasteboard->clear; |
53 |
|
|
$pasteboard->copy ($self->selection); |
54 |
|
|
|
55 |
root |
1.1 |
() |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
sub paste { |
59 |
|
|
my ($self) = @_; |
60 |
|
|
|
61 |
root |
1.3 |
my $str = $pasteboard->paste; |
62 |
|
|
utf8::decode $str; |
63 |
|
|
$self->tt_write ($self->locale_encode ($str)); |
64 |
|
|
|
65 |
root |
1.1 |
() |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
sub on_user_command { |
69 |
|
|
my ($self, $cmd) = @_; |
70 |
|
|
|
71 |
|
|
if ($cmd eq "macosx-clipboard:copy") { |
72 |
|
|
$self->copy; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
if ($cmd eq "macosx-clipboard:paste") { |
76 |
|
|
$self->paste; |
77 |
|
|
} |
78 |
root |
1.3 |
|
79 |
root |
1.1 |
() |
80 |
|
|
} |
81 |
|
|
|