1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Dependencies finally work correctly in perl libraries (they're each compiled

separately now). Added statusbar code to available to perl, it's now
possible to create new statusbar items with perl scripts.

statusbar_items_redraw(char *name) can now be used to easily redraw all
named statusbar items in screen.

Probably several other changes I've already forgotten :)


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1861 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-10-20 19:52:07 +00:00 committed by cras
parent 17f4d6b5de
commit 76c6e9ab83
48 changed files with 428 additions and 124 deletions

View File

@ -33,7 +33,6 @@
#define MAX_LAG_UNKNOWN_TIME 30
/* activity */
static GSList *activity_items;
static GList *activity_list;
static GHashTable *input_entries;
@ -195,7 +194,7 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
activity_list = g_list_remove(activity_list, window);
if (window->data_level != 0)
activity_list = g_list_prepend(activity_list, window);
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
return;
}
@ -204,12 +203,12 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
if (window->data_level == 0) {
/* remove from activity list */
activity_list = g_list_remove(activity_list, window);
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
} else if (window->data_level != GPOINTER_TO_INT(oldlevel) ||
window->hilight_color != 0) {
/* different level as last time (or maybe different
hilight color?), just redraw it. */
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
}
return;
}
@ -231,7 +230,7 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
if (tmp == NULL)
activity_list = g_list_append(activity_list, window);
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
}
static void sig_statusbar_activity_window_destroyed(WINDOW_REC *window)
@ -240,12 +239,12 @@ static void sig_statusbar_activity_window_destroyed(WINDOW_REC *window)
if (g_list_find(activity_list, window) != NULL)
activity_list = g_list_remove(activity_list, window);
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
}
static void sig_statusbar_activity_updated(void)
{
statusbar_items_redraw(activity_items);
statusbar_items_redraw("act");
}
static void item_more(SBAR_ITEM_REC *item, int get_size_only)
@ -276,24 +275,14 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
}
}
static void sig_statusbar_item_created(SBAR_ITEM_REC *item)
{
if (item->func == item_act)
activity_items = g_slist_prepend(activity_items, item);
}
static void sig_statusbar_item_destroyed(SBAR_ITEM_REC *item)
{
if (item->func == item_act)
activity_items = g_slist_remove(activity_items, item);
else {
GUI_ENTRY_REC *rec;
GUI_ENTRY_REC *rec;
rec = g_hash_table_lookup(input_entries, item);
if (rec != NULL) {
gui_entry_destroy(rec);
g_hash_table_remove(input_entries, item);
}
rec = g_hash_table_lookup(input_entries, item);
if (rec != NULL) {
gui_entry_destroy(rec);
g_hash_table_remove(input_entries, item);
}
}
@ -319,7 +308,6 @@ void statusbar_items_init(void)
signal_add("window destroyed", (SIGNAL_FUNC) sig_statusbar_activity_window_destroyed);
signal_add("window refnum changed", (SIGNAL_FUNC) sig_statusbar_activity_updated);
signal_add("statusbar item created", (SIGNAL_FUNC) sig_statusbar_item_created);
signal_add("statusbar item destroyed", (SIGNAL_FUNC) sig_statusbar_item_destroyed);
}
@ -334,6 +322,5 @@ void statusbar_items_deinit(void)
g_list_free(activity_list);
activity_list = NULL;
signal_remove("statusbar item created", (SIGNAL_FUNC) sig_statusbar_item_created);
signal_remove("statusbar item destroyed", (SIGNAL_FUNC) sig_statusbar_item_destroyed);
}

View File

