source: perl/lib/BarnOwl/Style.pm @ 6dba228

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 6dba228 was fd8dfe7, checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
Load perl code from the filesystem at runtime. Remove perlwrap.pm and associated code, and instead do 'use BarnOwl' at boot time to load cdoe from the file system at runtime. In addition, add appropriate 'use' statements to the .pm files to cause everything to get loaded.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1use strict;
2use warnings;
3
4package BarnOwl::Style;
5
6use BarnOwl::Style::Basic;
7use BarnOwl::Style::Default;
8use BarnOwl::Style::Legacy;
9use BarnOwl::Style::OneLine;
10
11# This takes a zephyr to be displayed and modifies it to be displayed
12# entirely in bold.
13sub boldify
14{
15    local $_ = shift;
16    if ( !(/\)/) ) {
17        return '@b(' . $_ . ')';
18    } elsif ( !(/\>/) ) {
19        return '@b<' . $_ . '>';
20    } elsif ( !(/\}/) ) {
21        return '@b{' . $_ . '}';
22    } elsif ( !(/\]/) ) {
23        return '@b[' . $_ . ']';
24    } else {
25        my $txt = "\@b($_";
26        $txt =~ s/\)/\)\@b\[\)\]\@b\(/g;
27        return $txt . ')';
28    }
29}
30
31sub style_command {
32    my $command = shift;
33    if(scalar @_ != 3 || $_[1] ne 'perl') {
34        die("Usage: style <name> perl <function>\n");
35    }
36    my $name = shift;
37    my $perl = shift;
38    my $fn   = shift;
39    {
40        # For historical reasons, assume unqualified references are
41        # in main::
42        package main;
43        no strict 'refs';
44        unless(*{$fn}{CODE}) {
45            die("Unable to create style '$name': no perl function '$fn'\n");
46        }
47    }
48    BarnOwl::create_style($name, BarnOwl::Style::Legacy->new($fn));
49}
50
51
521;
Note: See TracBrowser for help on using the repository browser.