summaryrefslogtreecommitdiff
path: root/src/perl
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-05-13 14:45:54 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-05-13 14:45:54 +0000
commit0a4cedd83dc28ba116491851a3571adce4082504 (patch)
tree05ce1a5c73eb0b0c2ebd22b1a56129284e630c1f /src/perl
parent9c038783a4180fc80794d87c17b856157f8a5359 (diff)
downloadirssi-0a4cedd83dc28ba116491851a3571adce4082504.zip
Added format_create_dest() + $dest->print() functions. here's also our first
magic perl variable - many thanks to Qrczak for helping with it :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2784 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl')
-rw-r--r--src/perl/ui/Formats.xs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/perl/ui/Formats.xs b/src/perl/ui/Formats.xs
index 5c95e56c..d016f07d 100644
--- a/src/perl/ui/Formats.xs
+++ b/src/perl/ui/Formats.xs
@@ -1,5 +1,19 @@
#include "module.h"
+static int magic_free_text_dest(SV *sv, MAGIC *mg)
+{
+ TEXT_DEST_REC *dest = (TEXT_DEST_REC *) mg->mg_ptr;
+ g_free((char *) dest->target);
+ g_free(dest);
+ mg->mg_ptr = NULL;
+ return 0;
+}
+
+static MGVTBL vtbl_free_text_dest =
+{
+ NULL, NULL, NULL, NULL, magic_free_text_dest
+};
+
MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::Window
PROTOTYPES: ENABLE
@@ -43,3 +57,37 @@ PPCODE:
XPUSHs(sv_2mortal(new_pv(ret)));
g_free_not_null(ret);
+
+MODULE = Irssi::UI::Formats PACKAGE = Irssi
+
+void
+format_create_dest(server, target=NULL, level=MSGLEVEL_CLIENTNOTICE, window=NULL)
+ Irssi::Server server
+ char *target
+ int level
+ Irssi::UI::Window window
+PREINIT:
+ TEXT_DEST_REC *dest;
+ SV *sv;
+PPCODE:
+ dest = g_new0(TEXT_DEST_REC, 1);
+ format_create_dest(dest, server, g_strdup(target), level, window);
+
+ sv = plain_bless(dest, "Irssi::UI::TextDest");
+ XPUSHs(sv_2mortal(sv));
+
+ sv = *hv_fetch(hvref(sv), "_irssi", 6, 0);
+ sv_magic(sv, NULL, '~', NULL, 0);
+
+ SvMAGIC(sv)->mg_private = 0x1551; /* HF */
+ SvMAGIC(sv)->mg_virtual = &vtbl_free_text_dest;
+ SvMAGIC(sv)->mg_ptr = (char *) dest;
+
+MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::TextDest
+
+void
+print(dest, str)
+ Irssi::UI::TextDest dest
+ char *str
+CODE:
+ printtext_dest(dest, str);