@ -39,10 +39,11 @@ STATUSBAR_GROUP_REC *active_statusbar_group;
sbar_item_funcs: char *name => STATUSBAR_FUNC func
sbar_signal_items: int signal_id => GSList *(SBAR_ITEM_REC *items)
sbar_item_signals: SBAR_ITEM_REC *item => GSList *(int *signal_ids)
named_sbar_items: const char *name => GSList *(SBAR_ITEM_REC *items)
*/
static GHashTable *sbar_item_defs, *sbar_item_funcs;
static GHashTable *sbar_signal_items, *sbar_item_signals;
static GHashTable *named_sbar_items;
void statusbar_item_register(const char *name, const char *value,
STATUSBAR_FUNC func)
@ -322,6 +323,12 @@ void statusbar_item_redraw(SBAR_ITEM_REC *item)
active_win = old_active_win;
}
void statusbar_items_redraw(const char *name)
{
g_slist_foreach(g_hash_table_lookup(named_sbar_items, name),
(GFunc) statusbar_item_redraw, NULL);
}
static void statusbars_recalc_ypos(STATUSBAR_REC *bar)
{
GSList *tmp, *bar_group;
@ -532,6 +539,32 @@ void statusbar_destroy(STATUSBAR_REC *bar)
g_free(bar);
}
void statusbar_recreate_items(STATUSBAR_REC *bar)
{
GSList *tmp;
/* destroy */
while (bar->items != NULL)
statusbar_item_destroy(bar->items->data);
/* create */
for (tmp = bar->config->items; tmp != NULL; tmp = tmp->next) {
SBAR_ITEM_CONFIG_REC *rec = tmp->data;
statusbar_item_create(bar, rec);
}
statusbar_redraw(bar);
}
void statusbars_recreate_items(void)
{
if (active_statusbar_group != NULL) {
g_slist_foreach(active_statusbar_group->bars,
(GFunc) statusbar_recreate_items, NULL);
}
}
STATUSBAR_REC *statusbar_find(STATUSBAR_GROUP_REC *group, const char *name,
MAIN_WINDOW_REC *window)
{
@ -782,6 +815,7 @@ SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
SBAR_ITEM_CONFIG_REC *config)
{
SBAR_ITEM_REC *rec;
GSList *items;
g_return_val_if_fail(bar != NULL, NULL);
g_return_val_if_fail(config != NULL, NULL);
@ -797,6 +831,10 @@ SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
rec->func = statusbar_item_default_func;
statusbar_item_default_signals(rec);
items = g_hash_table_lookup(named_sbar_items, config->name);
items = g_slist_append(items, rec);
g_hash_table_insert(named_sbar_items, config->name, items);
signal_emit("statusbar item created", 1, rec);
return rec;
}
@ -834,6 +872,14 @@ void statusbar_item_destroy(SBAR_ITEM_REC *item)
g_return_if_fail(item != NULL);
item->bar->items = g_slist_remove(item->bar->items, item);
list = g_hash_table_lookup(named_sbar_items, item->config->name);
list = g_slist_remove(list, item);
if (list == NULL)
g_hash_table_remove(named_sbar_items, item->config->name);
else
g_hash_table_insert(named_sbar_items, item->config->name, list);
signal_emit("statusbar item destroyed", 1, item);
list = g_hash_table_lookup(sbar_item_signals, item);
@ -943,13 +989,15 @@ void statusbar_init(void)
statusbar_groups = NULL;
active_statusbar_group = NULL;
sbar_item_defs = g_hash_table_new((GHashFunc) g_str_hash,
(GCompareFunc) g_str_equal);
(GCompareFunc) g_str_equal);
sbar_item_funcs = g_hash_table_new((GHashFunc) g_str_hash,
(GCompareFunc) g_str_equal);
sbar_signal_items = g_hash_table_new((GHashFunc) g_direct_hash,
(GCompareFunc) g_direct_equal);
sbar_item_signals = g_hash_table_new((GHashFunc) g_direct_hash,
(GCompareFunc) g_direct_equal);
named_sbar_items = g_hash_table_new((GHashFunc) g_str_hash,
(GCompareFunc) g_str_equal);
signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);
@ -980,6 +1028,7 @@ void statusbar_deinit(void)
g_hash_table_foreach(sbar_item_signals,
(GHFunc) statusbar_item_signal_destroy, NULL);
g_hash_table_destroy(sbar_item_signals);
g_hash_table_destroy(named_sbar_items);
signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);

View File

@ -100,8 +100,10 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
/* redraw statusbar, NULL = all */
void statusbar_redraw(STATUSBAR_REC *bar);
void statusbar_item_redraw(SBAR_ITEM_REC *item);
#define statusbar_items_redraw(list) \
g_slist_foreach(list, (GFunc) statusbar_item_redraw, NULL);
void statusbar_items_redraw(const char *name);
void statusbar_recreate_items(STATUSBAR_REC *bar);
void statusbars_recreate_items(void);
void statusbar_init(void);
void statusbar_deinit(void);

