App-Greple-stripe

 view release on metacpan or  search on metacpan

docs/stripe.ZH.pod  view on Meta::CPAN

=encoding utf-8

=head1 NAME

App::Greple::stripe - Greple 斑马纹模块

=head1 SYNOPSIS

    greple -Mstripe [ module options -- ] ...

=head1 VERSION

Version 1.02

=head1 DESCRIPTION

L<App::Greple::stripe> 是 L<greple|App::Greple> 的一个模块,用于以斑马条纹方式显示匹配文本。

下面的命令匹配两个连续的行。

    greple -E '(.+\n){1,2}' --face +E

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/normal.png">
</p>

但是,每个匹配的块都用相同的颜色着色,因此不清楚块在哪里断开。一种方法是使用 C<-blockend> 选项显式显示这些块。

    greple -E '(.+\n){1,2}' --face +E --blockend=--

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/blockend.png">
</p>

使用条纹模块,匹配相同图案的图块会用相似颜色系列的不同颜色着色。

    greple -Mstripe -E '(.+\n){1,2}' --face +E

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/stripe.png">
</p>

默认情况下,会准备两个颜色系列。因此,在搜索多个图案时,偶数图案和奇数图案会被分配不同的颜色系列。

    greple -Mstripe -E '.*[02468]$' -E '.*[13579]$' --need=1

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/random.png">
</p>

如果像上例那样指定了多个模式,则只会输出与所有模式匹配的行。因此,需要使用 C<--need=1> 选项来放宽这一条件。

如果要为三个或更多图案使用不同的颜色系列,请在调用模块时指定 C<step> 数量。系列数最多可以增加到 6 个。

    greple -Mstripe::config=step=3 --need=1 -E p1 -E p2 -E p3 ...

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/step-3.png">
</p>

=head1 MODULE OPTIONS

B<stripe> 模块有一些特定的选项。这些选项可以在模块声明时指定,也可以在模块声明后以 C<--> 结尾作为选项指定。

以下三条命令具有完全相同的效果。

    greple -Mstripe::config=step=3

    greple -Mstripe --config step=3 --

    greple -Mstripe --step=3 --

请注意,此时可以使用 C<set> 函数代替 C<config>,以实现向后兼容。

=over 7

=item B<-Mstripe::config>=B<step>=I<n>

=item B<--step>=I<n>

将步数设置为 I<n>。

=item B<-Mstripe::config>=B<darkmode>

=item B<--darkmode>

使用深色背景

=for html <p>
<img width="750" src="https://raw.githubusercontent.com/kaz-utashiro/greple-stiripe/refs/heads/main/images/darkmode.png">
</p>

使用 C<-face> 选项为所有颜色映射设置前景色。以下命令将前景色设置为白色,并用背景色填充整行。

    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



( run in 0.455 second using v1.01-cache-2.11-cpan-df04353d9ac )