diff options
Diffstat (limited to 'src/perl/perl-common.c')
-rw-r--r-- | src/perl/perl-common.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index d20d3ab4..d6e6192d 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -39,8 +39,20 @@ #include "perl-common.h" +#include "fe-common/core/formats.h" +#include "fe-common/core/printtext.h" + GHashTable *perl_stashes; +/* returns the package who called us */ +char *perl_get_package(void) +{ + STRLEN n_a; + + perl_eval_pv("($package) = caller;", TRUE); + return SvPV(perl_get_sv("package", FALSE), n_a); +} + HV *irssi_get_stash_item(int type, int chat_type) { char *str; @@ -157,6 +169,26 @@ void perl_query_fill_hash(HV *hv, QUERY_REC *query) hv_store(hv, "unwanted", 8, newSViv(query->unwanted), 0); } +void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist) +{ + THEME_REC *theme; + char *module, *str; + int formatnum; + + module = g_strdup(perl_get_package()); + theme = dest->window->theme == NULL ? current_theme : + dest->window->theme; + + formatnum = format_find_tag(module, format); + signal_emit("print format", 5, theme, module, + &dest, GINT_TO_POINTER(formatnum), arglist); + + str = format_get_text_theme_charargs(theme, module, dest, formatnum, arglist); + if (*str != '\0') printtext_window(dest->window, dest->level, "%s", str); + g_free(str); + g_free(module); +} + static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) { static char *items[] = { |