App-Greple-stripe

 view release on metacpan or  search on metacpan

docs/stripe.JA.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> のモジュールです。

次のコマンドは連続する2行にマッチします。

    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>

stripeモジュールを使うと、同じパターンにマッチしたブロックは、類似色系列の異なる色で着色されます。

    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>

デフォルトでは2つの色系列が用意されている。そのため、複数のパターンを検索した場合、偶数パターンと奇数パターンでは、それぞれ異なる色系列が割り当てられる。

    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>オプションが必要となる。

3つ以上のパターンで異なる色系列を使いたい場合は、モジュールを呼び出すときに 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<-->で終わるオプションとして指定します。

以下の3つのコマンドは全く同じ効果をもたらします。

    greple -Mstripe::config=step=3

    greple -Mstripe --config step=3 --

    greple -Mstripe --step=3 --

なお、現時点では下位互換性のためにC<config>の代わりにC<set>関数を使うことができます。

=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 1.713 second using v1.01-cache-2.11-cpan-df04353d9ac )