Changeset f6b319c


Ignore:
Timestamp:
Apr 29, 2007, 6:27:30 PM (17 years ago)
Author:
Sam Hartman <hartmans@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:
d791cdb
Parents:
03cf6b9
Message:
Implement hackish support for the wordwrap filter in the perl styles.
Note that while I think the user-visible parts of this are reasonably
OK the implementation needs cleanup.


* perlconfig.c: Add should_wordwrap attribute to message hashes.  This
   is a hack; a better solution is to expose an arbitrary interface for
   doing filter matches from perl.  That proved to be more than I had
   time for.
* perlglue.xs: expose owl_text_wordwrap
* perlwrap.pm: use in the default style
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    r0337203 rf6b319c  
    3333  int i, j;
    3434  owl_pair *pair;
     35  owl_filter *wrap;
    3536
    3637  if (!m) return &PL_sv_undef;
     38  wrap = owl_global_get_filter(&g, "wordwrap");
     39  if(!wrap) {
     40      owl_function_error("wrap filter is not defined");
     41      return &PL_sv_undef;
     42  }
     43
    3744  h = newHV();
    3845
     
    8592  hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
    8693  hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
     94  hv_store(h, "should_wordwrap",
     95           strlen("should_wordwrap"), newSViv(
     96                                              owl_filter_message_match(wrap, m)),0);
    8797
    8898  type = owl_message_get_type(m);
  • perlglue.xs

    rc2c5c77 rf6b319c  
    315315                }
    316316        }
     317
     318char *
     319wordwrap(in, cols)
     320        char *in
     321        int cols
     322        PREINIT:
     323                char *rv = NULL;
     324        CODE:
     325rv = owl_text_wordwrap(in, cols);
     326                RETVAL = rv;   
     327        OUTPUT:
     328                RETVAL
     329        CLEANUP:
     330                if (rv) owl_free(rv);
  • perlwrap.pm

    r1cf32e7d rf6b319c  
    418418            BarnOwl::ModuleLoader->load_all;
    419419        };
    420         BarnOwl::error("Error loading modules: $@") if $@;
     420        BarnOwl::error("$@") if $@;
     421open TMP, ">/tmp/error";
     422print TMP $@;
     423
    421424    } else {
    422425        BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@");
     
    528531
    529532    my $body = $m->body;
     533    if ($m->{should_wordwrap}) {
     534      $body = BarnOwl::wordwrap($body, BarnOwl::getnumcols()-8);
     535    }
    530536    # replace newline followed by anything with
    531537    # newline plus four spaces and that thing.
Note: See TracChangeset for help on using the changeset viewer.