source: perl/modules/WordWrap/lib/BarnOwl/Module/WordWrap.pm @ 45cf49f

debianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 45cf49f was 1375a6a, checked in by Nelson Elhage <nelhage@mit.edu>, 16 years ago
Add a word-wrapping style to the repo and default build.
  • Property mode set to 100644
File size: 873 bytes
RevLine 
[1375a6a]1use warnings;
2use strict;
3
4=head1 NAME
5
6BarnOwl::Module::WordWrap
7
8=head1 DESCRIPTION
9
10An extension of the default owl style that wordwraps displayed
11messages using Text:;Autoformat
12
13=cut
14
15package BarnOwl::Module::WordWrap;
16use base qw(BarnOwl::Style::Default);
17
18eval "use Text::Autoformat";
19
20if($@) {
21    BarnOwl::error("Text::Autoformat not found; Not loading wordwrap style");
22} else {
23    BarnOwl::create_style("wordwrap", "BarnOwl::Module::WordWrap");
24}
25
26sub 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
40sub description {
41    "A word-wrapping variant of the default style."
42}
43
441;
Note: See TracBrowser for help on using the repository browser.