View File

@ -90,9 +90,9 @@ IRC_SOURCES = \
irc/Irc.xs \
irc/Irc.pm \
irc/Dcc.xs \
irc/IrcChannel.xs \
irc/IrcQuery.xs \
irc/IrcServer.xs \
irc/Channel.xs \
irc/Query.xs \
irc/Server.xs \
irc/Modes.xs \
irc/Netsplit.xs \
irc/Notifylist.xs \
@ -114,6 +114,7 @@ TEXTUI_SOURCES = \
textui/TextUI.pm \
textui/TextBuffer.xs \
textui/TextBufferView.xs \
textui/Statusbar.xs \
textui/Makefile.PL.in \
textui/typemap \
textui/module.h

View File

@ -1,7 +1,7 @@
Makefile
Makefile.PL
Irssi.c
Irssi.bs
*.c
*.o
pm_to_blib
blib

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Channel PACKAGE = Irssi
PROTOTYPES: ENABLE
void
channels()
@ -18,7 +21,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
MODULE = Irssi::Channel PACKAGE = Irssi::Server
#*******************************
void
@ -68,7 +71,7 @@ PPCODE:
g_slist_free(list);
#*******************************
MODULE = Irssi PACKAGE = Irssi::Channel PREFIX = channel_
MODULE = Irssi::Channel PACKAGE = Irssi::Channel PREFIX = channel_
#*******************************
void

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Core PACKAGE = Irssi
PROTOTYPES: ENABLE
void
signal_emit(signal, ...)
@ -374,7 +377,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
MODULE = Irssi::Core PACKAGE = Irssi::Server
#*******************************
char *
@ -389,7 +392,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Windowitem
MODULE = Irssi::Core PACKAGE = Irssi::Windowitem
#*******************************
char *

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Ignore PACKAGE = Irssi
PROTOTYPES: ENABLE
void
ignores()
@ -22,7 +25,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
MODULE = Irssi::Ignore PACKAGE = Irssi::Server
#*******************************
int
@ -35,7 +38,7 @@ ignore_check(server, nick, host, channel, text, level)
int level
#*******************************
MODULE = Irssi PACKAGE = Irssi::Ignore PREFIX = ignore_
MODULE = Irssi::Ignore PACKAGE = Irssi::Ignore PREFIX = ignore_
#*******************************
void

View File

@ -7,7 +7,7 @@ package Irssi;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = "0.8";
$VERSION = "0.9";
require Exporter;
require DynaLoader;

View File

@ -9,12 +9,17 @@ init()
CODE:
perl_api_version_check("Irssi");
INCLUDE: Channel.xs
INCLUDE: Core.xs
INCLUDE: Ignore.xs
INCLUDE: Log.xs
INCLUDE: Masks.xs
INCLUDE: Query.xs
INCLUDE: Rawlog.xs
INCLUDE: Server.xs
INCLUDE: Settings.xs
void
deinit()
CODE:
BOOT:
irssi_boot(Channel);
irssi_boot(Core);
irssi_boot(Ignore);
irssi_boot(Log);
irssi_boot(Masks);
irssi_boot(Query);
irssi_boot(Rawlog);
irssi_boot(Server);
irssi_boot(Settings);

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Log PACKAGE = Irssi
PROTOTYPES: ENABLE
void
logs()
@ -19,7 +22,7 @@ log_find(fname)
char *fname
#*******************************
MODULE = Irssi PACKAGE = Irssi::Log PREFIX = log_
MODULE = Irssi::Log PACKAGE = Irssi::Log PREFIX = log_
#*******************************
void

View File

