| 1 |
use warnings; |
| 2 |
use strict; |
| 3 |
|
| 4 |
=head1 NAME |
| 5 |
|
| 6 |
BarnOwl::Module::WordWrap |
| 7 |
|
| 8 |
=head1 DESCRIPTION |
| 9 |
|
| 10 |
An extension of the default owl style that wordwraps displayed |
| 11 |
messages using L<Text::Autoformat> |
| 12 |
|
| 13 |
=cut |
| 14 |
|
| 15 |
package BarnOwl::Module::WordWrap; |
| 16 |
use base qw(BarnOwl::Style::Default); |
| 17 |
|
| 18 |
eval "use Text::Autoformat"; |
| 19 |
|
| 20 |
if($@) { |
| 21 |
BarnOwl::error("Text::Autoformat not found; Not loading wordwrap style"); |
| 22 |
} else { |
| 23 |
BarnOwl::create_style("wordwrap", "BarnOwl::Module::WordWrap"); |
| 24 |
} |
| 25 |
|
| 26 |
sub indent_body { |
| 27 |
my $self = shift; |
| 28 |
my $m = shift; |
| 29 |
my $body = $m->body; |
| 30 |
|
| 31 |
my $left = 5; |
| 32 |
|
| 33 |
$body = autoformat($body, {left => $left, |
| 34 |
right => BarnOwl::getnumcols() - $left - 1, |
| 35 |
all => 1, renumber => 0, list => 0}); |
| 36 |
$body =~ s/\n$//; |
| 37 |
return $body; |
| 38 |
} |
| 39 |
|
| 40 |
sub description { |
| 41 |
"A word-wrapping variant of the default style." |
| 42 |
} |
| 43 |
|
| 44 |
1; |