App-Greple-stripe
view release on metacpan or search on metacpan
lib/App/Greple/stripe.pm view on Meta::CPAN
greple -Mstripe --step=3 --
Note that, C<set> function can be used instead of C<config> for
backward compatibility, at this point.
=over 7
=item B<-Mstripe::config>=B<step>=I<n>
=item B<--step>=I<n>
Set the step count to I<n>.
=item B<-Mstripe::config>=B<darkmode>
=item B<--darkmode>
Use dark background colors.
=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/darkmode.png">
</p>
Use C<--face> option to set foreground color for all colormap. The
following command sets the foreground color to white and fills the
entire line with the background color.
greple -Mstripe --darkmode -- --face +WE
=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/dark-white.png">
</p>
=back
=head1 SEE ALSO
L<App::Greple>
L<App::Greple::xlate>
L<Getopt::EX::Config>
=head1 AUTHOR
Kazumasa Utashiro
=head1 LICENSE
Copyright Â©ï¸ 2024-2025 Kazumasa Utashiro.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
use List::Util qw(max pairmap first);
use Hash::Util qw(lock_keys);
use Scalar::Util;
*is_number = \&Scalar::Util::looks_like_number;
use Data::Dumper;
use Getopt::EX::Config qw(config set);
my $config = Getopt::EX::Config->new(
step => 2,
darkmode => undef,
);
lock_keys %{$config};
my %series = (
light => [
[ qw(/544 /533) ],
[ qw(/454 /353) ],
[ qw(/445 /335) ],
[ qw(/455 /355) ],
[ qw(/545 /535) ],
[ qw(/554 /553) ],
],
dark => [
[ qw(/200 /100) ],
[ qw(/020 /010) ],
[ qw(/004 /003) ],
[ qw(/022 /011) ],
[ qw(/202 /101) ],
[ qw(/220 /110) ],
],
);
sub finalize {
our($mod, $argv) = @_;
Getopt::EX::Config->deal_with(
$argv,
map("$_:1", keys %{$config}),
);
my @default = qw(--stripe-postgrep);
my @cm = qw(@);
my $map = config('darkmode') ? $series{dark} : $series{light};
for my $i (0, 1) {
for my $s (0 .. config('step') - 1) {
push @cm, $map->[$s % @$map]->[$i];
}
}
local $" = ',';
$mod->setopt(default => join(' ', @default, "--cm=@cm"));
}
#
# Increment each index by $step
#
sub stripe {
my $grep = shift;
my $step = config('step');
if ($step == 0) {
$step = _max_index($grep) + 1;
}
my @counter = (-$step .. -1);
for my $r ($grep->result) {
my($b, @match) = @$r;
for my $m (@match) {
my $mod = $m->[2] % $step;
( run in 2.312 seconds using v1.01-cache-2.11-cpan-df04353d9ac )