@ -2,5 +2,6 @@ use ExtUtils::MakeMaker;
WriteMakefile('NAME' => 'Irssi',
'LIBS' => '',
'OBJECT' => '$(O_FILES)',
'INC' => '-I../../.. -I@top_srcdir@ -I@top_srcdir@/src -I@top_srcdir@/src/core @GLIB_CFLAGS@',
'VERSION_FROM' => '@srcdir@/Irssi.pm');

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Masks PACKAGE = Irssi
PROTOTYPES: ENABLE
int
mask_match(mask, nick, user, host)
@ -32,7 +35,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
MODULE = Irssi::Masks PACKAGE = Irssi::Server
#*******************************
int

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Query PACKAGE = Irssi
PROTOTYPES: ENABLE
void
queries()
@ -20,7 +23,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server
MODULE = Irssi::Query PACKAGE = Irssi::Server
#*******************************
void
@ -41,7 +44,7 @@ query_find(server, nick)
char *nick
#*******************************
MODULE = Irssi PACKAGE = Irssi::Query PREFIX = query_
MODULE = Irssi::Query PACKAGE = Irssi::Query PREFIX = query_
#*******************************
void

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Rawlog PACKAGE = Irssi
PROTOTYPES: ENABLE
void
rawlog_set_size(lines)
@ -8,7 +11,7 @@ Irssi::Rawlog
rawlog_create()
#*******************************
MODULE = Irssi PACKAGE = Irssi::Rawlog PREFIX = rawlog_
MODULE = Irssi::Rawlog PACKAGE = Irssi::Rawlog PREFIX = rawlog_
#*******************************
void

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Server PACKAGE = Irssi
PROTOTYPES: ENABLE
void
servers()
@ -36,7 +39,7 @@ server_find_chatnet(chatnet)
char *chatnet
#*******************************
MODULE = Irssi PACKAGE = Irssi::Server PREFIX = server_
MODULE = Irssi::Server PACKAGE = Irssi::Server PREFIX = server_
#*******************************
void

View File

@ -1,4 +1,7 @@
MODULE = Irssi PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::Settings PACKAGE = Irssi
PROTOTYPES: ENABLE
char *
settings_get_str(key)

View File

@ -1,7 +1,7 @@
Makefile
Makefile.PL
Irc.c
Irc.bs
*.c
*.o
pm_to_blib
blib

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel PREFIX = irc_
#include "module.h"
MODULE = Irssi::Irc::Channel PACKAGE = Irssi::Irc::Channel PREFIX = irc_
PROTOTYPES: ENABLE
void
bans(channel)
@ -42,7 +45,7 @@ CODE:
OUTPUT:
RETVAL
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_
MODULE = Irssi::Irc::Channel PACKAGE = Irssi::Irc::Server PREFIX = irc_
Irssi::Irc::Channel
irc_channel_create(server, name, automatic)

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc
#include "module.h"
MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Irc
PROTOTYPES: ENABLE
void
dccs()
@ -60,7 +63,7 @@ dcc_get_download_path(fname)
char *fname
#*******************************
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Dcc PREFIX = dcc_
MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Irc::Dcc PREFIX = dcc_
#*******************************
void
@ -85,7 +88,7 @@ dcc_reject(dcc, server)
Irssi::Irc::Server server
#*******************************
MODULE = Irssi::Irc PACKAGE = Irssi::Windowitem PREFIX = item_
MODULE = Irssi::Irc::Dcc PACKAGE = Irssi::Windowitem PREFIX = item_
#*******************************
Irssi::Irc::Dcc::Chat

View File

@ -7,7 +7,7 @@ package Irssi::Irc;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = "0.8";
$VERSION = "0.9";
require Exporter;
require DynaLoader;

View File

@ -178,11 +178,15 @@ CODE:
"@Irssi::Irc::Dcc::Send::ISA = qw(Irssi::Irc::Dcc);\n",
TRUE);
INCLUDE: IrcServer.xs
INCLUDE: IrcChannel.xs
INCLUDE: IrcQuery.xs
INCLUDE: Modes.xs
INCLUDE: Netsplit.xs
void
deinit()
CODE:
INCLUDE: Dcc.xs
INCLUDE: Notifylist.xs
BOOT:
irssi_boot(Irc__Channel);
irssi_boot(Irc__Dcc);
irssi_boot(Irc__Modes);
irssi_boot(Irc__Netsplit);
irssi_boot(Irc__Notifylist);
irssi_boot(Irc__Query);
irssi_boot(Irc__Server);

View File

@ -1,7 +0,0 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_
Irssi::Irc::Query
irc_query_create(server_tag, nick, automatic)
char *server_tag
char *nick
int automatic

View File

