| 1 | package Clipboard; | ||||||||||||||||||||||||||||
| 2 | 2 | $Clipboard::VERSION = '0.32'; | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $driver; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | sub copy { my $self = shift; return $driver->copy(@_); } | ||||||||||||||||||||||||||
|
Subroutine
copy: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub copy_to_all_selections { | ||||||||||||||||||||||||||
|
Subroutine
copy_to_all_selections: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | 0 | my $meth = $driver->can('copy_to_all_selections'); | |||||||||||||||||||||||||||
| 12 | 0 | ▶ | return $meth ? $meth->($driver, @_) : $driver->copy(@_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub cut { goto © } | ||||||||||||||||||||||||||
|
Subroutine
cut: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | sub paste { my $self = shift; return $driver->paste(@_); } | ||||||||||||||||||||||||||
|
Subroutine
paste: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 39 | ▶ | sub bind_os { my $driver = shift; return map { $_ => $driver } @_; } | ||||||||||||||||||||||||||
|
Subroutine
bind_os: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 13 | ▶ | sub find_driver { | ||||||||||||||||||||||||||
|
Subroutine
find_driver: called CC=13 SCAR=37.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 13 | my $os = shift; | |||||||||||||||||||||||||||
| 22 | 13 | my %drivers = ( | |||||||||||||||||||||||||||
| 23 | # list stolen from Module::Build, with some modifications (for | ||||||||||||||||||||||||||||
| 24 | # example, cygwin doesn't count as Unix here, because it will | ||||||||||||||||||||||||||||
| 25 | # use the Win32 clipboard.) | ||||||||||||||||||||||||||||
| 26 | bind_os(Xsel => qw(linux bsd$ aix bsdos dec_osf dgux | ||||||||||||||||||||||||||||
| 27 | dynixptx gnu hpux irix dragonfly machten next os2 sco_sv solaris | ||||||||||||||||||||||||||||
| 28 | sunos svr4 svr5 unicos unicosmk)), | ||||||||||||||||||||||||||||
| 29 | bind_os(Xclip => qw(linux bsd$ aix bsdos dec_osf dgux | ||||||||||||||||||||||||||||
| 30 | dynixptx gnu hpux irix dragonfly machten next os2 sco_sv solaris | ||||||||||||||||||||||||||||
| 31 | sunos svr4 svr5 unicos unicosmk)), | ||||||||||||||||||||||||||||
| 32 | #bind_os(WaylandClipboard => qw(linux)), # Do not uncomment this line... | ||||||||||||||||||||||||||||
| 33 | bind_os(MacPasteboard => qw(darwin)), | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 13 | ▶ | if ($os =~ /^(?:mswin|win|cygwin)/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | # If we are connected to windows through ssh, and xclip is | ||||||||||||||||||||||||||||
| 38 | # available, use it. | ||||||||||||||||||||||||||||
| 39 | 2 | ▶ | if (exists $ENV{SSH_CONNECTION}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 41 | 0 | require Clipboard::Xsel; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | return 'Xsel' if Clipboard::Xsel::xsel_available(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | require Clipboard::Xclip; | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | return 'Xclip' if Clipboard::Xclip::xclip_available(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 2 | return 'Win32'; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | # Preferentially use Clipboard::WaylandClipboard if we see WAYLAND_DISPLAY | ||||||||||||||||||||||||||||
| 50 | 11 | ▶ | if (exists($ENV{WAYLAND_DISPLAY}) && length($ENV{WAYLAND_DISPLAY})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $ENV{"WAYLAND_DISPLAY"} and length $ENV{"WAYLAND_DISPLAY"}
MC/DC0%0/2
exists $ENV{"WAYLAND_DISPLAY"} and length $ENV{"WAYLAND_DISPLAY"}
exists $ENV{"WAYLAND_DISPLAY"}
length $ENV{"WAYLAND_DISPLAY"}
Truth table33%1/3
A and B
A= exists $ENV{"WAYLAND_DISPLAY"}B= length $ENV{"WAYLAND_DISPLAY"}
| |||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||
| 52 | 0 | require Clipboard::WaylandClipboard; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return 'WaylandClipboard' if Clipboard::WaylandClipboard::available(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 11 | foreach my $d (sort keys %drivers) | |||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | 99 | ▶ | if ($os =~ /$d/i) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||
| 59 | 10 | return $drivers{$d}; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | # use xsel/xclip on unknown OSes that seem to have a DISPLAY | ||||||||||||||||||||||||||||
| 63 | 1 | ▶ | if (exists($ENV{DISPLAY})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||
| 65 | 0 | require Clipboard::Xsel; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | return 'Xsel' if Clipboard::Xsel::xsel_available(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | require Clipboard::Xclip; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | return 'Xclip' if Clipboard::Xclip::xclip_available(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | die "The $os system is not yet supported by Clipboard.pm. Please email rking\@panoptic.com and tell him about this.\n"; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 75 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | 3 | my $drv = Clipboard->find_driver($^O); | |||||||||||||||||||||||||||
| 77 | 3 | require "Clipboard/$drv.pm"; | |||||||||||||||||||||||||||
| 78 | 3 | $driver = "Clipboard::$drv"; | |||||||||||||||||||||||||||
| 79 | 3 | return; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | 1; | |||||||||||||||||||||||||||
| 83 | # vi:tw=72 | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||