summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);