ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/macosx-clipboard-native
(Generate patch)

Comparing rxvt-unicode/src/perl/macosx-clipboard-native (file contents):
Revision 1.2 by sf-exg, Sun Nov 20 11:09:22 2011 UTC vs.
Revision 1.3 by sf-exg, Tue Nov 22 17:04:28 2011 UTC

1#! perl -w 1#! perl -w
2
3# http://triplefusion.net/system/macosx-clipboard
4 2
5# ---------------------------------------------------------------------- 3# ----------------------------------------------------------------------
6# File: macosx-clipboard-native 4# File: macosx-clipboard-native
7# ---------------------------------------------------------------------- 5# ----------------------------------------------------------------------
8# 6#
28 26
29# URxvt.perl-ext-common: macosx-clipboard 27# URxvt.perl-ext-common: macosx-clipboard
30# URxvt.keysym.M-c: perl:macosx-clipboard:copy 28# URxvt.keysym.M-c: perl:macosx-clipboard:copy
31# URxvt.keysym.M-v: perl:macosx-clipboard:paste 29# URxvt.keysym.M-v: perl:macosx-clipboard:paste
32 30
33use Fcntl ();
34use Foundation; 31use Foundation;
35 32
36our $appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework'); 33my $appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework');
37$appkit->load if $appkit; 34$appkit->load if $appkit;
38 35
39if ($appkit->isLoaded) { 36if ($appkit->isLoaded) {
40 no strict 'refs'; 37 no strict 'refs';
41 for my $class (qw(NSPasteboard)) { 38 for my $class (qw(NSPasteboard)) {
43 } 40 }
44} else { 41} else {
45 undef $appkit; 42 undef $appkit;
46} 43}
47 44
48our $pasteboard = NSPasteboard->generalPasteboard; 45my $pasteboard = NSPasteboard->generalPasteboard;
49 46
50sub copy { 47sub copy {
51 my ($self) = @_; 48 my ($self) = @_;
52 49
53 $pasteboard->declareTypes_owner_(NSArray->arrayWithObject_('NSStringPboardType'), undef); 50 $pasteboard->declareTypes_owner_(NSArray->arrayWithObject_('NSStringPboardType'), undef);
56 () 53 ()
57} 54}
58 55
59sub paste { 56sub paste {
60 my ($self) = @_; 57 my ($self) = @_;
61 my ($type, $str);
62 58
63 $type = $pasteboard->availableTypeFromArray_(NSArray->arrayWithObject_('NSStringPboardType')); 59 my $type = $pasteboard->availableTypeFromArray_(NSArray->arrayWithObject_('NSStringPboardType'));
64 if ($type->isEqual_('NSStringPboardType')){ 60 if ($type->isEqual_('NSStringPboardType')) {
65 $str = $pasteboard->stringForType_($type)->UTF8String; 61 my $str = $pasteboard->stringForType_($type)->UTF8String;
66 $str =~ tr/\n/\r/; 62 $str =~ tr/\n/\r/;
67 utf8::decode($str); 63 utf8::decode($str);
68 $self->tt_write($self->locale_encode($str)); 64 $self->tt_write($self->locale_encode($str));
69 } 65 }
70 66

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines