summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/perl/Makefile.am7
-rw-r--r--src/perl/textui/.cvsignore7
-rw-r--r--src/perl/textui/Makefile.PL.in7
-rw-r--r--src/perl/textui/TextBuffer.xs80
-rw-r--r--src/perl/textui/TextBufferView.xs98
-rw-r--r--src/perl/textui/TextUI.pm24
-rw-r--r--src/perl/textui/TextUI.xs97
-rw-r--r--src/perl/textui/module.h14
-rw-r--r--src/perl/textui/typemap18
9 files changed, 349 insertions, 3 deletions
diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am
index db381053..8ac1ffa7 100644
--- a/src/perl/Makefile.am
+++ b/src/perl/Makefile.am
@@ -118,7 +118,7 @@ EXTRA_DIST = \
$(UI_SOURCES)
all-local:
- for dir in common irc ui; do \
+ for dir in common irc ui textui; do \
cd $$dir && \
if [ ! -f Makefile ]; then \
$(perlpath) Makefile.PL $(PERL_MM_PARAMS); \
@@ -128,16 +128,17 @@ all-local:
done
install-exec-local:
- for dir in common irc ui; do \
+ for dir in common irc ui textui; do \
cd $$dir && $(MAKE) install && cd ..; \
done
clean-generic:
- rm -f common/Makefile irc/Makefile ui/Makefile
+ rm -f common/Makefile irc/Makefile ui/Makefile textui/Makefile
distclean: distclean-am
-(cd common && $(MAKE) realclean && rm -f Makefile.PL)
-(cd irc && $(MAKE) realclean && rm -f Makefile.PL)
-(cd ui && $(MAKE) realclean && rm -f Makefile.PL)
+ -(cd textui && $(MAKE) realclean && rm -f Makefile.PL)
libperl_core_la_LIBADD = $(PERL_LDFLAGS)
diff --git a/src/perl/textui/.cvsignore b/src/perl/textui/.cvsignore
new file mode 100644
index 00000000..e6c0f856
--- /dev/null
+++ b/src/perl/textui/.cvsignore
@@ -0,0 +1,7 @@
+Makefile
+Makefile.PL
+TextUI.c
+TextUI.bs
+*.o
+pm_to_blib
+blib
diff --git a/src/perl/textui/Makefile.PL.in b/src/perl/textui/Makefile.PL.in
new file mode 100644
index 00000000..8b5a2b6c
--- /dev/null
+++ b/src/perl/textui/Makefile.PL.in
@@ -0,0 +1,7 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile('NAME' => 'Irssi::TextUI',
+ 'LIBS' => '',
+ 'TYPEMAPS' => ['../common/typemap', '../ui/typemap'],
+ 'INC' => '-I../../.. -I@top_srcdir@/src -I@top_srcdir@/src/core -I@top_srcdir@/src/fe-common/core -I@top_srcdir@/src/fe-text @GLIB_CFLAGS@',
+ 'VERSION_FROM' => '@srcdir@/TextUI.pm');
diff --git a/src/perl/textui/TextBuffer.xs b/src/perl/textui/TextBuffer.xs
new file mode 100644
index 00000000..83b1582c
--- /dev/null
+++ b/src/perl/textui/TextBuffer.xs
@@ -0,0 +1,80 @@
+MODULE = Irssi::TextUI PACKAGE = Irssi
+
+Irssi::TextUI::TextBuffer
+textbuffer_create()
+
+#*******************************
+MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
+#*******************************
+
+void
+textbuffer_destroy(buffer)
+ Irssi::TextUI::TextBuffer buffer
+
+Irssi::TextUI::Line
+textbuffer_append(buffer, data, len, info)
+ Irssi::TextUI::TextBuffer buffer
+ char *data
+ int len
+ Irssi::TextUI::LineInfo info
+
+Irssi::TextUI::Line
+textbuffer_insert(buffer, insert_after, data, len, info)
+ Irssi::TextUI::TextBuffer buffer
+ Irssi::TextUI::Line insert_after
+ char *data
+ int len
+ Irssi::TextUI::LineInfo info
+
+void
+textbuffer_remove(buffer, line)
+ Irssi::TextUI::TextBuffer buffer
+ Irssi::TextUI::Line line
+
+void
+textbuffer_remove_all_lines(buffer)
+ Irssi::TextUI::TextBuffer buffer
+
+#*******************************
+MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::Line PREFIX = textbuffer_line_
+#*******************************
+
+Irssi::TextUI::Line
+textbuffer_line_prev(line)
+ Irssi::TextUI::Line line
+CODE:
+ RETVAL = line->prev;
+OUTPUT:
+ RETVAL
+
+Irssi::TextUI::Line
+textbuffer_line_next(line)
+ Irssi::TextUI::Line line
+CODE:
+ RETVAL = line->next;
+OUTPUT:
+ RETVAL
+
+void
+textbuffer_line_ref(line)
+ Irssi::TextUI::Line line
+
+void
+textbuffer_line_unref(line, buffer)
+ Irssi::TextUI::Line line
+ Irssi::TextUI::TextBuffer buffer
+CODE:
+ textbuffer_line_unref(buffer, line);
+
+void
+textbuffer_line_get_text(line, coloring)
+ Irssi::TextUI::Line line
+ int coloring
+PREINIT:
+ GString *str;
+PPCODE:
+ str = g_string_new(NULL);
+ textbuffer_line2text(line, coloring, str);
+ XPUSHs(sv_2mortal(new_pv(str->str)));
+ g_string_free(str, TRUE);
+
diff --git a/src/perl/textui/TextBufferView.xs b/src/perl/textui/TextBufferView.xs
new file mode 100644
index 00000000..70c04165
--- /dev/null
+++ b/src/perl/textui/TextBufferView.xs
@@ -0,0 +1,98 @@
+MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
+
+Irssi::TextUI::TextBufferView
+textbuffer_view_create(buffer, width, height, default_indent, longword_noindent)
+ Irssi::TextUI::TextBuffer buffer
+ int width
+ int height
+ int default_indent
+ int longword_noindent
+
+#*******************************
+MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBufferView PREFIX = textbuffer_view_
+#*******************************
+
+void
+textbuffer_view_destroy(view)
+ Irssi::TextUI::TextBufferView view
+
+void
+textbuffer_view_set_default_indent(view, default_indent, longword_noindent)
+ Irssi::TextUI::TextBufferView view
+ int default_indent
+ int longword_noindent
+
+void
+textbuffer_view_resize(view, width, height)
+ Irssi::TextUI::TextBufferView view
+ int width
+ int height
+
+void
+textbuffer_view_clear(view)
+ Irssi::TextUI::TextBufferView view
+
+void
+textbuffer_view_get_lines(view)
+ Irssi::TextUI::TextBufferView view
+
+void
+textbuffer_view_scroll(view, lines)
+ Irssi::TextUI::TextBufferView view
+ int lines
+
+void
+textbuffer_view_scroll_line(view, line)
+ Irssi::TextUI::TextBufferView view
+ Irssi::TextUI::Line line
+
+Irssi::TextUI::LineCache
+textbuffer_view_get_line_cache(view, line)
+ Irssi::TextUI::TextBufferView view
+ Irssi::TextUI::Line line
+
+void
+textbuffer_view_insert_line(view, line)
+ Irssi::TextUI::TextBufferView view
+ Irssi::TextUI::Line line
+
+void
+textbuffer_view_remove_line(view, line)
+ Irssi::TextUI::TextBufferView view
+ Irssi::TextUI::Line line
+
+void
+textbuffer_view_remove_all_lines(view)
+ Irssi::TextUI::TextBufferView view
+
+void
+textbuffer_view_set_bookmark(view, name, line)
+ Irssi::TextUI::TextBufferView view
+ char *name
+ Irssi::TextUI::Line line
+
+void
+textbuffer_view_set_bookmark_bottom(view, name);
+ Irssi::TextUI::TextBufferView view
+ char *name
+
+Irssi::TextUI::Line
+textbuffer_view_get_bookmark(view, name);
+ Irssi::TextUI::TextBufferView view
+ char *name
+
+void
+textbuffer_view_redraw(view)
+ Irssi::TextUI::TextBufferView view
+
+#*******************************
+MODULE = Irssi::TextUI PACKAGE = Irssi::UI::Window
+#*******************************
+
+Irssi::TextUI::TextBufferView
+view(window)
+ Irssi::UI::Window window
+CODE:
+ RETVAL = WINDOW_GUI(window)->view;
+OUTPUT:
+ RETVAL
diff --git a/src/perl/textui/TextUI.pm b/src/perl/textui/TextUI.pm
new file mode 100644
index 00000000..df7e8674
--- /dev/null
+++ b/src/perl/textui/TextUI.pm
@@ -0,0 +1,24 @@
+#
+# Perl interface to irssi functions.
+#
+
+package Irssi::TextUI;
+
+use strict;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+
+$VERSION = "0.20";
+
+require Exporter;
+require DynaLoader;
+
+@ISA = qw(Exporter DynaLoader);
+@EXPORT = qw();
+@EXPORT_OK = qw();
+
+bootstrap Irssi::TextUI $VERSION;
+
+Irssi::TextUI::init();
+
+1;
+
diff --git a/src/perl/textui/TextUI.xs b/src/perl/textui/TextUI.xs
new file mode 100644
index 00000000..e003b49c
--- /dev/null
+++ b/src/perl/textui/TextUI.xs
@@ -0,0 +1,97 @@
+#include "module.h"
+
+static void perl_main_window_fill_hash(HV *hv, MAIN_WINDOW_REC *window)
+{
+ hv_store(hv, "active", 6, plain_bless(window->active, "Irssi::UI::Window"), 0);
+
+ hv_store(hv, "first_line", 10, newSViv(window->first_line), 0);
+ hv_store(hv, "last_line", 9, newSViv(window->last_line), 0);
+ hv_store(hv, "width", 5, newSViv(window->width), 0);
+ hv_store(hv, "height", 6, newSViv(window->height), 0);
+
+ hv_store(hv, "statusbar_lines", 15, newSViv(window->statusbar_lines), 0);
+}
+
+static void perl_text_buffer_fill_hash(HV *hv, TEXT_BUFFER_REC *buffer)
+{
+ hv_store(hv, "first_line", 10, plain_bless(buffer->first_line, "Irssi::TextUI::Line"), 0);
+ hv_store(hv, "lines_count", 11, newSViv(buffer->lines_count), 0);
+ hv_store(hv, "cur_line", 8, plain_bless(buffer->cur_line, "Irssi::TextUI::Line"), 0);
+ hv_store(hv, "last_eol", 8, newSViv(buffer->last_eol), 0);
+}
+
+static void perl_text_buffer_view_fill_hash(HV *hv, TEXT_BUFFER_VIEW_REC *view)
+{
+ hv_store(hv, "buffer", 6, plain_bless(view->buffer, "Irssi::TextUI::TextBuffer"), 0);
+ hv_store(hv, "width", 5, newSViv(view->width), 0);
+ hv_store(hv, "height", 6, newSViv(view->height), 0);
+
+ hv_store(hv, "default_indent", 14, newSViv(view->default_indent), 0);
+ hv_store(hv, "longword_noindent", 17, newSViv(view->longword_noindent), 0);
+
+ hv_store(hv, "ypos", 4, newSViv(view->ypos), 0);
+
+ hv_store(hv, "startline", 9, plain_bless(view->startline, "Irssi::TextUI::Line"), 0);
+ hv_store(hv, "subline", 7, newSViv(view->subline), 0);
+
+ hv_store(hv, "bottom_startline", 16, plain_bless(view->bottom_startline, "Irssi::TextUI::Line"), 0);
+ hv_store(hv, "bottom_subline", 14, newSViv(view->bottom_subline), 0);
+
+ hv_store(hv, "empty_linecount", 15, newSViv(view->empty_linecount), 0);
+ hv_store(hv, "bottom", 6, newSViv(view->bottom), 0);
+}
+
+static void perl_line_fill_hash(HV *hv, LINE_REC *line)
+{
+ hv_store(hv, "refcount", 8, newSViv(line->refcount), 0);
+ hv_store(hv, "info", 4, plain_bless(&line->info, "Irssi::TextUI::LineInfo"), 0);
+}
+
+static void perl_line_cache_fill_hash(HV *hv, LINE_CACHE_REC *cache)
+{
+ hv_store(hv, "last_access", 11, newSViv(cache->last_access), 0);
+ hv_store(hv, "count", 5, newSViv(cache->count), 0);
+ /*LINE_CACHE_SUB_REC lines[1];*/
+}
+
+static void perl_line_info_fill_hash(HV *hv, LINE_INFO_REC *info)
+{
+ hv_store(hv, "level", 5, newSViv(info->level), 0);
+ hv_store(hv, "time", 4, newSViv(info->time), 0);
+}
+
+static PLAIN_OBJECT_INIT_REC textui_plains[] = {
+ { "Irssi::TextUI::MainWindow", (PERL_OBJECT_FUNC) perl_main_window_fill_hash },
+ { "Irssi::TextUI::TextBuffer", (PERL_OBJECT_FUNC) perl_text_buffer_fill_hash },
+ { "Irssi::TextUI::TextBufferView", (PERL_OBJECT_FUNC) perl_text_buffer_view_fill_hash },
+ { "Irssi::TextUI::Line", (PERL_OBJECT_FUNC) perl_line_fill_hash },
+ { "Irssi::TextUI::LineCache", (PERL_OBJECT_FUNC) perl_line_cache_fill_hash },
+ { "Irssi::TextUI::LineInfo", (PERL_OBJECT_FUNC) perl_line_info_fill_hash },
+
+ { NULL, NULL }
+};
+
+MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI
+
+PROTOTYPES: ENABLE
+
+void
+init()
+PREINIT:
+ static int initialized = FALSE;
+CODE:
+ if (initialized) return;
+ initialized = TRUE;
+
+ irssi_add_plains(textui_plains);
+
+MODULE = Irssi::TextUI PACKAGE = Irssi
+
+void
+gui_printtext(xpos, ypos, str)
+ int xpos
+ int ypos
+ char *str
+
+INCLUDE: TextBuffer.xs
+INCLUDE: TextBufferView.xs
diff --git a/src/perl/textui/module.h b/src/perl/textui/module.h
new file mode 100644
index 00000000..239b0b02
--- /dev/null
+++ b/src/perl/textui/module.h
@@ -0,0 +1,14 @@
+#include "../ui/module.h"
+
+#include "mainwindows.h"
+#include "gui-windows.h"
+#include "gui-printtext.h"
+#include "textbuffer.h"
+#include "textbuffer-view.h"
+
+typedef MAIN_WINDOW_REC *Irssi__TextUI__MainWindow;
+typedef TEXT_BUFFER_REC *Irssi__TextUI__TextBuffer;
+typedef TEXT_BUFFER_VIEW_REC *Irssi__TextUI__TextBufferView;
+typedef LINE_REC *Irssi__TextUI__Line;
+typedef LINE_CACHE_REC *Irssi__TextUI__LineCache;
+typedef LINE_INFO_REC *Irssi__TextUI__LineInfo;
diff --git a/src/perl/textui/typemap b/src/perl/textui/typemap
new file mode 100644
index 00000000..a31b6478
--- /dev/null
+++ b/src/perl/textui/typemap
@@ -0,0 +1,18 @@
+TYPEMAP
+Irssi::TextUI::MainWindow T_PlainObj
+Irssi::TextUI::TextBuffer T_PlainObj
+Irssi::TextUI::TextBufferView T_PlainObj
+Irssi::TextUI::Line T_PlainObj
+Irssi::TextUI::LineCache T_PlainObj
+Irssi::TextUI::LineInfo T_PlainObj
+
+INPUT
+
+T_PlainObj
+ $var = irssi_ref_object($arg)
+
+OUTPUT
+
+T_PlainObj
+ $arg = plain_bless($var, \"$type\");
+