Perl fixes and additions. theme_register() / printformat() works now

with scripts


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@884 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-11-26 09:22:18 +00:00 committed by cras
commit 079932c405
10 changed files with 101 additions and 24 deletions

View file

@ -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[] = {