ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/macosx-clipboard
Revision: 1.5
Committed: Tue Nov 22 17:04:28 2011 UTC (12 years, 6 months ago) by sf-exg
Branch: MAIN
CVS Tags: rel-9_14, rxvt-unicode-rel-9_15
Changes since 1.4: +0 -1 lines
Log Message:
Cleanups.

File Contents

# User Rev Content
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     # Usage:
27    
28     # URxvt.perl-ext-common: macosx-clipboard
29     # URxvt.keysym.M-c: perl:macosx-clipboard:copy
30     # URxvt.keysym.M-v: perl:macosx-clipboard:paste
31    
32 root 1.3 use Mac::Pasteboard;
33 ayin 1.2
34 root 1.3 my $pasteboard = new Mac::Pasteboard;
35 ayin 1.2
36 root 1.1 sub copy {
37     my ($self) = @_;
38    
39 root 1.3 $pasteboard->clear;
40     $pasteboard->copy ($self->selection);
41    
42 root 1.1 ()
43     }
44    
45     sub paste {
46     my ($self) = @_;
47    
48 root 1.3 my $str = $pasteboard->paste;
49     utf8::decode $str;
50     $self->tt_write ($self->locale_encode ($str));
51    
52 root 1.1 ()
53     }
54    
55     sub on_user_command {
56     my ($self, $cmd) = @_;
57    
58     if ($cmd eq "macosx-clipboard:copy") {
59     $self->copy;
60     }
61    
62     if ($cmd eq "macosx-clipboard:paste") {
63     $self->paste;
64     }
65 root 1.3
66 root 1.1 ()
67     }
68