@ -2,6 +2,7 @@ use ExtUtils::MakeMaker;
WriteMakefile('NAME' => 'Irssi::Irc',
'LIBS' => '',
'OBJECT' => '$(O_FILES)',
'TYPEMAPS' => ['../common/typemap'],
'INC' => '-I../../.. -I@top_srcdir@/src -I@top_srcdir@/src/core -I@top_srcdir@/src/irc/core -I@top_srcdir@/src/irc @GLIB_CFLAGS@',
'VERSION_FROM' => '@srcdir@/Irc.pm');

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc
#include "module.h"
MODULE = Irssi::Irc::Modes PACKAGE = Irssi::Irc
PROTOTYPES: ENABLE
char *
modes_join(old, mode, channel)
@ -7,7 +10,7 @@ modes_join(old, mode, channel)
int channel
#*******************************
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel PREFIX = channel_
MODULE = Irssi::Irc::Modes PACKAGE = Irssi::Irc::Channel PREFIX = channel_
#*******************************
char *

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server
#include "module.h"
MODULE = Irssi::Irc::Netsplit PACKAGE = Irssi::Irc::Server
PROTOTYPES: ENABLE
Irssi::Irc::Netsplit
netsplit_find(server, nick, address)

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc
#include "module.h"
MODULE = Irssi::Irc::Notifylist PACKAGE = Irssi::Irc
PROTOTYPES: ENABLE
void
notifies()
@ -31,7 +34,7 @@ notifylist_find(mask, ircnet)
char *ircnet
#*******************************
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server
MODULE = Irssi::Irc::Notifylist PACKAGE = Irssi::Irc::Server
#*******************************
int
@ -40,7 +43,7 @@ notifylist_ison_server(server, nick)
char *nick
#*******************************
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Notifylist PREFIX = notifylist_
MODULE = Irssi::Irc::Notifylist PACKAGE = Irssi::Irc::Notifylist PREFIX = notifylist_
#*******************************
int

10
src/perl/irc/Query.xs Normal file
View File

@ -0,0 +1,10 @@
#include "module.h"
MODULE = Irssi::Irc::Query PACKAGE = Irssi::Irc::Server PREFIX = irc_
PROTOTYPES: ENABLE
Irssi::Irc::Query
irc_query_create(server_tag, nick, automatic)
char *server_tag
char *nick
int automatic

View File

@ -1,4 +1,7 @@
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server PREFIX = irc_server_
#include "module.h"
MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Server PREFIX = irc_server_
PROTOTYPES: ENABLE
char *
irc_server_get_channels(server)
@ -32,7 +35,7 @@ ctcp_send_reply(server, data)
Irssi::Irc::Server server
char *data
MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_
MODULE = Irssi::Irc::Server PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_
Irssi::Irc::Server
irc_server_connect(conn)

View File

@ -22,4 +22,4 @@ extern PerlInterpreter *my_perl; /* must be called my_perl or some perl implemen
/* Change this every time when some API changes between irssi's perl module
and irssi's perl libraries. */
#define IRSSI_PERL_API_VERSION 20011020
#define IRSSI_PERL_API_VERSION 20011021

View File

@ -190,6 +190,16 @@ char *perl_get_use_list(void)
return ret;
}
void irssi_callXS(void (*subaddr)(CV* cv), CV *cv, SV **mark)
{
dSP;
PUSHMARK(mark);
(*subaddr)(cv);
PUTBACK;
}
void perl_connect_fill_hash(HV *hv, SERVER_CONNECT_REC *conn)
{
char *type, *chat_type;

View File

@ -48,6 +48,12 @@ void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects);
char *perl_get_use_list(void);
#define irssi_boot(x) { \
extern void boot_Irssi__##x(CV *cv); \
irssi_callXS(boot_Irssi__##x, cv, mark); \
}
void irssi_callXS(void (*subaddr)(CV* cv), CV *cv, SV **mark);
void perl_common_start(void);
void perl_common_stop(void);

View File

@ -120,7 +120,8 @@ void perl_scripts_deinit(void)
perl_sources_stop();
perl_common_stop();
/* Unload all perl libraries loaded with dynaloader */
/* Unload all perl libraries loaded with dynaloader */
perl_eval_pv("foreach my $lib (@DynaLoader::dl_modules) { if ($lib =~ /^Irssi\\b/) { $lib .= '::deinit();'; eval $lib; } }", TRUE);
perl_eval_pv("foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); }", TRUE);
/* perl interpreter */

View File

