Changeset b67ab6b for perlwrap.pm


Ignore:
Timestamp:
Apr 29, 2008, 1:21:15 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:
52f8dd6
Parents:
864ed35
Message:
Implement back-compat with old-style owl::format_msg() styles
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r864ed35 rb67ab6b  
    153153}
    154154$configfile ||= $ENV{HOME}."/.owlconf";
    155 
    156 # populate global variable space for legacy owlconf files
    157 sub _format_msg_legacy_wrap {
    158     my ($m) = @_;
    159     $m->legacy_populate_global();
    160     return &BarnOwl::format_msg($m);
    161 }
    162155
    163156# populate global variable space for legacy owlconf files
     
    702695        if(*BarnOwl::format_msg{CODE}) {
    703696            # 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");
     697            BarnOwl::create_style("perl", BarnOwl::Style::Legacy->new(
     698                "BarnOwl::format_msg",
     699                "User-defined perl style that calls BarnOwl::format_msg"
     700                . " with legacy global variable support",
     701                1));
     702             BarnOwl::set("-q default_style perl");
    708703        }
    709704    }
     
    779774sub description {"Default style";}
    780775
    781 BarnOwl::_create_style("default", "BarnOwl::Style::Default");
     776BarnOwl::create_style("default", "BarnOwl::Style::Default");
    782777
    783778################################################################################
     
    869864sub description {"Compatability alias for the default style";}
    870865
    871 BarnOwl::_create_style("basic", "BarnOwl::Style::Basic");
     866BarnOwl::create_style("basic", "BarnOwl::Style::Basic");
    872867
    873868package BarnOwl::Style::OneLine;
     
    896891sub description {"Formats for one-line-per-message"}
    897892
    898 BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine");
     893BarnOwl::create_style("oneline", "BarnOwl::Style::OneLine");
    899894
    900895################################################################################
     
    996991}
    997992
     993package BarnOwl::Style::Legacy;
     994
     995sub new {
     996    my $class = shift;
     997    my $func  = shift;
     998    my $desc  = shift;
     999    my $useglobals = shift;
     1000    $useglobals = 0 unless defined($useglobals);
     1001    return bless {function    => $func,
     1002                  description => $desc,
     1003                  useglobals  => $useglobals}, $class;
     1004}
     1005
     1006sub description {shift->{description}};
     1007
     1008sub format_message {
     1009    my $self = shift;
     1010    if($self->{useglobals}) {
     1011        $_[0]->legacy_populate_global();
     1012    }
     1013    no strict 'refs';
     1014    goto \&{$self->{function}};
     1015}
     1016
    9981017
    9991018# switch to package main when we're done
Note: See TracChangeset for help on using the changeset viewer.