mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Perl fixes and additions. theme_register() / printformat() works now
with scripts git-svn-id: http://svn.irssi.org/repos/irssi/trunk@884 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
9a7491fbe6
commit
079932c405
@ -75,9 +75,6 @@ void core_init(void)
|
|||||||
|
|
||||||
void core_deinit(void)
|
void core_deinit(void)
|
||||||
{
|
{
|
||||||
while (modules != NULL)
|
|
||||||
module_unload(modules->data);
|
|
||||||
|
|
||||||
chat_commands_deinit();
|
chat_commands_deinit();
|
||||||
|
|
||||||
nicklist_deinit();
|
nicklist_deinit();
|
||||||
|
@ -586,6 +586,9 @@ void theme_unregister_module(const char *module)
|
|||||||
{
|
{
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
||||||
|
if (default_formats == NULL)
|
||||||
|
return; /* already uninitialized */
|
||||||
|
|
||||||
if (!g_hash_table_lookup_extended(default_formats, module, &key, &value))
|
if (!g_hash_table_lookup_extended(default_formats, module, &key, &value))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1004,6 +1007,7 @@ void themes_deinit(void)
|
|||||||
theme_destroy(themes->data);
|
theme_destroy(themes->data);
|
||||||
|
|
||||||
g_hash_table_destroy(default_formats);
|
g_hash_table_destroy(default_formats);
|
||||||
|
default_formats = NULL;
|
||||||
|
|
||||||
command_unbind("format", (SIGNAL_FUNC) cmd_format);
|
command_unbind("format", (SIGNAL_FUNC) cmd_format);
|
||||||
command_unbind("save", (SIGNAL_FUNC) cmd_save);
|
command_unbind("save", (SIGNAL_FUNC) cmd_save);
|
||||||
|
@ -123,6 +123,9 @@ static void textui_deinit(void)
|
|||||||
quitting = TRUE;
|
quitting = TRUE;
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
|
|
||||||
|
while (modules != NULL)
|
||||||
|
module_unload(modules->data);
|
||||||
|
|
||||||
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
|
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
|
||||||
gui_textwidget_deinit();
|
gui_textwidget_deinit();
|
||||||
gui_special_vars_deinit();
|
gui_special_vars_deinit();
|
||||||
|
@ -14,4 +14,5 @@ INCLUDE: Query.xs
|
|||||||
INCLUDE: Rawlog.xs
|
INCLUDE: Rawlog.xs
|
||||||
INCLUDE: Server.xs
|
INCLUDE: Server.xs
|
||||||
INCLUDE: Settings.xs
|
INCLUDE: Settings.xs
|
||||||
|
INCLUDE: Themes.xs
|
||||||
INCLUDE: Window.xs
|
INCLUDE: Window.xs
|
||||||
|
@ -2,5 +2,5 @@ use ExtUtils::MakeMaker;
|
|||||||
|
|
||||||
WriteMakefile('NAME' => 'Irssi',
|
WriteMakefile('NAME' => 'Irssi',
|
||||||
'LIBS' => '',
|
'LIBS' => '',
|
||||||
'INC' => '-I@top_srcdir@/src -I@top_srcdir@/src/core @GLIB_CFLAGS@',
|
'INC' => '-I@top_srcdir@ -I@top_srcdir@/src -I@top_srcdir@/src/core @GLIB_CFLAGS@',
|
||||||
'VERSION_FROM' => '@srcdir@/Irssi.pm');
|
'VERSION_FROM' => '@srcdir@/Irssi.pm');
|
||||||
|
@ -298,13 +298,13 @@ window_item_is_active(item)
|
|||||||
|
|
||||||
|
|
||||||
#*******************************
|
#*******************************
|
||||||
MODULE = Irssi PACKAGE = Irssi::Channel
|
MODULE = Irssi PACKAGE = Irssi::Windowitem
|
||||||
#*******************************
|
#*******************************
|
||||||
|
|
||||||
void
|
void
|
||||||
print(channel, str, level=MSGLEVEL_CLIENTNOTICE)
|
print(item, str, level=MSGLEVEL_CLIENTNOTICE)
|
||||||
Irssi::Channel channel
|
Irssi::Windowitem item
|
||||||
int level
|
int level
|
||||||
char *str
|
char *str
|
||||||
CODE:
|
CODE:
|
||||||
printtext(channel->server, channel->name, level, str);
|
printtext(item->server, item->name, level, str);
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include <XSUB.h>
|
#include <XSUB.h>
|
||||||
|
|
||||||
#undef _
|
#undef _
|
||||||
|
#undef VERSION
|
||||||
#include "../module.h"
|
#include "../module.h"
|
||||||
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -15,18 +17,21 @@
|
|||||||
#include "chatnets.h"
|
#include "chatnets.h"
|
||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
#include "servers-reconnect.h"
|
#include "servers-reconnect.h"
|
||||||
|
#include "servers-redirect.h"
|
||||||
#include "servers-setup.h"
|
#include "servers-setup.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "queries.h"
|
#include "queries.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
|
|
||||||
#include "perl/perl-common.h"
|
|
||||||
|
|
||||||
#include "fe-common/core/fe-windows.h"
|
#include "fe-common/core/fe-windows.h"
|
||||||
|
#include "fe-common/core/formats.h"
|
||||||
|
#include "fe-common/core/printtext.h"
|
||||||
#include "fe-common/core/window-items.h"
|
#include "fe-common/core/window-items.h"
|
||||||
#include "fe-common/core/themes.h"
|
#include "fe-common/core/themes.h"
|
||||||
#include "fe-common/core/keyboard.h"
|
#include "fe-common/core/keyboard.h"
|
||||||
|
|
||||||
|
#include "perl/perl-common.h"
|
||||||
|
|
||||||
typedef COMMAND_REC *Irssi__Command;
|
typedef COMMAND_REC *Irssi__Command;
|
||||||
typedef LOG_REC *Irssi__Log;
|
typedef LOG_REC *Irssi__Log;
|
||||||
typedef LOG_ITEM_REC *Irssi__LogItem;
|
typedef LOG_ITEM_REC *Irssi__LogItem;
|
||||||
|
@ -39,8 +39,20 @@
|
|||||||
|
|
||||||
#include "perl-common.h"
|
#include "perl-common.h"
|
||||||
|
|
||||||
|
#include "fe-common/core/formats.h"
|
||||||
|
#include "fe-common/core/printtext.h"
|
||||||
|
|
||||||
GHashTable *perl_stashes;
|
GHashTable *perl_stashes;
|
||||||
|
|
||||||
|
/* returns the package who called us */
|
||||||
|
char *perl_get_package(void)
|
||||||
|
{
|
||||||
|
STRLEN n_a;
|
||||||
|
|
||||||
|
perl_eval_pv("($package) = caller;", TRUE);
|
||||||
|
return SvPV(perl_get_sv("package", FALSE), n_a);
|
||||||
|
}
|
||||||
|
|
||||||
HV *irssi_get_stash_item(int type, int chat_type)
|
HV *irssi_get_stash_item(int type, int chat_type)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
@ -157,6 +169,26 @@ void perl_query_fill_hash(HV *hv, QUERY_REC *query)
|
|||||||
hv_store(hv, "unwanted", 8, newSViv(query->unwanted), 0);
|
hv_store(hv, "unwanted", 8, newSViv(query->unwanted), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
|
||||||
|
{
|
||||||
|
THEME_REC *theme;
|
||||||
|
char *module, *str;
|
||||||
|
int formatnum;
|
||||||
|
|
||||||
|
module = g_strdup(perl_get_package());
|
||||||
|
theme = dest->window->theme == NULL ? current_theme :
|
||||||
|
dest->window->theme;
|
||||||
|
|
||||||
|
formatnum = format_find_tag(module, format);
|
||||||
|
signal_emit("print format", 5, theme, module,
|
||||||
|
&dest, GINT_TO_POINTER(formatnum), arglist);
|
||||||
|
|
||||||
|
str = format_get_text_theme_charargs(theme, module, dest, formatnum, arglist);
|
||||||
|
if (*str != '\0') printtext_window(dest->window, dest->level, "%s", str);
|
||||||
|
g_free(str);
|
||||||
|
g_free(module);
|
||||||
|
}
|
||||||
|
|
||||||
static void perl_register_protocol(CHAT_PROTOCOL_REC *rec)
|
static void perl_register_protocol(CHAT_PROTOCOL_REC *rec)
|
||||||
{
|
{
|
||||||
static char *items[] = {
|
static char *items[] = {
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
extern GHashTable *perl_stashes;
|
extern GHashTable *perl_stashes;
|
||||||
|
|
||||||
|
/* returns the package who called us */
|
||||||
|
char *perl_get_package(void);
|
||||||
|
|
||||||
HV *irssi_get_stash_item(int type, int chat_type);
|
HV *irssi_get_stash_item(int type, int chat_type);
|
||||||
|
|
||||||
#define irssi_get_stash(item) \
|
#define irssi_get_stash(item) \
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#include "perl-common.h"
|
#include "perl-common.h"
|
||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
|
|
||||||
|
#include "fe-common/core/themes.h"
|
||||||
|
#include "fe-common/core/formats.h"
|
||||||
|
|
||||||
/* For compatibility with perl 5.004 and older */
|
/* For compatibility with perl 5.004 and older */
|
||||||
#ifndef ERRSV
|
#ifndef ERRSV
|
||||||
# define ERRSV GvSV(errgv)
|
# define ERRSV GvSV(errgv)
|
||||||
@ -199,23 +202,41 @@ static int signal_destroy_hash(void *key, GSList **list, const char *package)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void perl_unregister_theme(const char *package)
|
||||||
|
{
|
||||||
|
FORMAT_REC *formats;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
formats = g_hash_table_lookup(default_formats, package);
|
||||||
|
if (formats == NULL) return;
|
||||||
|
|
||||||
|
for (n = 0; formats[n].def != NULL; n++) {
|
||||||
|
g_free(formats[n].tag);
|
||||||
|
g_free(formats[n].def);
|
||||||
|
}
|
||||||
|
g_free(formats);
|
||||||
|
theme_unregister_module(package);
|
||||||
|
}
|
||||||
|
|
||||||
static int perl_script_destroy(const char *name)
|
static int perl_script_destroy(const char *name)
|
||||||
{
|
{
|
||||||
GSList *tmp, *next;
|
GSList *tmp, *next, *item;
|
||||||
char *package;
|
char *package;
|
||||||
int package_len;
|
int package_len;
|
||||||
|
|
||||||
if (gslist_find_string(perl_scripts, name) == NULL)
|
item = gslist_find_string(perl_scripts, name);
|
||||||
return FALSE;
|
if (item == NULL) return FALSE;
|
||||||
|
|
||||||
package = g_strdup_printf("Irssi::Script::%s::", name);
|
package = g_strdup_printf("Irssi::Script::%s", name);
|
||||||
package_len = strlen(package);
|
package_len = strlen(package);
|
||||||
|
|
||||||
|
/* signals */
|
||||||
g_hash_table_foreach_remove(first_signals,
|
g_hash_table_foreach_remove(first_signals,
|
||||||
(GHRFunc) signal_destroy_hash, package);
|
(GHRFunc) signal_destroy_hash, package);
|
||||||
g_hash_table_foreach_remove(last_signals,
|
g_hash_table_foreach_remove(last_signals,
|
||||||
(GHRFunc) signal_destroy_hash, package);
|
(GHRFunc) signal_destroy_hash, package);
|
||||||
|
|
||||||
|
/* timeouts and input waits */
|
||||||
for (tmp = perl_sources; tmp != NULL; tmp = next) {
|
for (tmp = perl_sources; tmp != NULL; tmp = next) {
|
||||||
PERL_SOURCE_REC *rec = tmp->data;
|
PERL_SOURCE_REC *rec = tmp->data;
|
||||||
|
|
||||||
@ -224,12 +245,21 @@ static int perl_script_destroy(const char *name)
|
|||||||
perl_source_destroy(rec);
|
perl_source_destroy(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* theme */
|
||||||
|
perl_unregister_theme(package);
|
||||||
|
|
||||||
g_free(package);
|
g_free(package);
|
||||||
|
g_free(item->data);
|
||||||
|
perl_scripts = g_slist_remove(perl_scripts, item->data);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void irssi_perl_stop(void)
|
static void irssi_perl_stop(void)
|
||||||
{
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
char *package;
|
||||||
|
|
||||||
|
/* signals */
|
||||||
g_hash_table_foreach(first_signals,
|
g_hash_table_foreach(first_signals,
|
||||||
(GHFunc) signal_destroy_hash, NULL);
|
(GHFunc) signal_destroy_hash, NULL);
|
||||||
g_hash_table_destroy(first_signals);
|
g_hash_table_destroy(first_signals);
|
||||||
@ -248,13 +278,24 @@ static void irssi_perl_stop(void)
|
|||||||
signal_remove("last signal", (SIGNAL_FUNC) sig_lastsignal);
|
signal_remove("last signal", (SIGNAL_FUNC) sig_lastsignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* timeouts and input waits */
|
||||||
while (perl_sources != NULL)
|
while (perl_sources != NULL)
|
||||||
perl_source_destroy(perl_sources->data);
|
perl_source_destroy(perl_sources->data);
|
||||||
|
|
||||||
|
/* themes */
|
||||||
|
for (tmp = perl_scripts; tmp != NULL; tmp = tmp->next) {
|
||||||
|
package = g_strdup_printf("Irssi::Script::%s",
|
||||||
|
(char *) tmp->data);
|
||||||
|
perl_unregister_theme(package);
|
||||||
|
g_free(package);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* scripts list */
|
||||||
g_slist_foreach(perl_scripts, (GFunc) g_free, NULL);
|
g_slist_foreach(perl_scripts, (GFunc) g_free, NULL);
|
||||||
g_slist_free(perl_scripts);
|
g_slist_free(perl_scripts);
|
||||||
perl_scripts = NULL;
|
perl_scripts = NULL;
|
||||||
|
|
||||||
|
/* perl interpreter */
|
||||||
perl_destruct(irssi_perl_interp);
|
perl_destruct(irssi_perl_interp);
|
||||||
perl_free(irssi_perl_interp);
|
perl_free(irssi_perl_interp);
|
||||||
irssi_perl_interp = NULL;
|
irssi_perl_interp = NULL;
|
||||||
@ -350,15 +391,6 @@ static void cmd_perlflush(const char *data)
|
|||||||
irssi_perl_start();
|
irssi_perl_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns the package who called us */
|
|
||||||
static char *perl_get_package(void)
|
|
||||||
{
|
|
||||||
STRLEN n_a;
|
|
||||||
|
|
||||||
perl_eval_pv("($package) = caller;", TRUE);
|
|
||||||
return SvPV(perl_get_sv("package", FALSE), n_a);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void perl_signal_to(const char *signal, const char *func, int last)
|
static void perl_signal_to(const char *signal, const char *func, int last)
|
||||||
{
|
{
|
||||||
PERL_SIGNAL_REC *rec;
|
PERL_SIGNAL_REC *rec;
|
||||||
|
Loading…
Reference in New Issue
Block a user