@ -1,7 +1,7 @@
Makefile
Makefile.PL
TextUI.c
TextUI.bs
*.c
*.o
pm_to_blib
blib

View File

@ -2,6 +2,7 @@ use ExtUtils::MakeMaker;
WriteMakefile('NAME' => 'Irssi::TextUI',
'LIBS' => '',
'OBJECT' => '$(O_FILES)',
'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');

View File

@ -0,0 +1,159 @@
#include "module.h"
static GHashTable *perl_sbar_defs;
static int check_sbar_destroy(char *key, char *value, char *script)
{
if (strncmp(key, script, strlen(script)) == 0 &&
key[strlen(script)] == ':') {
g_free(key);
g_free(value);
return TRUE;
}
return FALSE;
}
static void sig_script_destroy(PERL_SCRIPT_REC *script)
{
g_hash_table_foreach_remove(perl_sbar_defs,
(GHRFunc) check_sbar_destroy,
script->name);
}
void perl_statusbar_init(void)
{
perl_sbar_defs = g_hash_table_new((GHashFunc) g_str_hash,
(GCompareFunc) g_str_equal);
signal_add("script destroy", (SIGNAL_FUNC) sig_script_destroy);
}
static void statusbar_item_def_destroy(void *key, void *value)
{
g_free(key);
g_free(value);
}
void perl_statusbar_deinit(void)
{
signal_remove("script destroy", (SIGNAL_FUNC) sig_script_destroy);
g_hash_table_foreach(perl_sbar_defs,
(GHFunc) statusbar_item_def_destroy, NULL);
g_hash_table_destroy(perl_sbar_defs);
}
static void perl_statusbar_event(char *function, SBAR_ITEM_REC *item,
int get_size_only)
{
dSP;
int retcount;
SV *item_sv, **sv;
HV *hv;
ENTER;
SAVETMPS;
PUSHMARK(SP);
item_sv = plain_bless(item, "Irssi::TextUI::StatusbarItem");
XPUSHs(sv_2mortal(item_sv));
XPUSHs(sv_2mortal(newSViv(get_size_only)));
PUTBACK;
retcount = perl_call_pv(function, G_EVAL|G_DISCARD);
SPAGAIN;
if (SvTRUE(ERRSV)) {
STRLEN n_a;
char *package;
package = perl_function_get_package(function);
signal_emit("script error", 2,
perl_script_find_package(package),
SvPV(ERRSV, n_a));
g_free(package);
}
/* min_size and max_size can be changed, move them to SBAR_ITEM_REC */
hv = hvref(item_sv);
if (hv != NULL) {
sv = hv_fetch(hv, "min_size", 8, 0);
if (sv != NULL) item->min_size = SvIV(*sv);
sv = hv_fetch(hv, "max_size", 8, 0);
if (sv != NULL) item->max_size = SvIV(*sv);
}
PUTBACK;
FREETMPS;
LEAVE;
}
static void sig_perl_statusbar(SBAR_ITEM_REC *item, int get_size_only)
{
char *function;
function = g_hash_table_lookup(perl_sbar_defs, item->config->name);
if (function != NULL)
perl_statusbar_event(function, item, get_size_only);
else {
/* use default function - this shouldn't actually happen.. */
statusbar_item_default_handler(item, get_size_only, NULL, "", TRUE);
}
}
MODULE = Irssi::TextUI::Statusbar PACKAGE = Irssi
PROTOTYPES: ENABLE
void
statusbar_item_register(name, value, func = NULL)
char *name
char *value
char *func
CODE:
statusbar_item_register(name, value, func == NULL || *func == '\0' ? NULL : sig_perl_statusbar);
if (func != NULL) {
g_hash_table_insert(perl_sbar_defs, g_strdup(name),
g_strdup_printf("%s::%s", perl_get_package(), func));
}
void
statusbar_item_unregister(name)
char *name
PREINIT:
gpointer key, value;
CODE:
if (g_hash_table_lookup_extended(perl_sbar_defs, name, &key, &value)) {
g_hash_table_remove(perl_sbar_defs, name);
g_free(key);
g_free(value);
}
statusbar_item_unregister(name);
void
statusbar_items_redraw(name)
char *name
void
statusbars_recreate_items()
#*******************************
MODULE = Irssi::TextUI::Statusbar PACKAGE = Irssi::TextUI::StatusbarItem PREFIX = statusbar_item_
#*******************************
void
statusbar_item_default_handler(item, get_size_only, str, data, escape_vars = TRUE)
Irssi::TextUI::StatusbarItem item
int get_size_only
char *str
char *data
int escape_vars
PREINIT:
HV *hv;
CODE:
statusbar_item_default_handler(item, get_size_only,
*str == '\0' ? NULL : str,
data, escape_vars);
hv = hvref(ST(0));
hv_store(hv, "min_size", 8, newSViv(item->min_size), 0);
hv_store(hv, "max_size", 8, newSViv(item->max_size), 0);

