Changes in / [d9337637:db0ac7e]


Ignore:
Files:
1 added
1 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • Makefile.in

    r9c7a701 r864ed35  
    2525     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
    2626     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    27      aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \
     27     aim.c buddy.c buddylist.c timer.c style.c errqueue.c \
    2828     zbuddylist.c muxevents.c popexec.c obarray.c select.c wcwidth.c \
    2929     glib_compat.c
     
    4848HEADERS=$(GEN_H) owl.h config.h test.h
    4949
    50 %.o: %.c $(HEADERS)
    51         $(CC) -c $(CFLAGS) $< -o $@
    52 
    5350$(EXE): $(AUTOGEN) $(OBJS) owl.o libfaim
    5451        $(ATHSTATIC) $(CC) -o $(EXE) owl.o $(OBJS) $(LDFLAGS) $(LIBS)
     
    5653tester: $(AUTOGEN) $(OBJS) tester.o
    5754        $(ATHSTATIC) $(CC) -o tester tester.o $(OBJS) $(LDFLAGS) $(LIBS)
     55
     56%.o: %.c $(HEADERS)
     57        $(CC) -c $(CFLAGS) $< -o $@
     58
     59# zcrypt is old crufty DES code I don't want to touch
     60# Disable all warnings when compiling it
     61zcrypt.o: zcrypt.c $(HEADERS)
     62        $(CC) -c $(CFLAGS) $< -w -o $@
    5863
    5964test: tester
     
    100105#owl_prototypes.h:
    101106
    102 .PHONY: tags clean distclean proto test
     107.PHONY: tags clean distclean proto test check-syntax
    103108
    104109tags: TAGS
     
    107112        etags $(BASE_SRCS) $(OWL_SRC) $(TESTER_SRC) $(GEN_C) owl.h $(GEN_H)
    108113
    109 $(BASE_OBJS) varstubs.h:: owl.h config.h owl_prototypes.h
    110 #$(BASE_OBJS) varstubs.h:: owl.h config.h
     114$(BASE_OBJS) varstubs.h: owl.h config.h owl_prototypes.h
    111115
    112116libfaim: libfaim/libfaim.a
     
    135139installdirs: mkinstalldirs
    136140        ${srcdir}/mkinstalldirs ${DESTDIR}${bindir} ${DESTDIR}${mandir}/man1 ${DESTDIR}${datadir}
     141
     142# For emacs flymake-mode
     143check-syntax: proto
     144        $(CC) $(CFLAGS) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
  • aim.c

    r34509d5 re3e6cff  
    14521452     *
    14531453     */
    1454     strncpy(realmsg, args->msg, sizeof(realmsg));
     1454    if (args->msg && args->msglen)
     1455      strncpy(realmsg, args->msg, sizeof(realmsg));
    14551456  }
    14561457
  • commands.c

    r3617286 r864ed35  
    101101              "Use 'show keymaps' to see the existing keymaps.\n"
    102102              "Key sequences may be things like M-C-t or NPAGE.\n"),
    103 
    104   OWLCMD_ARGS("style", owl_command_style, OWL_CTX_ANY,
    105               "creates a new style",
    106               "style <name> perl <function_name>",
    107               "Creates a new style for formatting messages.\n"
    108               "A style named <name> will be created that will\n"
    109               "format messages using the perl function <function_name>.\n\n"
    110               "SEE ALSO: show styles, view -s, filter -s\n"),
    111103
    112104  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
     
    180172              "print <variable>\n"
    181173              "print",
    182               "Print the value of the named variable.  If no arugments\n"
     174              "Print the value of the named variable.  If no arguments\n"
    183175              "are used print the value of all variables.\n"),
    184176
     
    599591              "smartnarrow [-i | --instance]",
    600592              "If the curmsg is a personal message narrow\n"
    601               "   to the converstaion with that user.\n"
     593              "   to the conversation with that user.\n"
    602594              "If the curmsg is a class message, instance foo, recip *\n"
    603595              "   message, narrow to the class, inst.\n"
     
    611603              "smartfilter [-i | --instance]",
    612604              "If the curmsg is a personal message, the filter is\n"
    613               "   the converstaion with that user.\n"
     605              "   the conversation with that user.\n"
    614606              "If the curmsg is a class message, instance foo, recip *\n"
    615607              "   message, the filter is the class, inst.\n"
     
    963955                  "", ""),
    964956
     957  OWLCMD_ALIAS("webzephyr", "zwrite daemon.webzephyr -c webzephyr -i"),
     958
    965959  /* This line MUST be last! */
    966960  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
     
    16731667  return NULL;
    16741668}
    1675 
    1676 char *owl_command_style(int argc, char **argv, char *buff) {
    1677   owl_style *s;
    1678 
    1679   /* Usage: style <name> perl <function> */
    1680   if (argc != 4 || strcmp(argv[2], "perl")) {
    1681     owl_function_makemsg("Usage: style <name> perl <function>");
    1682     return NULL;
    1683   }
    1684   if (!owl_perlconfig_is_function(argv[3])) {
    1685     owl_function_makemsg("Unable to create style '%s': no perl function '%s'",
    1686                          argv[1], argv[3]);
    1687     return NULL;
    1688   }
    1689   s=owl_malloc(sizeof(owl_style));
    1690   owl_style_create_perl(s, argv[1], argv[3], NULL);
    1691   owl_global_add_style(&g, s);
    1692 
    1693   return NULL;
    1694 }
    1695 
    16961669
    16971670void owl_command_quit()
  • functions.c

    r6b580b0 rcdd3959  
    258258  ret=owl_zwrite_create_from_line(&z, line);
    259259  if (ret) {
    260     owl_function_error("Error in zwrite arugments");
     260    owl_function_error("Error in zwrite arguments");
    261261    owl_zwrite_free(&z);
    262262    return;
     
    19251925  owl_fmtext_append_normal(&fm, "\n");
    19261926
    1927   owl_fmtext_append_normal(&fm, "  Startup Arugments: ");
     1927  owl_fmtext_append_normal(&fm, "  Startup Arguments: ");
    19281928  owl_fmtext_append_normal(&fm, owl_global_get_startupargs(&g));
    19291929  owl_fmtext_append_normal(&fm, "\n");
  • global.c

    r054894e r8aa83ea3  
    453453  sepbar(NULL);
    454454  owl_editwin_redisplay(&(g->tw), 0);
     455  owl_function_full_redisplay(&g);
    455456
    456457  /* TODO: this should handle other forms of popwins */
  • keys.c

    ra6a4155 r3004c9f  
    230230
    231231  BIND_CMD("LEFT",   "recv:shiftleft", "");
     232  BIND_CMD("M-[ D",  "recv:shiftleft", "");
    232233  BIND_CMD("RIGHT",  "recv:shiftright","");
     234  BIND_CMD("M-[ C",  "recv:shiftleft", "");
    233235  BIND_CMD("DOWN",   "recv:next",      "");
    234236  BIND_CMD("C-n",    "recv:next",      "");
     237  BIND_CMD("M-[ B",  "recv:next",      "");
    235238  BIND_CMD("M-C-n",  "recv:next --smart-filter", "move to next message matching the current one");
    236239  BIND_CMD("UP",     "recv:prev",      "");
     240  BIND_CMD("M-[ A",  "recv:prev",      "");
    237241  BIND_CMD("n",      "recv:next-notdel", "");
    238242  BIND_CMD("p",      "recv:prev-notdel", "");
     
    281285  BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
    282286
     287  BIND_CMD("W",   "start-command webzephyr ", "start a webzephyr command");
     288
    283289  BIND_CMD("C-c",  "",                "no effect in this mode");
    284290  BIND_CMD("C-g",  "",                "no effect in this mode");
  • owl.c

    r4cc0ee0b r52f8dd6  
    274274  }
    275275
    276   /* setup the built-in styles */
    277   owl_function_debugmsg("startup: creating built-in styles");
    278 
    279   s=owl_malloc(sizeof(owl_style));
    280   owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting.");
    281   owl_global_add_style(&g, s);
    282 
    283276  /* setup the default filters */
    284277  /* the personal filter will need to change again when AIM chat's are
     
    409402  if (0 != strcmp(owl_global_get_default_style(&g), "__unspecified__")) {
    410403    /* the style was set by the user: leave it alone */
    411   } else if (owl_global_is_config_format(&g)) {
    412     owl_global_set_default_style(&g, "perl");
    413   } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     404  } else {
    414405    owl_global_set_default_style(&g, "default");
    415   } else {
    416     owl_global_set_default_style(&g, "basic");
    417406  }
    418407
     
    436425  nexttime=time(NULL);
    437426
     427#ifdef HAVE_LIBZEPHYR
     428  /* Check for any zephyrs that have come in while we've done init. */
     429  owl_zephyr_process_events();
     430#endif
     431 
    438432  owl_function_debugmsg("startup: entering main loop");
    439433  /* main loop */
     
    595589  if(owl_message_is_direction_in(m)) {
    596590    /* let perl know about it*/
    597     owl_perlconfig_getmsg(m, 0, NULL);
     591    owl_perlconfig_getmsg(m, NULL);
    598592
    599593    /* do we need to autoreply? */
  • owl.h

    r9c7a701 r120291c  
    7070#define HAS_BOOL
    7171#include <perl.h>
     72#include "owl_perl.h"
    7273#undef logout
    7374#include "XSUB.h"
     
    162163#define OWL_SCROLLMODE_PAGED       4
    163164#define OWL_SCROLLMODE_PAGEDCENTER 5
    164 
    165 #define OWL_STYLE_TYPE_INTERNAL  0
    166 #define OWL_STYLE_TYPE_PERL      1
    167165
    168166#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
     
    386384typedef struct _owl_style {
    387385  char *name;
    388   char *description;
    389   int type;
    390   char *perlfuncname;
    391   void (*formatfunc) (owl_fmtext *fm, owl_message *m);
     386  SV *perlobj;
    392387} owl_style;
    393388
  • perl/lib/BarnOwl/ModuleLoader.pm

    re005862 r965e14d  
    4040        if(!defined eval "use BarnOwl::Module::$class") {
    4141            # BarnOwl::error("Unable to load module $class: $!") if $!;
    42             BarnOwl::error("Unable to load module $class: $@") if $@;
     42            BarnOwl::error("Unable to load module $class: \n$@\n") if $@;
    4343        }
    4444    }
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r9c7a701 r919535f  
    199199        process_msg($conn, $to, join(" ", @_));
    200200    } else {
    201         BarnOwl::start_edit_win("/msg $to -a " . $conn->alias, sub {process_msg($conn, $to, @_)});
     201        BarnOwl::start_edit_win("/msg -a " . $conn->alias . " $to", sub {process_msg($conn, $to, @_)});
    202202    }
    203203}
     
    209209    # Strip whitespace. In the future -- send one message/line?
    210210    $body =~ tr/\n\r/  /;
    211     $conn->conn->privmsg($to, $body);
     211    if ($body =~ /^\/me (.*)/) {
     212        $conn->conn->me($to, $1);
     213        $body = BarnOwl::Style::boldify($conn->nick.' '.$1);
     214    } else {
     215        $conn->conn->privmsg($to, $body);
     216    }
    212217    my $msg = BarnOwl::Message->new(
    213218        type        => 'IRC',
     
    220225        is_private($to) ?
    221226          (isprivate  => 'true') : (channel => $to),
    222         replycmd    => "irc-msg $to",
    223         replysendercmd => "irc-msg $to"
     227        replycmd    => "irc-msg -a " . $conn->alias . " $to",
     228        replysendercmd => "irc-msg -a " . $conn->alias . " $to"
    224229       );
    225230    BarnOwl::queue_message($msg);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    r661d2eb r8faab0c  
    108108        is_private($recipient) ?
    109109          (isprivate  => 'true') : (channel => $recipient),
    110         replycmd    => 'irc-msg ' .
     110        replycmd    => 'irc-msg -a ' . $self->alias . ' ' .
    111111            (is_private($recipient) ? $evt->nick : $recipient),
    112         replysendercmd => 'irc-msg ' . $evt->nick
     112        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    113113       );
    114114
     
    158158        loginout   => 'login',
    159159        channel    => $evt->to,
     160        replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
     161        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    160162        );
    161163    BarnOwl::queue_message($msg);
     
    167169        loginout   => 'logout',
    168170        channel    => $evt->to,
     171        replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
     172        replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
    169173        );
    170174    BarnOwl::queue_message($msg);
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r6b580b0 rb72a352  
    2525use Net::DNS;
    2626use Getopt::Long;
     27Getopt::Long::Configure(qw(no_getopt_compat prefix_pattern=-|--));
    2728
    2829use utf8;
     
    479480        'account=s' => \$from,
    480481        'id=s'     =>  \$jwrite_sid,
    481     );
     482    ) or die("Usage: jwrite JID [-t thread] [-s 'subject'] [-a account]\n");
    482483    $jwrite_type = 'groupchat' if $gc;
    483484
     
    570571
    571572        my $getopt = Getopt::Long::Parser->new;
    572         $getopt->configure('pass_through');
     573        $getopt->configure('pass_through', 'no_getopt_compat');
    573574        $getopt->getoptions( 'account=s' => \$jid );
    574575        $jid ||= defaultJID();
     
    734735        my $purgeGroups;
    735736        my $getopt = Getopt::Long::Parser->new;
    736         $getopt->configure('pass_through');
     737        $getopt->configure('pass_through', 'no_getopt_compat');
    737738        $getopt->getoptions(
    738739            'account=s' => \$jid,
  • perl/modules/Jabber/lib/Net/Jabber/Data.pm

    rc2bed55 rcdd3959  
    120120to go into full detail on each of these functions.  Rather I will
    121121present the functions in a list with a type in the first column to
    122 show what they return, or take as arugments.  Here is the list of
     122show what they return, or take as arguments.  Here is the list of
    123123types I will use:
    124124
  • perl/modules/Jabber/lib/Net/Jabber/Protocol.pm

    rc2bed55 rcdd3959  
    940940        if (!exists($funcHash{set}) && exists($funcHash{get}))
    941941        {
    942             croak("The DefineNamespace arugments have changed, and I cannot determine the\nnew values automatically for name($name).  Please read the man page\nfor Net::Jabber::Namespaces.  I apologize for this incompatability.\n");
     942            croak("The DefineNamespace arguments have changed, and I cannot determine the\nnew values automatically for name($name).  Please read the man page\nfor Net::Jabber::Namespaces.  I apologize for this incompatability.\n");
    943943        }
    944944
  • perlconfig.c

    r9c7a701 rb67ab6b  
    411411}
    412412
    413 char *owl_perlconfig_getmsg(owl_message *m, int mode, char *subname)
    414 {
    415   /* if mode==1 we are doing message formatting.  The returned
    416    * formatted message needs to be freed by the caller.
    417    *
    418    * if mode==0 we are just doing the message-has-been-received
    419    * thing.
    420    */
    421   if (!owl_global_have_config(&g)) return(NULL);
    422  
    423   /* run the procedure corresponding to the mode */
    424   if (mode==1) {
    425     char *ret = NULL;
    426     ret = owl_perlconfig_call_with_message(subname?subname
    427                                            :"BarnOwl::_format_msg_legacy_wrap", m);
    428     if (!ret) {
    429       ret = owl_sprintf("@b([Perl Message Formatting Failed!])\n");
    430     }
    431     return ret;
    432   } else {
    433     char *ptr = NULL;
    434     if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) {
    435       ptr = owl_perlconfig_call_with_message(subname?subname
    436                                        :"BarnOwl::_receive_msg_legacy_wrap", m);
    437     }
    438     if (ptr) owl_free(ptr);
    439     return(NULL);
    440   }
     413void owl_perlconfig_getmsg(owl_message *m, char *subname)
     414{
     415  char *ptr = NULL;
     416  if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) {
     417    ptr = owl_perlconfig_call_with_message(subname?subname
     418                                           :"BarnOwl::_receive_msg_legacy_wrap", m);
     419  }
     420  if (ptr) owl_free(ptr);
    441421}
    442422
  • perlglue.xs

    r9c7a701 rb67ab6b  
    256256
    257257void
    258 _create_style(name, function, description)
     258create_style(name, object)
    259259     char *name
    260      char *function
    261      char *description
     260     SV  *object
    262261     PREINIT:
    263                 /* This is to allow us to bootstrap the default style before the
    264                 command architecture has been initialized */
    265262                owl_style *s;
    266263     CODE:
    267264        {
    268265                s = owl_malloc(sizeof(owl_style));
    269                 owl_style_create_perl(s, name, function, description);
     266                owl_style_create_perl(s, name, object);
    270267                owl_global_add_style(&g, s);
    271268        }
  • perlwrap.pm

    r9815e2e r811ad93  
    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
     
    692685# Internal startup/shutdown routines called by the C code
    693686
     687sub _load_perl_commands {
     688    # Load builtin perl commands
     689    BarnOwl::new_command(style => \&BarnOwl::Style::style_command,
     690                       {
     691                           summary => "creates a new style",
     692                           usage   => "style <name> perl <function_name>",
     693                           description =>
     694                           "A style named <name> will be created that will\n" .
     695                           "format messages using the perl function <function_name>.\n\n" .
     696                           "SEE ALSO: show styles, view -s, filter -s\n\n" .
     697                           "DEPRECATED in favor of BarnOwl::create_style(NAME, OBJECT)",
     698                          });
     699}
     700
    694701sub _load_owlconf {
    695702    # load the config  file
     
    702709        if(*BarnOwl::format_msg{CODE}) {
    703710            # 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");
     711            BarnOwl::create_style("perl", BarnOwl::Style::Legacy->new(
     712                "BarnOwl::format_msg",
     713                "User-defined perl style that calls BarnOwl::format_msg"
     714                . " with legacy global variable support",
     715                1));
     716             BarnOwl::set("-q default_style perl");
    708717        }
    709718    }
     
    715724
    716725sub _startup {
     726    _load_perl_commands();
    717727    _load_owlconf();
    718728
     
    763773sub format_message($)
    764774{
    765     my $m = shift;
     775    my $self = shift;
     776    my $m    = shift;
     777    my $fmt;
    766778
    767779    if ( $m->is_loginout) {
    768         return format_login($m);
     780        $fmt = $self->format_login($m);
    769781    } elsif($m->is_ping && $m->is_personal) {
    770         return ( "\@b(PING) from \@b(" . $m->pretty_sender . ")\n" );
     782        $fmt = $self->format_ping($m);
    771783    } elsif($m->is_admin) {
    772         return "\@bold(OWL ADMIN)\n" . indentBody($m);
     784        $fmt = $self->format_admin($m);
    773785    } else {
    774         return format_chat($m);
    775     }
    776 }
    777 
    778 BarnOwl::_create_style("default", "BarnOwl::Style::Default::format_message", "Default style");
     786        $fmt = $self->format_chat($m);
     787    }
     788    $fmt = BarnOwl::Style::boldify($fmt) if $self->should_bold($m);
     789    return $fmt;
     790}
     791
     792sub should_bold {
     793    my $self = shift;
     794    my $m = shift;
     795    return $m->is_personal && $m->direction eq "in";
     796}
     797
     798sub description {"Default style";}
     799
     800BarnOwl::create_style("default", "BarnOwl::Style::Default");
    779801
    780802################################################################################
     
    787809
    788810sub format_login($) {
     811    my $self = shift;
    789812    my $m = shift;
    790813    return sprintf(
     
    798821}
    799822
     823sub format_ping {
     824    my $self = shift;
     825    my $m = shift;
     826    return "\@b(PING) from \@b(" . $m->pretty_sender . ")\n";
     827}
     828
     829sub format_admin {
     830    my $self = shift;
     831    my $m = shift;
     832    return "\@bold(OWL ADMIN)\n" . $self->indent_body($m);
     833}
     834
    800835sub format_chat($) {
     836    my $self = shift;
     837    my $m = shift;
     838    my $header = $self->chat_header($m);
     839    return $header . "\n". $self->indent_body($m);
     840}
     841
     842sub chat_header {
     843    my $self = shift;
    801844    my $m = shift;
    802845    my $header;
     
    819862    }
    820863    $header .= "  " . time_hhmm($m);
     864    $header .= $self->format_sender($m);
     865    return $header;
     866}
     867
     868sub format_sender {
     869    my $self = shift;
     870    my $m = shift;
    821871    my $sender = $m->long_sender;
    822872    $sender =~ s/\n.*$//s;
    823     $header .= " " x (4 - ((length $header) % 4));
    824     $header .= "(" . $sender . '@color[default]' . ")";
    825     my $message = $header . "\n". indentBody($m);
    826     if($m->is_personal && $m->direction eq "in") {
    827         $message = BarnOwl::Style::boldify($message);
    828     }
    829     return $message;
    830 }
    831 
    832 sub indentBody($)
     873    return "  (" . $sender . '@color[default]' . ")";
     874}
     875
     876sub indent_body($)
    833877{
     878    my $self = shift;
    834879    my $m = shift;
    835880
     
    846891}
    847892
     893package BarnOwl::Style::Basic;
     894our @ISA=qw(BarnOwl::Style::Default);
     895
     896sub description {"Compatability alias for the default style";}
     897
     898BarnOwl::create_style("basic", "BarnOwl::Style::Basic");
     899
    848900package BarnOwl::Style::OneLine;
     901# Inherit format_message to dispatch
     902our @ISA = qw(BarnOwl::Style::Default);
     903
     904use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
     905
     906sub description {"Formats for one-line-per-message"}
     907
     908BarnOwl::create_style("oneline", "BarnOwl::Style::OneLine");
     909
    849910################################################################################
    850 # Branching point for various formatting functions in this style.
    851 ################################################################################
    852 use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
    853 sub format_message($) {
    854   my $m = shift;
    855 
    856 #  if ( $m->is_zephyr ) {
    857 #    return format_zephyr($m);
    858 #  }
    859   if ( $m->is_loginout ) {
    860     return format_login($m);
    861   }
    862   elsif ( $m->is_ping) {
    863     return format_ping($m);
    864   }
    865   elsif ( $m->is_admin || $m->is_loopback) {
    866     return format_local($m);
    867   }
    868   else {
    869     return format_chat($m);
    870   }
    871 }
    872 
    873 BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message");
    874 
    875 ################################################################################
    876911
    877912sub format_login($) {
     913  my $self = shift;
    878914  my $m = shift;
    879915  return sprintf(
     
    898934sub format_chat($)
    899935{
     936  my $self = shift;
    900937  my $m = shift;
    901938  my $dir = lc($m->{direction});
     
    911948  if ($m->is_personal) {
    912949    $line= sprintf(BASE_FORMAT,
    913                    $dirsym,
    914                    $m->type,
    915                    '',
    916                    ($dir eq 'out'
    917                       ? $m->pretty_recipient
    918                       : $m->pretty_sender));
     950                   $dirsym,
     951                   $m->type,
     952                   '',
     953                   ($dir eq 'out'
     954                    ? $m->pretty_recipient
     955                    : $m->pretty_sender));
    919956  }
    920957  else {
    921958    $line = sprintf(BASE_FORMAT,
    922                     $dirsym,
    923                     $m->context,
    924                     $m->subcontext,
    925                     ($dir eq 'out'
    926                        ? $m->pretty_recipient
    927                        : $m->pretty_sender));
     959                    $dirsym,
     960                    $m->context,
     961                    $m->subcontext,
     962                    ($dir eq 'out'
     963                     ? $m->pretty_recipient
     964                     : $m->pretty_sender));
    928965  }
    929966
     
    931968  $body =~ tr/\n/ /;
    932969  $line .= $body;
    933   $line = BarnOwl::Style::boldify($line) if ($m->is_personal && lc($m->direction) eq 'in');
    934970  return $line;
    935971}
    936972
    937 # Format locally generated messages
    938 sub format_local($)
     973# Format owl admin messages
     974sub format_admin($)
    939975{
     976  my $self = shift;
    940977  my $m = shift;
    941   my $type = uc($m->{type});
    942   my $line = sprintf(BASE_FORMAT, '<', $type, '', '');
     978  my $line = sprintf(BASE_FORMAT, '<', 'ADMIN', '', '');
    943979  my $body = $m->{body};
    944980  $body =~ tr/\n/ /;
     
    9681004}
    9691005
     1006sub style_command {
     1007    my $command = shift;
     1008    if(scalar @_ != 3 || $_[1] ne 'perl') {
     1009        die("Usage: style <name> perl <function>\n");
     1010    }
     1011    my $name = shift;
     1012    my $perl = shift;
     1013    my $fn   = shift;
     1014    {
     1015        no strict 'refs';
     1016        unless(*{$fn}{CODE}) {
     1017            die("Unable to create style '$name': no perl function '$fn'\n");
     1018        }
     1019    }
     1020    BarnOwl::create_style($name, BarnOwl::Style::Legacy->new($fn));
     1021}
     1022
     1023package BarnOwl::Style::Legacy;
     1024
     1025sub new {
     1026    my $class = shift;
     1027    my $func  = shift;
     1028    my $desc  = shift;
     1029    my $useglobals = shift;
     1030    $useglobals = 0 unless defined($useglobals);
     1031    return bless {function    => $func,
     1032                  description => $desc,
     1033                  useglobals  => $useglobals}, $class;
     1034}
     1035
     1036sub description {
     1037    my $self = shift;
     1038    return $self->{description} ||
     1039    ("User-defined perl style that calls " . $self->{function});
     1040};
     1041
     1042sub format_message {
     1043    my $self = shift;
     1044    if($self->{useglobals}) {
     1045        $_[0]->legacy_populate_global();
     1046    }
     1047    no strict 'refs';
     1048    goto \&{$self->{function}};
     1049}
     1050
    9701051
    9711052# switch to package main when we're done
  • style.c

    r5a9f6fe r864ed35  
     1#define OWL_PERL
    12#include "owl.h"
    23
    34static const char fileIdent[] = "$Id$";
    45
    5 void owl_style_create_internal(owl_style *s, char *name, void (*formatfunc) (owl_fmtext *fm, owl_message *m), char *description)
     6void owl_style_create_perl(owl_style *s, char *name, SV *obj)
    67{
    7   s->type=OWL_STYLE_TYPE_INTERNAL;
    88  s->name=owl_strdup(name);
    9   if (description) {
    10     s->description=owl_strdup(description);
    11   } else {
    12     s->description=owl_sprintf("Owl internal style %s", name);
    13   }
    14   s->perlfuncname=NULL;
    15   s->formatfunc=formatfunc;
    16 }
    17 
    18 void owl_style_create_perl(owl_style *s, char *name, char *perlfuncname, char *description)
    19 {
    20   s->type=OWL_STYLE_TYPE_PERL;
    21   s->name=owl_strdup(name);
    22   s->perlfuncname=owl_strdup(perlfuncname);
    23   if (description) {
    24     s->description=owl_strdup(description);
    25   } else {
    26     s->description=owl_sprintf("User-defined perl style that calls %s",
    27                                perlfuncname);
    28   }
    29   s->formatfunc=NULL;
     9  s->perlobj = SvREFCNT_inc(obj);
    3010}
    3111
     
    4323char *owl_style_get_description(owl_style *s)
    4424{
    45   return(s->description);
     25  SV *sv = NULL;
     26  OWL_PERL_CALL_METHOD(s->perlobj,
     27                       "description",
     28                       /* no args */,
     29                       "Error in style_get_description: %s",
     30                       0,
     31                       sv = SvREFCNT_inc(POPs);
     32                       );
     33  if(sv) {
     34    return SvPV_nolen(sv_2mortal(sv));
     35  } else {
     36    return "[error getting description]";
     37  }
    4638}
    4739
     
    5143void owl_style_get_formattext(owl_style *s, owl_fmtext *fm, owl_message *m)
    5244{
    53   if (s->type==OWL_STYLE_TYPE_INTERNAL) {
    54     (* s->formatfunc)(fm, m);
    55   } else if (s->type==OWL_STYLE_TYPE_PERL) {
    56     char *body, *indent;
    57     int curlen;
     45  char *body, *indent;
     46  int curlen;
    5847
    59     /* run the perl function */
    60     body=owl_perlconfig_getmsg(m, 1, s->perlfuncname);
    61     if (!strcmp(body, "")) {
    62       owl_free(body);
    63       body=owl_strdup("<unformatted message>");
    64     }
    65    
    66     /* indent and ensure ends with a newline */
    67     indent=owl_malloc(strlen(body)+(owl_text_num_lines(body))*OWL_TAB+10);
    68     owl_text_indent(indent, body, OWL_TAB);
    69     curlen = strlen(indent);
    70     if (curlen==0 || indent[curlen-1] != '\n') {
    71       indent[curlen] = '\n';
    72       indent[curlen+1] = '\0';
    73     }
     48  SV *sv = NULL;
     49 
     50  /* Call the perl object */
     51  OWL_PERL_CALL_METHOD(s->perlobj,
     52                       "format_message",
     53                       XPUSHs(owl_perlconfig_message2hashref(m));,
     54                       "Error in format_message: %s",
     55                       0,
     56                       sv = SvREFCNT_inc(POPs);
     57                       );
    7458
    75     /* fmtext_append.  This needs to change */
    76     owl_fmtext_append_ztext(fm, indent);
    77    
    78     owl_free(indent);
    79     owl_free(body);
     59  if(sv) {
     60    body = SvPV_nolen(sv);
     61  } else {
     62    body = "<unformatted message>";
    8063  }
     64
     65  /* indent and ensure ends with a newline */
     66  indent=owl_malloc(strlen(body)+(owl_text_num_lines(body))*OWL_TAB+10);
     67  owl_text_indent(indent, body, OWL_TAB);
     68  curlen = strlen(indent);
     69  if (curlen==0 || indent[curlen-1] != '\n') {
     70    indent[curlen] = '\n';
     71    indent[curlen+1] = '\0';
     72  }
     73
     74  /* fmtext_append.  This needs to change */
     75  owl_fmtext_append_ztext(fm, indent);
     76
     77  owl_free(indent);
     78  if(sv)
     79    SvREFCNT_dec(body);
    8180}
    8281
    8382int owl_style_validate(owl_style *s) {
    84   if (!s) {
    85     return -1;
    86   } else if (s->type==OWL_STYLE_TYPE_INTERNAL) {
    87     return 0;
    88   } else if (s->type==OWL_STYLE_TYPE_PERL
    89              && s->perlfuncname
    90              && owl_perlconfig_is_function(s->perlfuncname)) {
    91     return 0;
    92   } else {
     83  if (!s || !s->perlobj || !SvOK(s->perlobj)) {
    9384    return -1;
    9485  }
     86  return 0;
    9587}
    9688
     
    9890{
    9991  if (s->name) owl_free(s->name);
    100   if (s->description) owl_free(s->description);
    101   if (s->type==OWL_STYLE_TYPE_PERL && s->perlfuncname) {
    102     owl_free(s->perlfuncname);
    103   }
     92  SvREFCNT_dec(s->perlobj);
    10493}
  • svkversion

    r95e60d6 r51f45d1  
    1515$p ||= ".";
    1616
    17 my @lines = `svk info $p`;
     17my @lines = `svk info $p 2>&1`;
     18if($! || $lines[0] =~ "not a checkout path") {
     19    print "exported$newline";
     20    exit;
     21}
    1822my @merged = grep {/^Merged From: /} @lines;
    1923
  • variable.c

    r247cbc9 r52f8dd6  
    273273                 "Some built-in styles include:\n"
    274274                 "   default  - the default owl formatting\n"
    275                  "   basic    - simple formatting\n"
    276275                 "   oneline  - one line per-message\n"
    277276                 "   perl     - legacy perl interface\n"
Note: See TracChangeset for help on using the changeset viewer.