diff options
author | Timo Sirainen <cras@irssi.org> | 2000-11-27 01:23:28 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-11-27 01:23:28 +0000 |
commit | 6aa8af346ca7b326e9ed61c4ccee3f9d2b7c7374 (patch) | |
tree | 771d0cdf0557cdf399ee1f9f8dea187721c88cad /src | |
parent | 0d8239e40e504cb1a4cce5e8d48cc0c7898c6e31 (diff) | |
download | irssi-6aa8af346ca7b326e9ed61c4ccee3f9d2b7c7374.zip |
forgot to add this
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@887 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/perl/common/Themes.xs | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/perl/common/Themes.xs b/src/perl/common/Themes.xs new file mode 100644 index 00000000..d8a140ac --- /dev/null +++ b/src/perl/common/Themes.xs @@ -0,0 +1,117 @@ +MODULE = Irssi PACKAGE = Irssi + +void +theme_register(formats) + SV *formats +PREINIT: + AV *av; + SV *sv; + FORMAT_REC *formatrecs; + char *key, *value; + int len, n, fpos, count; +CODE: + + if (!SvROK(formats)) + croak("formats is not a reference to list"); + av = (AV *) SvRV(formats); + len = av_len(av)+1; + if (len == 0 || (len & 1) != 0) + croak("formats list is invalid - not dividable by 3 (%d)", len); + + formatrecs = g_new0(FORMAT_REC, len/2+2); + formatrecs[fpos].tag = g_strdup(perl_get_package()); + formatrecs[fpos].def = g_strdup("Perl script"); + + for (fpos = 1, n = 0; n < len; n++, fpos++) { + key = SvPV(*av_fetch(av, n, 0), PL_na); n++; + value = SvPV(*av_fetch(av, n, 0), PL_na); + + formatrecs[fpos].tag = g_strdup(key); + formatrecs[fpos].def = g_strdup(value); + formatrecs[fpos].params = MAX_FORMAT_PARAMS; + } + + theme_register_module(perl_get_package(), formatrecs); + +void +printformat(server, target, level, format, ...) + Irssi::Server server + char *target + int level + char *format +PREINIT: + TEXT_DEST_REC dest; + char *arglist[MAX_FORMAT_PARAMS]; + int n; +CODE: + format_create_dest(&dest, server, target, level, NULL); + memset(arglist, 0, sizeof(arglist)); + for (n = 4; n < 4+MAX_FORMAT_PARAMS; n++) { + arglist[n-4] = n < items ? SvPV(ST(n), PL_na) : ""; + } + + printformat_perl(&dest, format, arglist); + +void +printformat_window(window, level, format, ...) + Irssi::Window window + int level + char *format +PREINIT: + TEXT_DEST_REC dest; + char *arglist[MAX_FORMAT_PARAMS]; + int n; +CODE: + format_create_dest(&dest, NULL, NULL, level, window); + memset(arglist, 0, sizeof(arglist)); + for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { + arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : ""; + } + + printformat_perl(&dest, format, arglist); + +#******************************* +MODULE = Irssi PACKAGE = Irssi::Server +#******************************* + +void +printformat(server, target, level, format, ...) + Irssi::Server server + char *target + int level + char *format +PREINIT: + TEXT_DEST_REC dest; + char *arglist[MAX_FORMAT_PARAMS]; + int n; +CODE: + format_create_dest(&dest, server, target, level, NULL); + memset(arglist, 0, sizeof(arglist)); + for (n = 4; n < 4+MAX_FORMAT_PARAMS; n++) { + arglist[n-4] = n < items ? SvPV(ST(n), PL_na) : ""; + } + + printformat_perl(&dest, format, arglist); + +#******************************* +MODULE = Irssi PACKAGE = Irssi::Windowitem +#******************************* + +void +printformat(item, level, format, ...) + Irssi::Windowitem item + int level + char *format +PREINIT: + TEXT_DEST_REC dest; + char *arglist[MAX_FORMAT_PARAMS]; + int n; +CODE: + format_create_dest(&dest, item->server, item->name, level, NULL); + memset(arglist, 0, sizeof(arglist)); + for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { + arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : ""; + } + + printformat_perl(&dest, format, arglist); + |