summaryrefslogtreecommitdiff
path: root/src/perl/textui
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-24 22:52:15 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-24 22:52:15 +0000
commit2a75c88f99e1aa24fbac81deac007ceca313b993 (patch)
tree5267820ea1eab3c7061056f2e7dbb92f2ace729b /src/perl/textui
parentf7683c0423277dec3ec939cf33c3044658ee48a5 (diff)
downloadirssi-2a75c88f99e1aa24fbac81deac007ceca313b993.zip
Added support for changing indentation behaviour with modules.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1912 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl/textui')
-rw-r--r--src/perl/textui/TextBufferView.xs65
-rw-r--r--src/perl/textui/TextUI.xs2
2 files changed, 64 insertions, 3 deletions
diff --git a/src/perl/textui/TextBufferView.xs b/src/perl/textui/TextBufferView.xs
index dfb1d036..37efc856 100644
--- a/src/perl/textui/TextBufferView.xs
+++ b/src/perl/textui/TextBufferView.xs
@@ -1,17 +1,74 @@
#include "module.h"
+static char *default_indent_func;
+
+static int perl_indent_func(TEXT_BUFFER_VIEW_REC *view,
+ LINE_REC *line, int ypos)
+{
+ dSP;
+ int retcount, ret;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(plain_bless(view, "Irssi::TextUI::TextBufferView")));
+ XPUSHs(sv_2mortal(plain_bless(line, "Irssi::TextUI::Line")));
+ XPUSHs(sv_2mortal(newSViv(ypos)));
+ PUTBACK;
+
+ retcount = perl_call_pv(default_indent_func, G_EVAL|G_DISCARD);
+ SPAGAIN;
+
+ ret = 0;
+ if (SvTRUE(ERRSV)) {
+ STRLEN n_a;
+ char *package;
+
+ package = perl_function_get_package(default_indent_func);
+ signal_emit("script error", 2,
+ perl_script_find_package(package),
+ SvPV(ERRSV, n_a));
+ g_free(package);
+ } else if (retcount > 0) {
+ ret = POPi;
+ }
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ return ret;
+}
+
+void perl_textbuffer_view_init(void)
+{
+ default_indent_func = NULL;
+}
+
+void perl_textbuffer_view_deinit(void)
+{
+ g_free_not_null(default_indent_func);
+}
+
MODULE = Irssi::TextUI::TextBufferView PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
PROTOTYPES: ENABLE
Irssi::TextUI::TextBufferView
-textbuffer_view_create(buffer, width, height, default_indent, longword_noindent, scroll)
+textbuffer_view_create(buffer, width, height, scroll)
Irssi::TextUI::TextBuffer buffer
int width
int height
- int default_indent
- int longword_noindent
int scroll
+void
+gui_windows_set_default_indent_func(func)
+ char *func
+CODE:
+ g_free_not_null(default_indent_func);
+ default_indent_func = g_strdup(func);
+ gui_windows_set_default_indent_func(perl_indent_func);
+
#*******************************
MODULE = Irssi::TextUI::TextBufferView PACKAGE = Irssi::TextUI::TextBufferView PREFIX = textbuffer_view_
#*******************************
@@ -25,6 +82,8 @@ textbuffer_view_set_default_indent(view, default_indent, longword_noindent)
Irssi::TextUI::TextBufferView view
int default_indent
int longword_noindent
+CODE:
+ textbuffer_view_set_default_indent(view, default_indent, longword_noindent, NULL);
void
textbuffer_view_set_scroll(view, scroll)
diff --git a/src/perl/textui/TextUI.xs b/src/perl/textui/TextUI.xs
index c92da84a..9ebd2c6b 100644
--- a/src/perl/textui/TextUI.xs
+++ b/src/perl/textui/TextUI.xs
@@ -96,11 +96,13 @@ CODE:
irssi_add_plains(textui_plains);
perl_statusbar_init();
+ perl_textbuffer_view_init();
void
deinit()
CODE:
perl_statusbar_deinit();
+ perl_textbuffer_view_deinit();
MODULE = Irssi::TextUI PACKAGE = Irssi