line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::REPL::Plugin::Clipboard; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: #clip output to clipboard |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2679
|
use Devel::REPL::Plugin; |
|
1
|
|
|
|
|
531803
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
7074
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1319
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
2602
|
use Clipboard; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
8237
|
use Term::ANSIColor 2.01 qw(colorstrip); |
|
1
|
|
|
|
|
9180
|
|
|
1
|
|
|
|
|
1025
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub BEFORE_PLUGIN { |
12
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
13
|
0
|
|
|
|
|
|
$self->load_plugin('Turtles'); |
14
|
0
|
|
|
|
|
|
return; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has last_output => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
default => '', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
around 'format_result' => sub { |
25
|
|
|
|
|
|
|
my $orig = shift; |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my @ret; |
29
|
|
|
|
|
|
|
if (wantarray) { |
30
|
|
|
|
|
|
|
@ret = $self->$orig(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
|
|
|
|
|
|
$ret[0] = $self->$orig(@_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Remove any color control characters that plugins like |
37
|
|
|
|
|
|
|
# Data::Printer may have added |
38
|
|
|
|
|
|
|
my $output = colorstrip( join( "\n", map { $_ // '' } @ret ) ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->last_output($output); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return wantarray ? @ret : $ret[0]; |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub command_clip { |
46
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
47
|
0
|
|
|
|
|
|
Clipboard->copy( $self->last_output ); |
48
|
0
|
|
|
|
|
|
return 'Output copied to clipboard'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Devel::REPL::Plugin::Clipboard - #clip output to clipboard |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.004 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COMMANDS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This module provides the following command to your Devel::REPL shell: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 #clip |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The C<#clip> puts the output of the last command on your clipboard. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Steve Nolte <mcsnolte@cpan.org> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Steve Nolte. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
82
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |