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.1 by root, Sat May 30 08:47:07 2009 UTC vs.
Revision 1.4 by root, Fri Sep 21 22:55:56 2012 UTC

1#! perl -w 1#! perl -w
2 2
3# http://triplefusion.net/system/macosx-clipboard 3=head1 NAME
4
5macosx-clipboard-native - apple is evil
6
7=head1 SYNOPSIS
8
9 urxvt -pe macosx-clipboard-native
10
11=head1 DESCRIPTION
12
13This extension does something with the clipboard on some Apple OS X
14systems. Apple is a vile company that actively fights free software,
15do not support them by using it! This extension is only included in
16rxvt-unicode because the maintainer was too weak! Do not give in to
17similar feelings! It hasn't even been changed to automatically load when
18resources are used! Plus, it's totally undocumented!
19
20=cut
4 21
5# ---------------------------------------------------------------------- 22# ----------------------------------------------------------------------
6# File: macosx-clipboard-native 23# File: macosx-clipboard-native
7# ---------------------------------------------------------------------- 24# ----------------------------------------------------------------------
8# 25#
9# All portions of code are copyright by their respective author/s. 26# All portions of code are copyright by their respective author/s.
10# Copyright (c) 2006 Samuel Ljungkvist <salj@triplefusion.net> 27# Copyright (c) 2006 Samuel Ljungkvist <salj@triplefusion.net>
11# 28#
12# This program is free software; you can redistribute it and/or modify 29# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by 30# it under the terms of the GNU General Public License as published by
28 45
29# URxvt.perl-ext-common: macosx-clipboard 46# URxvt.perl-ext-common: macosx-clipboard
30# URxvt.keysym.M-c: perl:macosx-clipboard:copy 47# URxvt.keysym.M-c: perl:macosx-clipboard:copy
31# URxvt.keysym.M-v: perl:macosx-clipboard:paste 48# URxvt.keysym.M-v: perl:macosx-clipboard:paste
32 49
33use Fcntl ();
34use Foundation; 50use Foundation;
35 51
36our $appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework'); 52my $appkit = NSBundle->alloc->init->initWithPath_('/System/Library/Frameworks/AppKit.framework');
37$appkit->load if $appkit; 53$appkit->load if $appkit;
38 54
39if ($appkit->isLoaded) { 55if ($appkit->isLoaded) {
40 no strict 'refs'; 56 no strict 'refs';
41 for my $class (qw(NSPasteboard)) { 57 for my $class (qw(NSPasteboard)) {
43 } 59 }
44} else { 60} else {
45 undef $appkit; 61 undef $appkit;
46} 62}
47 63
48our $pasteboard = NSPasteboard->generalPasteboard; 64my $pasteboard = NSPasteboard->generalPasteboard;
49 65
50sub copy { 66sub copy {
51 my ($self) = @_; 67 my ($self) = @_;
52 68
53 $pasteboard->declareTypes_owner_(NSArray->arrayWithObject_('NSStringPboardType'), undef); 69 $pasteboard->declareTypes_owner_(NSArray->arrayWithObject_('NSStringPboardType'), undef);
56 () 72 ()
57} 73}
58 74
59sub paste { 75sub paste {
60 my ($self) = @_; 76 my ($self) = @_;
61 my ($type, $str);
62 77
63 $type = $pasteboard->availableTypeFromArray_(NSArray->arrayWithObject_('NSStringPboardType')); 78 my $type = $pasteboard->availableTypeFromArray_(NSArray->arrayWithObject_('NSStringPboardType'));
64 if ($type->isEqual_('NSStringPboardType')){ 79 if ($type->isEqual_('NSStringPboardType')) {
65 $str = $pasteboard->stringForType_($type)->UTF8String; 80 my $str = $pasteboard->stringForType_($type)->UTF8String;
66 $str =~ tr/\n/\r/; 81 $str =~ tr/\n/\r/;
67 utf8::decode($str); 82 utf8::decode($str);
68 $self->tt_write($self->locale_encode($str)); 83 $self->tt_write($self->locale_encode($str));
69 } 84 }
70 85

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines