« blib/lib/Devel/Trepan/CmdProcessor/Command/Show_Subcmd/Aliases.pm
↑ Summary
lib/Devel/Trepan/Position.pm »
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | # Copyright (C) 2011, 2014 Rocky Bernstein <rocky@cpan.org> | ||
| 3 | use warnings; no warnings 'redefine'; no warnings 'once'; | ||
| 4 | use rlib '../../../../..'; | ||
| 5 | |||
| 6 | package Devel::Trepan::CmdProcessor::Command::Show::Highlight; | ||
| 7 | |||
| 8 | use Devel::Trepan::CmdProcessor::Command::Subcmd::Core; | ||
| 9 | |||
| 10 | @ISA = qw(Devel::Trepan::CmdProcessor::Command::ShowBoolSubcmd); | ||
| 11 | # Values inherited from parent | ||
| 12 | use vars @Devel::Trepan::CmdProcessor::Command::Subcmd::SUBCMD_VARS; | ||
| 13 | |||
| 14 | # =pod | ||
| 15 | # | ||
| 16 | # =head2 Synopsis: | ||
| 17 | # | ||
| 18 | # =cut | ||
| 19 | our $HELP = <<"EOH"; | ||
| 20 | =pod | ||
| 21 | |||
| 22 | B<show highlight> | ||
| 23 | |||
| 24 | Show whether we use terminal highlighting | ||
| 25 | |||
| 26 | =head2 See also: | ||
| 27 | |||
| 28 | L<C<set highlight>|Devel::Trepan::CmdProcessor::Command::Set::Highlight> | ||
| 29 | =cut | ||
| 30 | EOH | ||
| 31 | our $SHORT_HELP = "Show whether we use terminal highlighting"; | ||
| 32 | our $MIN_ABBREV = length('high'); | ||
| 33 | |||
| 34 | sub run($$) | ||
| 35 | { | ||
| 36 | my ($self, $args) = @_; | ||
| 37 | my $proc = $self->{proc}; | ||
| 38 | my $val = $proc->{settings}{highlight} || 'plain'; | ||
| 39 | my $mess; | ||
| 40 | if ('plain' eq $val) { | ||
| 41 | $mess = 'output set to not use terminal escape sequences'; | ||
| 42 | } elsif ('lightbg' eq $val) { | ||
| 43 | $mess = 'output set for terminal with escape sequences ' . | ||
| 44 | 'for a light background'; | ||
| 45 | } elsif ('darkbg' eq $val) { | ||
| 46 | $mess = ('output set for terminal with escape sequences ' . | ||
| 47 | 'for a dark background') | ||
| 48 | } else { | ||
| 49 | $proc->errmsg(sprintf('Internal error: incorrect highlight setting %s', $val)); | ||
| 50 | } | ||
| 51 | $proc->msg($mess); | ||
| 52 | } | ||
| 53 | |||
| 54 | unless (caller) { | ||
| 55 | # Demo it. | ||
| 56 | require Devel::Trepan::CmdProcessor; | ||
| 57 | my $proc = Devel::Trepan::CmdProcessor->new; | ||
| 58 | my $parent = Devel::Trepan::CmdProcessor::Command::Set->new($proc, 'show'); | ||
| 59 | my $cmd = __PACKAGE__->new($parent, 'highlight'); | ||
| 60 | print $cmd->{help}, "\n"; | ||
| 61 | print "min args: ", $cmd->MIN_ARGS, "\n"; | ||
| 62 | print $cmd->run(); | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; |