summaryrefslogtreecommitdiff
path: root/src/perl/ui/Themes.xs
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-06-27 22:56:17 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-06-27 22:56:17 +0000
commit89d7498019b64ae5f89b6f09f32aaa9d876a9da3 (patch)
tree1b289e5394b6dc0db092459fbabaaf049b285715 /src/perl/ui/Themes.xs
parentd7342a6c4fac7956ddef141c8a2f88a1e7b0378c (diff)
downloadirssi-89d7498019b64ae5f89b6f09f32aaa9d876a9da3.zip
Moved fe_perl module to use Irssi::UI .. this breaks several scripts that
use UI-specific code, but simply adding the "use Irssi::UI;" after use Irssi; should work. make install now removes libfe_perl.* files from global module directory, but if you have it somewhere else you should manually remove it. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1582 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl/ui/Themes.xs')
-rw-r--r--src/perl/ui/Themes.xs124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs
new file mode 100644
index 00000000..427952ff
--- /dev/null
+++ b/src/perl/ui/Themes.xs
@@ -0,0 +1,124 @@
+
+MODULE = Irssi::UI PACKAGE = Irssi
+
+void
+theme_register(formats)
+ SV *formats
+PREINIT:
+ STRLEN n_a;
+ AV *av;
+ FORMAT_REC *formatrecs;
+ char *key, *value;
+ int len, n, fpos;
+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[0].tag = g_strdup(perl_get_package());
+ formatrecs[0].def = g_strdup("Perl script");
+
+ for (fpos = 1, n = 0; n < len; n++, fpos++) {
+ key = SvPV(*av_fetch(av, n, 0), n_a); n++;
+ value = SvPV(*av_fetch(av, n, 0), n_a);
+
+ 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(level, format, ...)
+ int level
+ char *format
+PREINIT:
+ STRLEN n_a;
+ TEXT_DEST_REC dest;
+ char *arglist[MAX_FORMAT_PARAMS];
+ int n;
+CODE:
+ format_create_dest(&dest, NULL, NULL, level, NULL);
+ memset(arglist, 0, sizeof(arglist));
+ for (n = 2; n < 2+MAX_FORMAT_PARAMS; n++) {
+ arglist[n-2] = n < items ? SvPV(ST(n), n_a) : "";
+ }
+
+ printformat_perl(&dest, format, arglist);
+
+#*******************************
+MODULE = Irssi::UI PACKAGE = Irssi::Server
+#*******************************
+
+void
+printformat(server, target, level, format, ...)
+ Irssi::Server server
+ char *target
+ int level
+ char *format
+PREINIT:
+ STRLEN n_a;
+ 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), n_a) : "";
+ }
+
+ printformat_perl(&dest, format, arglist);
+
+#*******************************
+MODULE = Irssi::UI PACKAGE = Irssi::UI::Window
+#*******************************
+
+void
+printformat(window, level, format, ...)
+ Irssi::UI::Window window
+ int level
+ char *format
+PREINIT:
+ STRLEN n_a;
+ 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), n_a) : "";
+ }
+
+ printformat_perl(&dest, format, arglist);
+
+#*******************************
+MODULE = Irssi::UI PACKAGE = Irssi::Windowitem
+#*******************************
+
+void
+printformat(item, level, format, ...)
+ Irssi::Windowitem item
+ int level
+ char *format
+PREINIT:
+ STRLEN n_a;
+ 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), n_a) : "";
+ }
+
+ printformat_perl(&dest, format, arglist);
+