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

Added Irssi::command_bind_first() and Irssi::command_bind_last()

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1638 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-07-16 20:03:36 +00:00 committed by cras
parent f37d661ac3
commit 0d3b5c729f
3 changed files with 34 additions and 7 deletions

View File

@ -315,6 +315,14 @@ PPCODE:
XPUSHs(sv_2mortal(plain_bless(tmp->data, "Irssi::Command")));
}
void
command_bind_first(cmd, func, category = "Perl scripts' commands")
char *cmd
char *category
char *func
CODE:
perl_command_bind_first(cmd, category, func);
void
command_bind(cmd, func, category = "Perl scripts' commands")
char *cmd
@ -323,6 +331,14 @@ command_bind(cmd, func, category = "Perl scripts' commands")
CODE:
perl_command_bind(cmd, category, func);
void
command_bind_last(cmd, func, category = "Perl scripts' commands")
char *cmd
char *category
char *func
CODE:
perl_command_bind_last(cmd, category, func);
void
command_runsub(cmd, data, server, item)
char *cmd

View File

@ -213,9 +213,12 @@ SIG_FUNC_DECL(0, first);
SIG_FUNC_DECL(1, default);
SIG_FUNC_DECL(2, last);
#define priority_get_func(priority) \
(priority == 0 ? sig_func_first : \
priority == 1 ? sig_func_default : sig_func_last)
#define perl_signal_get_func(rec) \
((rec)->priority == 0 ? sig_func_first : \
(rec)->priority == 1 ? sig_func_default : sig_func_last)
(priority_get_func((rec)->priority))
void perl_signal_add_to_int(const char *signal, const char *func,
int priority, int add_signal)
@ -319,14 +322,15 @@ void perl_signal_remove(const char *signal, const char *func)
g_free(fullfunc);
}
void perl_command_bind(const char *cmd, const char *category, const char *func)
void perl_command_bind_to(const char *cmd, const char *category,
const char *func, int priority)
{
char *signal;
command_bind(cmd, category, sig_func_default);
command_bind(cmd, category, priority_get_func(priority));
signal = g_strconcat("command ", cmd, NULL);
perl_signal_add_to_int(signal, func, 1, FALSE);
perl_signal_add_to_int(signal, func, priority, FALSE);
g_free(signal);
}

View File

@ -11,8 +11,15 @@ void perl_signal_add_to(const char *signal, const char *func, int priority);
void perl_signal_remove(const char *signal, const char *func);
void perl_command_bind(const char *cmd, const char *category,
const char *func);
void perl_command_bind_to(const char *cmd, const char *category,
const char *func, int priority);
#define perl_command_bind_first(cmd, category, func) \
perl_command_bind_to(cmd, category, func, 0)
#define perl_command_bind(cmd, category, func) \
perl_command_bind_to(cmd, category, func, 1)
#define perl_command_bind_last(cmd, category, func) \
perl_command_bind_to(cmd, category, func, 2)
void perl_command_unbind(const char *cmd, const char *func);
/* destroy all signals used by package */