mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #14 from ailin-nemui/perl-draw-mod
Allow access to "gui render line text" from Perl
This commit is contained in:
commit
a6722f5c71
@ -358,6 +358,9 @@ gui-printtext.c:
|
|||||||
textbuffer-view.c
|
textbuffer-view.c
|
||||||
"gui textbuffer line removed", TEXTBUFFER_VIEW_REC *view, LINE_REC *line, LINE_REC *prev_line
|
"gui textbuffer line removed", TEXTBUFFER_VIEW_REC *view, LINE_REC *line, LINE_REC *prev_line
|
||||||
|
|
||||||
|
textbuffer-formats.c
|
||||||
|
"gui render line text", TEXT_DEST_REC, GString *str, LINE_INFO_META_REC
|
||||||
|
|
||||||
Perl
|
Perl
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
||||||
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
||||||
|
|
||||||
#define IRSSI_ABI_VERSION 37
|
#define IRSSI_ABI_VERSION 38
|
||||||
|
|
||||||
#define DEFAULT_SERVER_ADD_PORT 6667
|
#define DEFAULT_SERVER_ADD_PORT 6667
|
||||||
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
||||||
|
@ -19,6 +19,8 @@ while (<>) {
|
|||||||
s/GList \* of ([^,]*)s/glistptr_\1/g;
|
s/GList \* of ([^,]*)s/glistptr_\1/g;
|
||||||
s/GSList of ([^,]*)s/gslist_\1/g;
|
s/GSList of ([^,]*)s/gslist_\1/g;
|
||||||
|
|
||||||
|
s/GString \*[^,]*/gstring/g;
|
||||||
|
|
||||||
s/char \*[^,]*/string/g;
|
s/char \*[^,]*/string/g;
|
||||||
s/ulong \*[^,]*/ulongptr/g;
|
s/ulong \*[^,]*/ulongptr/g;
|
||||||
s/int \*[^,]*/intptr/g;
|
s/int \*[^,]*/intptr/g;
|
||||||
@ -56,6 +58,7 @@ while (<>) {
|
|||||||
KEYINFO_REC => 'Irssi::UI::Keyinfo',
|
KEYINFO_REC => 'Irssi::UI::Keyinfo',
|
||||||
PROCESS_REC => 'Irssi::UI::Process',
|
PROCESS_REC => 'Irssi::UI::Process',
|
||||||
TEXT_DEST_REC => 'Irssi::UI::TextDest',
|
TEXT_DEST_REC => 'Irssi::UI::TextDest',
|
||||||
|
LINE_INFO_META_REC => 'Irssi::UI::LineInfoMeta',
|
||||||
WINDOW_REC => 'Irssi::UI::Window',
|
WINDOW_REC => 'Irssi::UI::Window',
|
||||||
WI_ITEM_REC => 'iobject',
|
WI_ITEM_REC => 'iobject',
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
|
|||||||
unsigned long v_ulong;
|
unsigned long v_ulong;
|
||||||
GSList *v_gslist;
|
GSList *v_gslist;
|
||||||
GList *v_glist;
|
GList *v_glist;
|
||||||
|
GString *v_gstring;
|
||||||
} saved_args[SIGNAL_MAX_ARGUMENTS];
|
} saved_args[SIGNAL_MAX_ARGUMENTS];
|
||||||
AV *aargs;
|
AV *aargs;
|
||||||
void *p[SIGNAL_MAX_ARGUMENTS];
|
void *p[SIGNAL_MAX_ARGUMENTS];
|
||||||
@ -146,6 +147,12 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
|
|||||||
} else if (g_strcmp0(rec->args[n], "intptr") == 0) {
|
} else if (g_strcmp0(rec->args[n], "intptr") == 0) {
|
||||||
saved_args[n].v_int = SvIV(SvRV(arg));
|
saved_args[n].v_int = SvIV(SvRV(arg));
|
||||||
c_arg = &saved_args[n].v_int;
|
c_arg = &saved_args[n].v_int;
|
||||||
|
} else if (g_strcmp0(rec->args[n], "gstring") == 0) {
|
||||||
|
char *pv;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
pv = SvPV(SvRV(arg), len);
|
||||||
|
c_arg = saved_args[n].v_gstring = g_string_new_len(pv, len);
|
||||||
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
||||||
GList *gl;
|
GList *gl;
|
||||||
int is_str;
|
int is_str;
|
||||||
@ -220,6 +227,16 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg,
|
|||||||
SV *t = SvRV(arg);
|
SV *t = SvRV(arg);
|
||||||
SvIOK_only(t);
|
SvIOK_only(t);
|
||||||
SvIV_set(t, saved_args[n].v_int);
|
SvIV_set(t, saved_args[n].v_int);
|
||||||
|
} else if (g_strcmp0(rec->args[n], "gstring") == 0) {
|
||||||
|
GString *str;
|
||||||
|
SV *t;
|
||||||
|
|
||||||
|
str = saved_args[n].v_gstring;
|
||||||
|
t = SvRV(arg);
|
||||||
|
SvPOK_only(t);
|
||||||
|
sv_setpvn(t, str->str, str->len);
|
||||||
|
|
||||||
|
g_string_free(str, TRUE);
|
||||||
} else if (strncmp(rec->args[n], "gslist_", 7) == 0) {
|
} else if (strncmp(rec->args[n], "gslist_", 7) == 0) {
|
||||||
g_slist_free(saved_args[n].v_gslist);
|
g_slist_free(saved_args[n].v_gslist);
|
||||||
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
||||||
@ -306,7 +323,10 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func,
|
|||||||
perlarg = newSViv(*(unsigned long *) arg);
|
perlarg = newSViv(*(unsigned long *) arg);
|
||||||
else if (g_strcmp0(rec->args[n], "intptr") == 0)
|
else if (g_strcmp0(rec->args[n], "intptr") == 0)
|
||||||
saved_args[n] = perlarg = newRV_noinc(newSViv(*(int *) arg));
|
saved_args[n] = perlarg = newRV_noinc(newSViv(*(int *) arg));
|
||||||
else if (g_strcmp0(rec->args[n], "formatnum_args") == 0 && n >= 3) {
|
else if (g_strcmp0(rec->args[n], "gstring") == 0) {
|
||||||
|
GString *str = arg;
|
||||||
|
saved_args[n] = perlarg = newRV_noinc(newSVpvn(str->str, str->len));
|
||||||
|
} else if (g_strcmp0(rec->args[n], "formatnum_args") == 0 && n >= 3) {
|
||||||
const THEME_REC *theme;
|
const THEME_REC *theme;
|
||||||
const MODULE_THEME_REC *rec;
|
const MODULE_THEME_REC *rec;
|
||||||
const FORMAT_REC *formats;
|
const FORMAT_REC *formats;
|
||||||
@ -399,6 +419,7 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func,
|
|||||||
|
|
||||||
if (SvTRUE(ERRSV)) {
|
if (SvTRUE(ERRSV)) {
|
||||||
char *error = g_strdup(SvPV_nolen(ERRSV));
|
char *error = g_strdup(SvPV_nolen(ERRSV));
|
||||||
|
perl_signal_remove_script(script);
|
||||||
signal_emit("script error", 2, script, error);
|
signal_emit("script error", 2, script, error);
|
||||||
g_free(error);
|
g_free(error);
|
||||||
rec = NULL;
|
rec = NULL;
|
||||||
@ -415,6 +436,19 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func,
|
|||||||
if (g_strcmp0(rec->args[n], "intptr") == 0) {
|
if (g_strcmp0(rec->args[n], "intptr") == 0) {
|
||||||
int *val = arg;
|
int *val = arg;
|
||||||
*val = SvIV(SvRV(saved_args[n]));
|
*val = SvIV(SvRV(saved_args[n]));
|
||||||
|
} else if (g_strcmp0(rec->args[n], "gstring") == 0) {
|
||||||
|
SV *os, *ns;
|
||||||
|
GString *str = arg;
|
||||||
|
|
||||||
|
os = sv_2mortal(newSVpvn(str->str, str->len));
|
||||||
|
ns = SvRV(saved_args[n]);
|
||||||
|
if (sv_cmp(os, ns) != 0) {
|
||||||
|
size_t len;
|
||||||
|
char *pv = SvPV(ns, len);
|
||||||
|
|
||||||
|
g_string_truncate(str, 0);
|
||||||
|
g_string_append_len(str, pv, len);
|
||||||
|
}
|
||||||
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
} else if (strncmp(rec->args[n], "glistptr_", 9) == 0) {
|
||||||
GList **ret = arg;
|
GList **ret = arg;
|
||||||
GList *out = NULL;
|
GList *out = NULL;
|
||||||
|
@ -83,6 +83,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec)
|
|||||||
|
|
||||||
if (SvTRUE(ERRSV)) {
|
if (SvTRUE(ERRSV)) {
|
||||||
char *error = g_strdup(SvPV_nolen(ERRSV));
|
char *error = g_strdup(SvPV_nolen(ERRSV));
|
||||||
|
perl_source_remove_script(rec->script);
|
||||||
signal_emit("script error", 2, rec->script, error);
|
signal_emit("script error", 2, rec->script, error);
|
||||||
g_free(error);
|
g_free(error);
|
||||||
}
|
}
|
||||||
|
@ -101,30 +101,10 @@ PPCODE:
|
|||||||
}
|
}
|
||||||
XPUSHs(sv_2mortal(newRV_noinc((SV *) hv)));
|
XPUSHs(sv_2mortal(newRV_noinc((SV *) hv)));
|
||||||
|
|
||||||
void
|
Irssi::UI::LineInfoMeta
|
||||||
textbuffer_line_get_meta(line)
|
textbuffer_line_get_meta(line)
|
||||||
Irssi::TextUI::Line line
|
Irssi::TextUI::Line line
|
||||||
PREINIT:
|
CODE:
|
||||||
HV *hv;
|
RETVAL = line->line->info.meta;
|
||||||
LINE_REC *l;
|
OUTPUT:
|
||||||
LINE_INFO_META_REC *m;
|
RETVAL
|
||||||
GHashTableIter iter;
|
|
||||||
char *key;
|
|
||||||
char *val;
|
|
||||||
PPCODE:
|
|
||||||
hv = newHV();
|
|
||||||
l = line->line;
|
|
||||||
if (l->info.meta != NULL) {
|
|
||||||
m = l->info.meta;
|
|
||||||
if (m->hash != NULL) {
|
|
||||||
g_hash_table_iter_init(&iter, m->hash);
|
|
||||||
while (
|
|
||||||
g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) {
|
|
||||||
(void) hv_store(hv, key, strlen(key), new_pv(val), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m->server_time) {
|
|
||||||
(void) hv_store(hv, "server_time", 11, newSViv(m->server_time), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XPUSHs(sv_2mortal(newRV_noinc((SV *) hv)));
|
|
||||||
|
@ -64,6 +64,26 @@ static void perl_text_dest_fill_hash(HV *hv, TEXT_DEST_REC *dest)
|
|||||||
(void) hv_store(hv, "hilight_color", 13, new_pv(dest->hilight_color), 0);
|
(void) hv_store(hv, "hilight_color", 13, new_pv(dest->hilight_color), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void perl_line_info_meta_fill_hash(HV *hv, LINE_INFO_META_REC *meta)
|
||||||
|
{
|
||||||
|
GHashTableIter iter;
|
||||||
|
char *key;
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
if (meta != NULL) {
|
||||||
|
if (meta->hash != NULL) {
|
||||||
|
g_hash_table_iter_init(&iter, meta->hash);
|
||||||
|
while (
|
||||||
|
g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) {
|
||||||
|
(void) hv_store(hv, key, strlen(key), new_pv(val), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (meta->server_time) {
|
||||||
|
(void) hv_store(hv, "server_time", 11, newSViv(meta->server_time), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void perl_exec_fill_hash(HV *hv, EXEC_WI_REC *item)
|
static void perl_exec_fill_hash(HV *hv, EXEC_WI_REC *item)
|
||||||
{
|
{
|
||||||
g_return_if_fail(hv != NULL);
|
g_return_if_fail(hv != NULL);
|
||||||
@ -81,6 +101,7 @@ static PLAIN_OBJECT_INIT_REC fe_plains[] = {
|
|||||||
{ "Irssi::UI::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash },
|
{ "Irssi::UI::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash },
|
||||||
{ "Irssi::UI::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },
|
{ "Irssi::UI::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },
|
||||||
{ "Irssi::UI::TextDest", (PERL_OBJECT_FUNC) perl_text_dest_fill_hash },
|
{ "Irssi::UI::TextDest", (PERL_OBJECT_FUNC) perl_text_dest_fill_hash },
|
||||||
|
{ "Irssi::UI::LineInfoMeta", (PERL_OBJECT_FUNC) perl_line_info_meta_fill_hash },
|
||||||
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
@ -12,3 +12,4 @@ typedef WINDOW_REC *Irssi__UI__Window;
|
|||||||
typedef TEXT_DEST_REC *Irssi__UI__TextDest;
|
typedef TEXT_DEST_REC *Irssi__UI__TextDest;
|
||||||
typedef THEME_REC *Irssi__UI__Theme;
|
typedef THEME_REC *Irssi__UI__Theme;
|
||||||
typedef KEYINFO_REC *Irssi__UI__Keyinfo;
|
typedef KEYINFO_REC *Irssi__UI__Keyinfo;
|
||||||
|
typedef LINE_INFO_META_REC *Irssi__UI__LineInfoMeta;
|
||||||
|
@ -3,6 +3,7 @@ Irssi::UI::Theme T_PlainObj
|
|||||||
Irssi::UI::Window T_PlainObj
|
Irssi::UI::Window T_PlainObj
|
||||||
Irssi::UI::Keyinfo T_PlainObj
|
Irssi::UI::Keyinfo T_PlainObj
|
||||||
Irssi::UI::TextDest T_PlainObj
|
Irssi::UI::TextDest T_PlainObj
|
||||||
|
Irssi::UI::LineInfoMeta T_PlainObj
|
||||||
|
|
||||||
INPUT
|
INPUT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user