View File

@ -1,10 +1,13 @@
MODULE = Irssi::TextUI PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::TextUI::TextBuffer PACKAGE = Irssi
PROTOTYPES: ENABLE
Irssi::TextUI::TextBuffer
textbuffer_create()
#*******************************
MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
MODULE = Irssi::TextUI::TextBuffer PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
#*******************************
void
@ -36,7 +39,7 @@ textbuffer_remove_all_lines(buffer)
Irssi::TextUI::TextBuffer buffer
#*******************************
MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::Line PREFIX = textbuffer_line_
MODULE = Irssi::TextUI::TextBuffer PACKAGE = Irssi::TextUI::Line PREFIX = textbuffer_line_
#*******************************
Irssi::TextUI::Line

View File

@ -1,4 +1,7 @@
MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBuffer PREFIX = textbuffer_
#include "module.h"
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)
@ -10,7 +13,7 @@ textbuffer_view_create(buffer, width, height, default_indent, longword_noindent,
int scroll
#*******************************
MODULE = Irssi::TextUI PACKAGE = Irssi::TextUI::TextBufferView PREFIX = textbuffer_view_
MODULE = Irssi::TextUI::TextBufferView PACKAGE = Irssi::TextUI::TextBufferView PREFIX = textbuffer_view_
#*******************************
void
@ -92,7 +95,7 @@ textbuffer_view_redraw(view)
Irssi::TextUI::TextBufferView view
#*******************************
MODULE = Irssi::TextUI PACKAGE = Irssi::UI::Window
MODULE = Irssi::TextUI::TextBufferView PACKAGE = Irssi::UI::Window
#*******************************
Irssi::TextUI::TextBufferView

View File

@ -7,7 +7,7 @@ package Irssi::TextUI;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = "0.8";
$VERSION = "0.9";
require Exporter;
require DynaLoader;

View File

@ -61,6 +61,14 @@ static void perl_line_info_fill_hash(HV *hv, LINE_INFO_REC *info)
hv_store(hv, "time", 4, newSViv(info->time), 0);
}
static void perl_statusbar_item_fill_hash(HV *hv, SBAR_ITEM_REC *item)
{
hv_store(hv, "min_size", 8, newSViv(item->min_size), 0);
hv_store(hv, "max_size", 8, newSViv(item->max_size), 0);
hv_store(hv, "xpos", 4, newSViv(item->xpos), 0);
hv_store(hv, "size", 4, newSViv(item->size), 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 },
@ -68,6 +76,7 @@ static PLAIN_OBJECT_INIT_REC textui_plains[] = {
{ "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 },
{ "Irssi::TextUI::StatusbarItem", (PERL_OBJECT_FUNC) perl_statusbar_item_fill_hash },
{ NULL, NULL }
};
@ -86,6 +95,12 @@ CODE:
initialized = TRUE;
irssi_add_plains(textui_plains);
perl_statusbar_init();
void
deinit()
CODE:
perl_statusbar_deinit();
MODULE = Irssi::TextUI PACKAGE = Irssi
@ -95,5 +110,7 @@ gui_printtext(xpos, ypos, str)
int ypos
char *str
INCLUDE: TextBuffer.xs
INCLUDE: TextBufferView.xs
BOOT:
irssi_boot(TextUI__Statusbar);
irssi_boot(TextUI__TextBuffer);
irssi_boot(TextUI__TextBufferView);

View File

@ -3,6 +3,7 @@
#include "mainwindows.h"
#include "gui-windows.h"
#include "gui-printtext.h"
#include "statusbar.h"
#include "textbuffer.h"
#include "textbuffer-view.h"
@ -12,3 +13,4 @@ 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;
typedef SBAR_ITEM_REC *Irssi__TextUI__StatusbarItem;

View File

@ -5,6 +5,7 @@ Irssi::TextUI::TextBufferView T_PlainObj
Irssi::TextUI::Line T_PlainObj
Irssi::TextUI::LineCache T_PlainObj
Irssi::TextUI::LineInfo T_PlainObj
Irssi::TextUI::StatusbarItem T_PlainObj
INPUT

View File

@ -1,7 +1,7 @@
Makefile
Makefile.PL
UI.c
UI.bs
*.c
*.o
pm_to_blib
blib

View File

@ -2,6 +2,7 @@ use ExtUtils::MakeMaker;
WriteMakefile('NAME' => 'Irssi::UI',
'LIBS' => '',
'OBJECT' => '$(O_FILES)',
'TYPEMAPS' => ['../common/typemap'],
'INC' => '-I../../.. -I@top_srcdir@/src -I@top_srcdir@/src/core -I@top_srcdir@/src/fe-common/core @GLIB_CFLAGS@',
'VERSION_FROM' => '@srcdir@/UI.pm');

View File

@ -1,5 +1,7 @@
#include "module.h"
MODULE = Irssi::UI PACKAGE = Irssi
MODULE = Irssi::UI::Themes PACKAGE = Irssi
PROTOTYPES: ENABLE
void
theme_register(formats)
@ -53,7 +55,7 @@ CODE:
printformat_perl(&dest, format, arglist);
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::Server
MODULE = Irssi::UI::Themes PACKAGE = Irssi::Server
#*******************************
void
@ -77,7 +79,7 @@ CODE:
printformat_perl(&dest, format, arglist);
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::UI::Window
MODULE = Irssi::UI::Themes PACKAGE = Irssi::UI::Window
#*******************************
void
@ -100,7 +102,7 @@ CODE:
printformat_perl(&dest, format, arglist);
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::Windowitem
MODULE = Irssi::UI::Themes PACKAGE = Irssi::Windowitem
#*******************************
void

View File

@ -7,7 +7,7 @@ package Irssi::UI;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
$VERSION = "0.8";
$VERSION = "0.9";
require Exporter;
require DynaLoader;
@ -21,4 +21,3 @@ bootstrap Irssi::UI $VERSION;
Irssi::UI::init();
1;

View File

@ -104,12 +104,6 @@ static PLAIN_OBJECT_INIT_REC fe_plains[] = {
{ NULL, NULL }
};
static void sig_deinit(void)
{
signal_remove("script destroy", (SIGNAL_FUNC) sig_script_destroy);
signal_remove("perl scripts deinit", (SIGNAL_FUNC) sig_deinit);
}
MODULE = Irssi::UI PACKAGE = Irssi::UI
PROTOTYPES: ENABLE
@ -126,8 +120,12 @@ CODE:
irssi_add_plains(fe_plains);
signal_add("script destroy", (SIGNAL_FUNC) sig_script_destroy);
signal_add("perl scripts deinit", (SIGNAL_FUNC) sig_deinit);
void
deinit()
CODE:
signal_remove("script destroy", (SIGNAL_FUNC) sig_script_destroy);
INCLUDE: Themes.xs
INCLUDE: Window.xs
BOOT:
irssi_boot(UI__Themes);
irssi_boot(UI__Window);

View File

@ -1,4 +1,7 @@
MODULE = Irssi::UI PACKAGE = Irssi
#include "module.h"
MODULE = Irssi::UI::Window PACKAGE = Irssi
PROTOTYPES: ENABLE
void
windows()
@ -93,7 +96,7 @@ OUTPUT:
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::Server
MODULE = Irssi::UI::Window PACKAGE = Irssi::Server
#*******************************
void
@ -135,7 +138,7 @@ window_find_closest(server, name, level)
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::UI::Window PREFIX=window_
MODULE = Irssi::UI::Window PACKAGE = Irssi::UI::Window PREFIX=window_
#*******************************
void
@ -230,7 +233,7 @@ OUTPUT:
RETVAL
#*******************************
MODULE = Irssi::UI PACKAGE = Irssi::Windowitem PREFIX = window_item_
MODULE = Irssi::UI::Window PACKAGE = Irssi::Windowitem PREFIX = window_item_
#*******************************
void