Changeset 864ed35 for perlwrap.pm


Ignore:
Timestamp:
Apr 29, 2008, 1:21:13 AM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b67ab6b
Parents:
120291c
Message:
Initial step of moving styles from the current mishmash of different
options to a unified object interface.
No backwards-compatibility support yet.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r9815e2e r864ed35  
    702702        if(*BarnOwl::format_msg{CODE}) {
    703703            # if the config defines a legacy formatting function, add 'perl' as a style
    704             BarnOwl::_create_style("perl", "BarnOwl::_format_msg_legacy_wrap",
    705                                    "User-defined perl style that calls BarnOwl::format_msg"
    706                                    . " with legacy global variable support");
    707             BarnOwl::set("-q default_style perl");
     704            # BarnOwl::_create_style("perl", "BarnOwl::_format_msg_legacy_wrap",
     705            #                        "User-defined perl style that calls BarnOwl::format_msg"
     706            #                        . " with legacy global variable support");
     707            # BarnOwl::set("-q default_style perl");
    708708        }
    709709    }
     
    763763sub format_message($)
    764764{
     765    my $self = shift;
    765766    my $m = shift;
    766767
    767768    if ( $m->is_loginout) {
    768         return format_login($m);
     769        return $self->format_login($m);
    769770    } elsif($m->is_ping && $m->is_personal) {
    770         return ( "\@b(PING) from \@b(" . $m->pretty_sender . ")\n" );
     771        return $self->format_ping($m);
    771772    } elsif($m->is_admin) {
    772         return "\@bold(OWL ADMIN)\n" . indentBody($m);
     773        return $self->format_admin($m);
    773774    } else {
    774         return format_chat($m);
     775        return $self->format_chat($m);
    775776    }
    776777}
    777778
    778 BarnOwl::_create_style("default", "BarnOwl::Style::Default::format_message", "Default style");
     779sub description {"Default style";}
     780
     781BarnOwl::_create_style("default", "BarnOwl::Style::Default");
    779782
    780783################################################################################
     
    787790
    788791sub format_login($) {
     792    my $self = shift;
    789793    my $m = shift;
    790794    return sprintf(
     
    798802}
    799803
     804sub format_ping {
     805    my $self = shift;
     806    my $m = shift;
     807    return "\@b(PING) from \@b(" . $m->pretty_sender . ")\n";
     808}
     809
     810sub format_admin {
     811    my $self = shift;
     812    my $m = shift;
     813    return "\@bold(OWL ADMIN)\n" . indentBody($m);
     814}
     815
    800816sub format_chat($) {
     817    my $self = shift;
    801818    my $m = shift;
    802819    my $header;
     
    846863}
    847864
     865package BarnOwl::Style::Basic;
     866
     867our @ISA=qw(BarnOwl::Style::Default);
     868
     869sub description {"Compatability alias for the default style";}
     870
     871BarnOwl::_create_style("basic", "BarnOwl::Style::Basic");
     872
    848873package BarnOwl::Style::OneLine;
    849874################################################################################
     
    852877use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
    853878sub format_message($) {
     879  my $self = shift;
    854880  my $m = shift;
    855881
    856 #  if ( $m->is_zephyr ) {
    857 #    return format_zephyr($m);
    858 #  }
    859882  if ( $m->is_loginout ) {
    860     return format_login($m);
     883    return $self->format_login($m);
    861884  }
    862885  elsif ( $m->is_ping) {
    863     return format_ping($m);
     886    return $self->format_ping($m);
    864887  }
    865888  elsif ( $m->is_admin || $m->is_loopback) {
    866     return format_local($m);
     889    return $self->format_local($m);
    867890  }
    868891  else {
    869     return format_chat($m);
     892    return $self->format_chat($m);
    870893  }
    871894}
    872895
    873 BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message");
     896sub description {"Formats for one-line-per-message"}
     897
     898BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine");
    874899
    875900################################################################################
    876901
    877902sub format_login($) {
     903  my $self = shift;
    878904  my $m = shift;
    879905  return sprintf(
     
    898924sub format_chat($)
    899925{
     926  my $self = shift;
    900927  my $m = shift;
    901928  my $dir = lc($m->{direction});
     
    938965sub format_local($)
    939966{
     967  my $self = shift;
    940968  my $m = shift;
    941969  my $type = uc($m->{type});
Note: See TracChangeset for help on using the changeset viewer.