line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
|
|
|
# Copyright (C) 2011-2015 Rocky Bernstein <rocky@cpan.org> |
3
|
12
|
|
|
12
|
|
106
|
use warnings; no warnings 'redefine'; no warnings 'once'; |
|
12
|
|
|
12
|
|
39
|
|
|
12
|
|
|
12
|
|
532
|
|
|
12
|
|
|
2
|
|
83
|
|
|
12
|
|
|
2
|
|
30
|
|
|
12
|
|
|
2
|
|
455
|
|
|
12
|
|
|
|
|
76
|
|
|
12
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
365
|
|
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
88
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
100
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
92
|
|
4
|
12
|
|
|
12
|
|
80
|
use rlib '../../../../..'; |
|
12
|
|
|
2
|
|
35
|
|
|
12
|
|
|
|
|
91
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
16
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Set::Highlight; |
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
5778
|
use Devel::Trepan::CmdProcessor::Command::Subcmd::Core; |
|
12
|
|
|
2
|
|
37
|
|
|
12
|
|
|
|
|
288
|
|
|
2
|
|
|
|
|
1133
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
71
|
|
9
|
12
|
|
|
12
|
|
67
|
use Devel::Trepan::DB::LineCache; |
|
12
|
|
|
2
|
|
32
|
|
|
12
|
|
|
|
|
2974
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
558
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Devel::Trepan::CmdProcessor::Command::Subcmd); |
12
|
|
|
|
|
|
|
# Values inherited from parent |
13
|
12
|
|
|
12
|
|
85
|
use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS; |
|
12
|
|
|
2
|
|
30
|
|
|
12
|
|
|
|
|
7562
|
|
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1579
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $SHORT_HELP = 'Set whether we use terminal highlighting'; |
16
|
|
|
|
|
|
|
our $MIN_ABBREV = length('hi'); |
17
|
|
|
|
|
|
|
=pod |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 Synopsis: |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
our $HELP = <<'HELP'; |
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
B<set highlight> [reset | plain | light | dark | off] |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Set whether we use terminal highlighting; Permissable values are: |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item B<plain> |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
no terminal highlighting |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item B<off> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
same as B<plain> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item B<light> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
terminal background is light; this is the default |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item B<dark> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
terminal background is dark or light forgeground text |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
If the first argument is B<reset>, we clear any existing color formatting |
50
|
|
|
|
|
|
|
and recolor all source code output. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 Examples: |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
set highlight off # no highlight |
55
|
|
|
|
|
|
|
set highlight plain # same as above |
56
|
|
|
|
|
|
|
set highlight dark # terminal has dark background |
57
|
|
|
|
|
|
|
set highlight light # terminal has light background |
58
|
|
|
|
|
|
|
set highlight # same as above |
59
|
|
|
|
|
|
|
set highlight reset light # clear source-code cache and |
60
|
|
|
|
|
|
|
# set for light background |
61
|
|
|
|
|
|
|
set highlight reset # clear source-code cache |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 See also: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
L<C<show highlight>|Devel::Trepan::CmdProcessor::Command::Show::Highlight> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
HELP |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my @choices = qw(reset plain light dark off); |
71
|
|
|
|
|
|
|
sub complete($$) |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
0
|
|
|
my ($self, $prefix) = @_; |
|
0
|
|
|
0
|
|
|
|
74
|
0
|
|
|
|
|
|
Devel::Trepan::Complete::complete_token(\@choices, $prefix); |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_highlight_type($$) |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
|
|
my ($self, $arg) = @_; |
|
0
|
|
|
0
|
|
|
|
80
|
0
|
0
|
|
|
|
|
return 'light' unless $arg; |
|
0
|
0
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if (grep {$arg eq $_} @choices) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $arg; |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
|
my $proc = $self->{proc}; |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $msg = sprintf('Expecting one of: %s; got "%s"', |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
join(', ', @choices), $arg); |
87
|
0
|
|
|
|
|
|
$proc->errmsg($msg); |
|
0
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return undef; |
|
0
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub run($$) |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
0
|
|
|
my ($self, $args) = @_; |
|
0
|
|
|
0
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $proc = $self->{proc}; |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $highlight_type = 'light'; |
|
0
|
|
|
|
|
|
|
98
|
0
|
0
|
0
|
|
|
|
if ((scalar @$args >= 3) && ('reset' eq $args->[2])) { |
|
0
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if (scalar @$args > 3) { |
|
0
|
0
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$highlight_type = $self->get_highlight_type($args->[3]); |
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} else { |
102
|
0
|
|
|
|
|
|
$highlight_type = $proc->{settings}{'highlight'}; |
|
0
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
return unless $highlight_type; |
|
0
|
0
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
clear_file_format_cache(); |
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} elsif (scalar @$args == 2) { |
107
|
0
|
|
|
|
|
|
$highlight_type = 'off'; |
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} else { |
109
|
0
|
|
|
|
|
|
$highlight_type = $self->get_highlight_type($args->[2]); |
|
0
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
return unless $highlight_type; |
|
0
|
0
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
112
|
0
|
0
|
0
|
|
|
|
if ($highlight_type eq 'plain' || $highlight_type eq 'off') { |
|
0
|
0
|
0
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$highlight_type = undef ; |
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} else { |
115
|
0
|
|
|
|
|
|
Devel::Trepan::DB::LineCache::color_setup($highlight_type); |
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
|
$proc->{settings}{'highlight'} = $highlight_type; |
|
0
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$proc->set_prompt(); |
|
0
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $show_cmd = $proc->{commands}->{'show'}; |
|
0
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
$show_cmd->run(['show', 'highlight']); |
|
0
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
unless (caller) { |
124
|
|
|
|
|
|
|
# Demo it. |
125
|
|
|
|
|
|
|
require Devel::Trepan::CmdProcessor::Mock; |
126
|
|
|
|
|
|
|
my ($proc, $cmd) = |
127
|
|
|
|
|
|
|
Devel::Trepan::CmdProcessor::Mock::subcmd_setup(); |
128
|
|
|
|
|
|
|
Devel::Trepan::CmdProcessor::Mock::subcmd_demo_info($proc, $cmd); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$cmd->run($cmd->{prefix}, 'off'); |
131
|
|
|
|
|
|
|
for my $arg ('', 're', 'foo') { |
132
|
|
|
|
|
|
|
# use Enbugger('trepan'); Enbugger->stop(); |
133
|
|
|
|
|
|
|
my @aref = $cmd->complete($arg); |
134
|
|
|
|
|
|
|
printf "complete '%s': %s\n", $arg, join(', ', @aref); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |