line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::ebug::Wx::View::PackageBrowser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1612
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw(Wx::Panel Devel::ebug::Wx::View::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
755
|
|
5
|
|
|
|
|
|
|
use Devel::ebug::Wx::Plugin qw(:plugin); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(tree) ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Wx qw(:treectrl :sizer); |
10
|
|
|
|
|
|
|
use Wx::Event qw(EVT_TREE_ITEM_ACTIVATED EVT_BUTTON); |
11
|
|
|
|
|
|
|
use Wx::Perl::TreeView; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub tag { 'package_browser' } |
14
|
|
|
|
|
|
|
sub description { 'Package Browser' } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new : View { |
17
|
|
|
|
|
|
|
my( $class, $parent, $wxebug, $layout_state ) = @_; |
18
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1 ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$self->wxebug( $wxebug ); |
21
|
|
|
|
|
|
|
my $tree = Wx::TreeCtrl->new( $self, -1, [-1,-1], [-1,-1], |
22
|
|
|
|
|
|
|
wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS ); |
23
|
|
|
|
|
|
|
my $model = Devel::ebug::Wx::View::PackageBrowser::Model |
24
|
|
|
|
|
|
|
->new( { ebug => $self->ebug } ); |
25
|
|
|
|
|
|
|
$self->{tree} = Wx::Perl::TreeView->new( $tree, $model ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $refresh = Wx::Button->new( $self, -1, 'Refresh' ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $sz = Wx::BoxSizer->new( wxVERTICAL ); |
30
|
|
|
|
|
|
|
my $cntrl = Wx::BoxSizer->new( wxHORIZONTAL ); |
31
|
|
|
|
|
|
|
$cntrl->Add( $refresh, 0, 0 ); |
32
|
|
|
|
|
|
|
$sz->Add( $cntrl, 0, wxGROW ); |
33
|
|
|
|
|
|
|
$sz->Add( $self->tree->treectrl, 1, wxGROW ); |
34
|
|
|
|
|
|
|
$self->SetSizer( $sz ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->register_view; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
EVT_TREE_ITEM_ACTIVATED( $self, $tree, sub { $self->_show_sub( $_[1] ) } ); |
39
|
|
|
|
|
|
|
EVT_BUTTON( $self, $refresh, sub { $self->_refresh } ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$self->SetSize( $self->default_size ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->add_subscription( $self->ebug, 'load_program', $self, '_refresh' ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _refresh { |
49
|
|
|
|
|
|
|
my( $self ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->tree->model->flush_cache; |
52
|
|
|
|
|
|
|
$self->tree->reload; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _show_sub { |
56
|
|
|
|
|
|
|
my( $self, $event ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if( $self->tree->ItemHasChildren( $event->GetItem ) ) { |
59
|
|
|
|
|
|
|
$event->Skip; |
60
|
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $cookie = $self->tree->get_cookie( $event->GetItem ); |
64
|
|
|
|
|
|
|
$cookie =~ s/^&:://; |
65
|
|
|
|
|
|
|
my( $filename, $start, $end ) = $self->ebug->subroutine_info( $cookie ); |
66
|
|
|
|
|
|
|
return unless $filename && $start; |
67
|
|
|
|
|
|
|
$self->wxebug->code_display_service |
68
|
|
|
|
|
|
|
->highlight_line( $filename, $start ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package Devel::ebug::Wx::View::PackageBrowser::Model; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use strict; |
74
|
|
|
|
|
|
|
use base qw(Wx::Perl::TreeView::Model Class::Accessor::Fast); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors( qw(ebug _last_cookie _last_answer) ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub get_root { return ( '::main', '' ) } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub flush_cache { |
81
|
|
|
|
|
|
|
my( $self ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$self->{_last_cookie} = $self->{_last_answer} = undef; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _get_answer { |
87
|
|
|
|
|
|
|
my( $self, $cookie ) = @_; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return $self->_last_answer |
90
|
|
|
|
|
|
|
if $self->_last_cookie && $self->_last_cookie eq $cookie; |
91
|
|
|
|
|
|
|
return [] unless $self->ebug->can( 'package_list' ); |
92
|
|
|
|
|
|
|
$self->{_last_cookie} = $cookie; |
93
|
|
|
|
|
|
|
my @packages = $self->ebug->package_list( $cookie ); |
94
|
|
|
|
|
|
|
my @subroutines = map "&$_", $self->ebug->symbol_list( $cookie, [ '&' ] ); |
95
|
|
|
|
|
|
|
return $self->{_last_answer} = [ @packages, @subroutines ]; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub get_child_count { |
99
|
|
|
|
|
|
|
my( $self, $cookie ) = @_; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $data = $self->_get_answer( $cookie ); |
102
|
|
|
|
|
|
|
return @$data; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_child { |
106
|
|
|
|
|
|
|
my( $self, $cookie, $index ) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $data = $self->_get_answer( $cookie ); |
109
|
|
|
|
|
|
|
my $item = $data->[$index]; |
110
|
|
|
|
|
|
|
if( substr( $item, 0, 1 ) eq ':' ) { |
111
|
|
|
|
|
|
|
return ( $item, substr( $item, length( $cookie ) + 2 ) ); |
112
|
|
|
|
|
|
|
} else { |
113
|
|
|
|
|
|
|
return ( $item, '&' . substr( $item, length( $cookie ) + 3 ) ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub has_children { |
118
|
|
|
|
|
|
|
my( $self, $cookie ) = @_; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return substr( $cookie, 0, 1 ) eq ':'; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |