source: perl/lib/BarnOwl/Style.pm @ ee183be

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since ee183be was ee183be, checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
Break perlwrap.pm into multiple files. Break perlwrap.pm out into .pm files in perl/lib. With this commit, we keep perlwrap.pm around and still load it as before. The next commit will delete perlwrap.pm and start loading perl files directly from disk at runtime.
  • Property mode set to 100644
File size: 1.1 KB
Line 
1use strict;
2use warnings;
3
4package BarnOwl::Style;
5
6# This takes a zephyr to be displayed and modifies it to be displayed
7# entirely in bold.
8sub boldify
9{
10    local $_ = shift;
11    if ( !(/\)/) ) {
12        return '@b(' . $_ . ')';
13    } elsif ( !(/\>/) ) {
14        return '@b<' . $_ . '>';
15    } elsif ( !(/\}/) ) {
16        return '@b{' . $_ . '}';
17    } elsif ( !(/\]/) ) {
18        return '@b[' . $_ . ']';
19    } else {
20        my $txt = "\@b($_";
21        $txt =~ s/\)/\)\@b\[\)\]\@b\(/g;
22        return $txt . ')';
23    }
24}
25
26sub style_command {
27    my $command = shift;
28    if(scalar @_ != 3 || $_[1] ne 'perl') {
29        die("Usage: style <name> perl <function>\n");
30    }
31    my $name = shift;
32    my $perl = shift;
33    my $fn   = shift;
34    {
35        # For historical reasons, assume unqualified references are
36        # in main::
37        package main;
38        no strict 'refs';
39        unless(*{$fn}{CODE}) {
40            die("Unable to create style '$name': no perl function '$fn'\n");
41        }
42    }
43    BarnOwl::create_style($name, BarnOwl::Style::Legacy->new($fn));
44}
45
46
471;
Note: See TracBrowser for help on using the repository browser.