release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 3a6277a was
fc92548d,
checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
|
Replace '@ISA' references with 'use base'
'use base' will automatically 'use' the prereq modules, which was
potentially problematic back when that didn't work, but is now exactly
what we want.
|
-
Property mode set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | use strict; |
---|
2 | use warnings; |
---|
3 | |
---|
4 | package BarnOwl::Style::OneLine; |
---|
5 | # Inherit format_message to dispatch |
---|
6 | use base qw(BarnOwl::Style::Default); |
---|
7 | |
---|
8 | use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s '; |
---|
9 | |
---|
10 | sub description {"Formats for one-line-per-message"} |
---|
11 | |
---|
12 | BarnOwl::create_style("oneline", "BarnOwl::Style::OneLine"); |
---|
13 | |
---|
14 | ################################################################################ |
---|
15 | |
---|
16 | sub maybe { |
---|
17 | my $thing = shift; |
---|
18 | return defined($thing) ? $thing : ""; |
---|
19 | } |
---|
20 | |
---|
21 | sub format_login { |
---|
22 | my $self = shift; |
---|
23 | my $m = shift; |
---|
24 | return sprintf( |
---|
25 | BASE_FORMAT, |
---|
26 | '<', |
---|
27 | $m->type, |
---|
28 | uc( $m->login ), |
---|
29 | $m->pretty_sender) |
---|
30 | . ($m->login_extra ? "at ".$m->login_extra : ''); |
---|
31 | } |
---|
32 | |
---|
33 | sub format_ping { |
---|
34 | my $self = shift; |
---|
35 | my $m = shift; |
---|
36 | return sprintf( |
---|
37 | BASE_FORMAT, |
---|
38 | '<', |
---|
39 | $m->type, |
---|
40 | 'PING', |
---|
41 | $m->pretty_sender) |
---|
42 | } |
---|
43 | |
---|
44 | sub format_chat |
---|
45 | { |
---|
46 | my $self = shift; |
---|
47 | my $m = shift; |
---|
48 | my $dir = lc($m->{direction}); |
---|
49 | my $dirsym = '-'; |
---|
50 | if ($dir eq 'in') { |
---|
51 | $dirsym = '<'; |
---|
52 | } |
---|
53 | elsif ($dir eq 'out') { |
---|
54 | $dirsym = '>'; |
---|
55 | } |
---|
56 | |
---|
57 | my $line; |
---|
58 | if ($m->is_personal) { |
---|
59 | |
---|
60 | # Figure out what to show in the subcontext column |
---|
61 | $line= sprintf(BASE_FORMAT, |
---|
62 | $dirsym, |
---|
63 | $m->type, |
---|
64 | maybe($m->short_personal_context), |
---|
65 | ($dir eq 'out' |
---|
66 | ? $m->pretty_recipient |
---|
67 | : $m->pretty_sender)); |
---|
68 | } |
---|
69 | else { |
---|
70 | $line = sprintf(BASE_FORMAT, |
---|
71 | $dirsym, |
---|
72 | maybe($m->context), |
---|
73 | maybe($m->subcontext), |
---|
74 | ($dir eq 'out' |
---|
75 | ? $m->pretty_recipient |
---|
76 | : $m->pretty_sender)); |
---|
77 | } |
---|
78 | |
---|
79 | my $body = $m->{body}; |
---|
80 | $body =~ tr/\n/ /; |
---|
81 | $line .= $body; |
---|
82 | return $line; |
---|
83 | } |
---|
84 | |
---|
85 | # Format owl admin messages |
---|
86 | sub format_admin |
---|
87 | { |
---|
88 | my $self = shift; |
---|
89 | my $m = shift; |
---|
90 | my $line = sprintf(BASE_FORMAT, '<', 'ADMIN', '', ''); |
---|
91 | my $body = $m->{body}; |
---|
92 | $body =~ tr/\n/ /; |
---|
93 | return $line.$body; |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.