line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Padre::Plugin::REPL; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33743
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub BEGIN { |
7
|
1
|
|
|
1
|
|
9
|
$ENV{PERL_RL} = "Stub"; |
8
|
1
|
|
|
|
|
21
|
$INC{'Term/ReadLine/Stub.pm'} = '/usr/share/perl/5.10/Term/ReadLine.pm'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use base 'Padre::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1051
|
|
12
|
1
|
|
|
1
|
|
488
|
use Padre::Wx; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Padre::Util qw/_T/; |
14
|
|
|
|
|
|
|
use Devel::REPL; |
15
|
|
|
|
|
|
|
use Capture::Tiny qw/capture_merged/; |
16
|
|
|
|
|
|
|
use Devel::REPL::Script; |
17
|
|
|
|
|
|
|
use Class::Unload; |
18
|
|
|
|
|
|
|
use Padre::Plugin::REPL::Panel; |
19
|
|
|
|
|
|
|
use Padre::Plugin::REPL::History; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $repl; |
24
|
|
|
|
|
|
|
our ( $input, $output ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub make_panel { |
27
|
|
|
|
|
|
|
( $input, $output ) = Padre::Plugin::REPL::Panel->new(); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub padre_interfaces { |
31
|
|
|
|
|
|
|
return 'Padre::Plugin' => '0.26'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub menu_plugins_simple_DISABLED { |
35
|
|
|
|
|
|
|
return "REPL" => [ |
36
|
|
|
|
|
|
|
( ('Evaluate something') . "\tCtrl+e" ) => \&dialog, ### _T |
37
|
|
|
|
|
|
|
]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub plugin_enable { |
41
|
|
|
|
|
|
|
_init_repl(); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub plugin_disable { |
45
|
|
|
|
|
|
|
Class::Unload->unload('Padre::Plugin::REPL::History'); |
46
|
|
|
|
|
|
|
Class::Unload->unload('Padre::Plugin::REPL::Panel'); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub dialog { |
50
|
|
|
|
|
|
|
my $code = Wx::GetTextFromUser("What do you want to evaluate?"); |
51
|
|
|
|
|
|
|
my $res = _eval_repl($code); |
52
|
|
|
|
|
|
|
Padre::Current->main->output->AppendText("# $code\n$res\n"); |
53
|
|
|
|
|
|
|
Padre::Current->main->show_output(1); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_text { |
57
|
|
|
|
|
|
|
$input->SetValue(shift); |
58
|
|
|
|
|
|
|
$input->SetInsertionPointEnd(); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_text { |
62
|
|
|
|
|
|
|
$input->GetValue(); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub evaluate { |
66
|
|
|
|
|
|
|
my $code = $input->GetValue(); |
67
|
|
|
|
|
|
|
my $res = _eval_repl($code); |
68
|
|
|
|
|
|
|
Padre::Plugin::REPL::History::evalled(); |
69
|
|
|
|
|
|
|
$output->AppendText("# $code\n$res\n"); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _init_repl { |
73
|
|
|
|
|
|
|
return if ( defined($repl) ); |
74
|
|
|
|
|
|
|
make_panel(); |
75
|
|
|
|
|
|
|
my $temp = Devel::REPL::Script->new(); |
76
|
|
|
|
|
|
|
$repl = $temp->_repl(); |
77
|
|
|
|
|
|
|
$temp->load_profile( $temp->profile ); |
78
|
|
|
|
|
|
|
$temp->load_rcfile( $temp->rcfile ); |
79
|
|
|
|
|
|
|
$repl->out_fh( \*STDOUT ); |
80
|
|
|
|
|
|
|
Padre::Plugin::REPL::History::init(); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _eval_repl { |
84
|
|
|
|
|
|
|
my $code = shift; |
85
|
|
|
|
|
|
|
my $res = capture_merged { |
86
|
|
|
|
|
|
|
$repl->print( $repl->formatted_eval($code) ); |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
return $res; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Padre::Plugin::REPL - read-evaluate-print plugin for Padre |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This plugin will ask you for some code, evaluate it, and show you its output and what it returned. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Since this uses L<Devel::REPL>, most of its plugins can be used in the same way as usual. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Ryan Niebur, C<< <ryanryan52 at gmail.com> >> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Copyright 2009 Ryan Niebur, all rights reserved. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
110
|
|
|
|
|
|
|
under the same terms as Perl itself. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |