mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 15:26:37 +02:00
Added keyboard handler to plugin API
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-03-26
|
||||
ChangeLog - 2006-03-30
|
||||
|
||||
|
||||
Version 0.1.9 (under dev!):
|
||||
* added keyboard handler to plugin API
|
||||
* improved script plugin loader
|
||||
* added hostname/IP option for connection to server
|
||||
* fixed --disable-plugins option in configure script
|
||||
|
||||
+364
-12
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
<bookinfo>
|
||||
|
||||
<title>WeeChat 0.1.8 - User guide</title>
|
||||
<title>WeeChat 0.1.9-cvs - User guide</title>
|
||||
<subtitle>Fast, light and extensible IRC client</subtitle>
|
||||
|
||||
<author>
|
||||
@@ -1801,6 +1801,29 @@ plugin->log (plugin, "freenode", "#weechat", "test");
|
||||
<option>function</option>: function called when message
|
||||
is received
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 3, following values are set in
|
||||
argv array:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = server name</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = IRC message</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = command arguments</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2036,6 +2059,29 @@ plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
|
||||
<option>function</option>: function called when command
|
||||
is executed
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 3, following values are set in
|
||||
argc array:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = server name</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = command</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = command arguments</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2123,6 +2169,119 @@ plugin->cmd_handler_add (plugin, "test", "Test command",
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 0, and argv is set to NULL.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_args</option>: arguments given to function
|
||||
when called
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_pointer</option>: pointer given to function
|
||||
when called
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: pointer to new timer handler.
|
||||
</para>
|
||||
<para>
|
||||
Note: function called has to return one of following values:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal>: function failed
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal>: function successfully
|
||||
completed
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Example:
|
||||
<screen>
|
||||
int my_timer (t_weechat_plugin *plugin, char *server, char *command,
|
||||
char *arguments, char *handler_args, void *handler_pointer)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "my timer");
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_keyboard_handler_add">
|
||||
<title>keyboard_handler_add</title>
|
||||
|
||||
<para>
|
||||
Prototype:
|
||||
<command>
|
||||
t_plugin_handler *keyboard_handler_add (t_weechat_plugin
|
||||
*plugin, t_plugin_handler_func *function,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Add a keyboard handler, called for any key pressed.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>plugin</option>: pointer to plugin structure
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 2 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[0] = touche appuyée (nom d'une fonction interne
|
||||
ou bien '*' suivi du code d'une touche si la touche
|
||||
n'est pas associée à une fonction)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[1] = "1" si la ligne de commande a changé suite
|
||||
à l'action de cette touche, "0" sinon
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2160,14 +2319,21 @@ plugin->cmd_handler_add (plugin, "test", "Test command",
|
||||
<para>
|
||||
Example:
|
||||
<screen>
|
||||
int my_timer (t_weechat_plugin *plugin, char *server, char *command,
|
||||
char *arguments, char *handler_args, void *handler_pointer)
|
||||
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "my timer");
|
||||
if (argc == 2)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "key pressed: %s", argv[0]);
|
||||
if (argv[1] && (argv[1][0] == '1'))
|
||||
plugin->print (plugin, NULL, NULL, "input text changed");
|
||||
else
|
||||
plugin->print (plugin, NULL, NULL, "input text not changed");
|
||||
}
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
plugin->keyboard_handler_add (plugin, &keyb_handler);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -2183,7 +2349,7 @@ plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Remove a handler.
|
||||
Remove a command or message handler.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
@@ -2353,6 +2519,24 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
|
||||
number of seconds since last key was pressed
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input</literal></entry>
|
||||
<entry>
|
||||
content of command line for current window
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_mask</literal></entry>
|
||||
<entry>
|
||||
content of color mask for command line
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_pos</literal></entry>
|
||||
<entry>
|
||||
cursor position in command line
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>weechat_dir</literal></entry>
|
||||
<entry>
|
||||
@@ -2400,9 +2584,12 @@ plugin->print (plugin, NULL, NULL,
|
||||
"(inactive for %s seconds)",
|
||||
version, nick, inactivity);
|
||||
|
||||
free (version);
|
||||
free (nick);
|
||||
free (inactivity);
|
||||
if (version)
|
||||
free (version);
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (inactivity)
|
||||
free (inactivity);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -4288,20 +4475,20 @@ sub my_timer
|
||||
|
||||
# python
|
||||
weechat.add_timer_handler(60, "my_timer")
|
||||
def my_timer(server, args):
|
||||
def my_timer():
|
||||
weechat.prnt("this is timer handler")
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_timer_handler(60, "my_timer")
|
||||
def my_timer(server, args)
|
||||
def my_timer()
|
||||
Weechat.print("this is timer handler")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_timer_handler(60, "my_timer")
|
||||
function my_timer(server, args)
|
||||
function my_timer()
|
||||
weechat.print("this is timer handler)
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
@@ -4325,6 +4512,110 @@ end
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>add_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Perl prototype:
|
||||
<command>
|
||||
weechat::add_keyboard_handler(message, function);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Python prototype:
|
||||
<command>
|
||||
weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ruby prototype:
|
||||
<command>
|
||||
Weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Lua prototype:
|
||||
<command>
|
||||
weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Add a keyboard handler, called for any key pressed.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: 1 if success, 0 if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
Examples:
|
||||
<screen>
|
||||
# perl
|
||||
weechat::add_keyboard_handler("my_keyboard");
|
||||
sub my_keyboard
|
||||
{
|
||||
my $key = shift;
|
||||
my $input_before = shift;
|
||||
my $input_after = shift;
|
||||
weechat::print("keyboard handler: key = '$key', "
|
||||
."input before = '$input_before' "
|
||||
."after = '$input_after'");
|
||||
return weechat::PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
# python
|
||||
weechat.add_keyboard_handler("my_keyboard")
|
||||
def my_keyboard(key, input_before, input_after):
|
||||
weechat.prnt("keyboard handler: key = '%s', " \
|
||||
"input before = '%s' after = '%s'"
|
||||
%(key, input_before, input_after))
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_keyboard_handler("my_keyboard")
|
||||
def my_keyboard(server, input_before, input_after)
|
||||
Weechat.print("keyboard handler: key = '#{key}', " \
|
||||
"input before = '#{input_before}' " \
|
||||
"after = '#{input_after}'")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_keyboard_handler("my_keyboard")
|
||||
function my_keyboard(server, input_before, input_after)
|
||||
weechat.print("keyboard handler: key = '"..key..
|
||||
"', input before = '"..input_before..
|
||||
"' after = '"..input_after.."'")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Note: function called has to return one of following values:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal>: function failed
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal>: function successfully
|
||||
completed
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_handler</title>
|
||||
|
||||
@@ -4452,6 +4743,67 @@ weechat.remove_timer_handler("my_timer")
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Perl prototype:
|
||||
<command>
|
||||
weechat::remove_keyboard_handler(function);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Python prototype:
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ruby prototype:
|
||||
<command>
|
||||
Weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Lua prototype:
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Remove a keyboard handler.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: 1 if success, 0 if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
Examples:
|
||||
<screen>
|
||||
# perl
|
||||
weechat::remove_keyboard_handler("my_keyboard");
|
||||
|
||||
# python
|
||||
weechat.remove_keyboard_handler("my_keyboard")
|
||||
|
||||
# ruby
|
||||
Weechat.remove_keyboard_handler("my_keyboard")
|
||||
|
||||
-- lua
|
||||
weechat.remove_keyboard_handler("my_keyboard")
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>command</title>
|
||||
|
||||
|
||||
+368
-10
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
<bookinfo>
|
||||
|
||||
<title>WeeChat 0.1.8 - Guide utilisateur</title>
|
||||
<title>WeeChat 0.1.9-cvs - Guide utilisateur</title>
|
||||
<subtitle>Client IRC rapide, léger et extensible</subtitle>
|
||||
|
||||
<author>
|
||||
@@ -1839,6 +1839,29 @@ plugin->log (plugin, "freenode", "#weechat", "test");
|
||||
<option>fonction</option> : fonction appelée lorsque le
|
||||
message est reçu
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 3 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = nom du serveur</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = message IRC</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = arguments de la commande</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2075,7 +2098,30 @@ plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée lorsque la
|
||||
commande est exécutée
|
||||
commande est exécutée.
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 3 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = nom du serveur</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = commande</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = arguments de la commande</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
@@ -2166,6 +2212,17 @@ plugin->cmd_handler_add (plugin, "test", "Commande test",
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 0 et argv vaut NULL.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2183,7 +2240,7 @@ plugin->cmd_handler_add (plugin, "test", "Commande test",
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : le pointeur vers le nouveau gestionnaire de
|
||||
messages.
|
||||
temps.
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
@@ -2216,6 +2273,118 @@ plugin->timer_handler_add (plugin, 60, &mon_timer);
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_keyboard_handler_add">
|
||||
<title>keyboard_handler_add</title>
|
||||
|
||||
<para>
|
||||
Prototype :
|
||||
<command>
|
||||
t_plugin_handler *keyboard_handler_add (t_weechat_plugin
|
||||
*plugin, t_plugin_handler_func *fonction,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ajoute un gestionnaire de clavier, appelé dès qu'une touche est
|
||||
pressée.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>plugin</option> : pointeur vers la structure
|
||||
de l'extension
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 2 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[0] = touche appuyée (nom d'une fonction interne
|
||||
ou bien '*' suivi du code d'une touche si la touche
|
||||
n'est pas associée à une fonction)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[1] = "1" si la ligne de commande a changé suite
|
||||
à l'action de cette touche, "0" sinon
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_args</option> : paramètres passés à la
|
||||
fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_pointer</option> : pointeur passé à la
|
||||
fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : le pointeur vers le nouveau gestionnaire de
|
||||
clavier.
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
suivantes :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal> : la fonction a échoué
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal> : la fonction a réussi
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Exemple :
|
||||
<screen>
|
||||
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "touche appuyée: %s", argv[0]);
|
||||
if (argv[1] && (argv[1][0] == '1'))
|
||||
plugin->print (plugin, NULL, NULL, "le texte d'entrée a changé");
|
||||
else
|
||||
plugin->print (plugin, NULL, NULL, "le texte d'entrée n'a pas changé");
|
||||
}
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->keyboard_handler_add (plugin, &keyb_handler);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_handler_remove">
|
||||
<title>handler_remove</title>
|
||||
|
||||
@@ -2227,7 +2396,7 @@ plugin->timer_handler_add (plugin, 60, &mon_timer);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Supprime un gestionnaire.
|
||||
Supprime un gestionnaire de commande ou message.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
@@ -2402,6 +2571,26 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
|
||||
touche a été appuyée
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input</literal></entry>
|
||||
<entry>
|
||||
contenu de la ligne de commande de la fenêtre
|
||||
courante
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_mask</literal></entry>
|
||||
<entry>
|
||||
contenu du masque de couleur de la ligne de
|
||||
commande
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_pos</literal></entry>
|
||||
<entry>
|
||||
position du curseur dans la ligne de commande
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>weechat_dir</literal></entry>
|
||||
<entry>
|
||||
@@ -2449,9 +2638,12 @@ plugin->print (plugin, NULL, NULL,
|
||||
"(inactif depuis %s secondes)",
|
||||
version, nick, inactivity);
|
||||
|
||||
free (version);
|
||||
free (nick);
|
||||
free (inactivity);
|
||||
if (version)
|
||||
free (version);
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (inactivity)
|
||||
free (inactivity);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -4369,20 +4561,20 @@ sub mon_timer
|
||||
|
||||
# python
|
||||
weechat.add_timer_handler(60, "mon_timer")
|
||||
def mon_timer(serveur, args):
|
||||
def mon_timer():
|
||||
weechat.prnt("ceci est le timer handler")
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_timer_handler(60, "mon_timer")
|
||||
def mon_timer(server, args)
|
||||
def mon_timer()
|
||||
Weechat.print("ceci est le timer handler")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_timer_handler(60, "mon_timer")
|
||||
function mon_timer(server, args)
|
||||
function mon_timer()
|
||||
weechat.print("ceci est le timer handler")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
@@ -4406,6 +4598,111 @@ end
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>add_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Prototype Perl :
|
||||
<command>
|
||||
weechat::add_keyboard_handler(fonction);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Python :
|
||||
<command>
|
||||
weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Ruby :
|
||||
<command>
|
||||
Weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Lua :
|
||||
<command>
|
||||
weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ajoute un gestionnaire de clavier, appelé dès qu'une touche est
|
||||
pressée.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
|
||||
</para>
|
||||
<para>
|
||||
Exemples :
|
||||
<screen>
|
||||
# perl
|
||||
weechat::add_keyboard_handler("mon_clavier");
|
||||
sub mon_clavier
|
||||
{
|
||||
my $key = shift;
|
||||
my $input_before = shift;
|
||||
my $input_after = shift;
|
||||
weechat::print("gestionnaire clavier: key = '$key', "
|
||||
."entrée avant = '$input_before' "
|
||||
."après = '$input_after'");
|
||||
return weechat::PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
# python
|
||||
weechat.add_keyboard_handler("mon_clavier")
|
||||
def mon_clavier(key, input_before, input_after):
|
||||
weechat.prnt("gestionnaire clavier: touche = '%s', " \
|
||||
"entrée avant = '%s' après = '%s'"
|
||||
%(key, input_before, input_after))
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_clavier_handler("mon_clavier")
|
||||
def mon_clavier(server, input_before, input_after)
|
||||
Weechat.print("gestionnaire clavier: touche = '#{key}', " \
|
||||
"entrée avant = '#{input_before}' " \
|
||||
"après = '#{input_after}'")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_clavier_handler("mon_clavier")
|
||||
function mon_clavier(server, input_before, input_after)
|
||||
weechat.print("gestionnaire clavier: touche = '"..key..
|
||||
"', entrée avant = '"..input_before..
|
||||
"' après = '"..input_after.."'")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
suivantes :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal> : la fonction a échoué
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal> : la fonction a réussi
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_handler</title>
|
||||
|
||||
@@ -4533,6 +4830,67 @@ weechat.remove_timer_handler("mon_timer")
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Prototype Perl :
|
||||
<command>
|
||||
weechat::remove_keyboard_handler(fonction);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Python :
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Ruby :
|
||||
<command>
|
||||
Weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Lua :
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Supprime un gestionnaire de clavier.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
|
||||
</para>
|
||||
<para>
|
||||
Exemples :
|
||||
<screen>
|
||||
# perl
|
||||
weechat::remove_keyboard_handler("mon_clavier");
|
||||
|
||||
# python
|
||||
weechat.remove_keyboard_handler("mon_clavier")
|
||||
|
||||
# ruby
|
||||
Weechat.remove_keyboard_handler("mon_clavier")
|
||||
|
||||
-- lua
|
||||
weechat.remove_keyboard_handler("mon_clavier")
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>command</title>
|
||||
|
||||
|
||||
+433
-402
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,10 @@
|
||||
#include "fifo.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* WeeChat internal commands */
|
||||
@@ -2539,6 +2542,44 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" (no command handler)\n"));
|
||||
}
|
||||
|
||||
/* timer handlers */
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" timer handlers:\n"));
|
||||
handler_found = 0;
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_TIMER)
|
||||
{
|
||||
handler_found = 1;
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" %d seconds\n"),
|
||||
ptr_handler->interval);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" (no timer handler)\n"));
|
||||
}
|
||||
|
||||
/* keyboard handlers */
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" keyboard handlers:\n"));
|
||||
handler_found = 0;
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_KEYBOARD)
|
||||
handler_found++;
|
||||
}
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
if (!handler_found)
|
||||
gui_printf (NULL, _(" (no keyboard handler)\n"));
|
||||
else
|
||||
gui_printf (NULL, _(" %d defined\n"),
|
||||
handler_found);
|
||||
}
|
||||
if (!weechat_plugins)
|
||||
{
|
||||
@@ -2583,6 +2624,8 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
|
||||
"without plugins support.\n"),
|
||||
"plugin");
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) channel;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
#endif /* PLUGINS */
|
||||
|
||||
@@ -424,6 +424,9 @@ completion_list_add_plugin_option (t_completion *completion)
|
||||
&completion->last_completion,
|
||||
ptr_option->name);
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -457,6 +460,9 @@ completion_list_add_plugin (t_completion *completion)
|
||||
&completion->last_completion,
|
||||
ptr_plugin->name);
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -634,6 +640,9 @@ completion_list_add_plugin_option_value (t_completion *completion)
|
||||
if (pos)
|
||||
pos[0] = ' ';
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,18 @@
|
||||
#include "../../irc/irc.h"
|
||||
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
t_gui_color gui_weechat_colors[] =
|
||||
{ { -1, 0, 0, "default" },
|
||||
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
|
||||
@@ -67,7 +79,7 @@ t_gui_color gui_weechat_colors[] =
|
||||
{ 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
int gui_irc_colors[16][2] =
|
||||
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
|
||||
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
|
||||
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
|
||||
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
|
||||
@@ -86,7 +98,7 @@ int gui_irc_colors[16][2] =
|
||||
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
|
||||
};
|
||||
|
||||
t_gui_color *gui_color[NUM_COLORS];
|
||||
t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
|
||||
/*
|
||||
@@ -205,13 +217,13 @@ gui_color_decode (unsigned char *string, int keep_colors)
|
||||
if (str_fg[0])
|
||||
{
|
||||
sscanf (str_fg, "%d", &fg);
|
||||
fg %= 16;
|
||||
fg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[fg][1];
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
sscanf (str_bg, "%d", &bg);
|
||||
bg %= 16;
|
||||
bg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[bg][1];
|
||||
}
|
||||
if (attr & A_BOLD)
|
||||
@@ -465,7 +477,7 @@ gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > NUM_COLORS - 1))
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
@@ -489,7 +501,7 @@ gui_color_get_pair (int num_color)
|
||||
void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
if ((num_color >= 0) && (num_color <= NUM_COLORS - 1))
|
||||
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
|
||||
{
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
|
||||
@@ -620,6 +632,35 @@ gui_window_chat_set_weechat_color (t_gui_window *window, int weechat_color)
|
||||
gui_color[weechat_color]->background);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_input_set_color: set color for an input window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_input_set_color (t_gui_window *window, int irc_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
fg = gui_irc_colors[irc_color][0];
|
||||
bg = gui_color[COLOR_WIN_INPUT]->background;
|
||||
|
||||
irc_color %= GUI_NUM_IRC_COLORS;
|
||||
if (gui_irc_colors[irc_color][1] & A_BOLD)
|
||||
wattron (window->win_input, A_BOLD);
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window->win_input, COLOR_PAIR(63));
|
||||
else
|
||||
{
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window->win_input, COLOR_PAIR((bg * 8) + fg));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_calculate_pos_size: calculate position and size for a buffer & subwindows
|
||||
*/
|
||||
@@ -2384,6 +2425,50 @@ gui_get_input_width (t_gui_window *window, char *nick)
|
||||
return (window->win_width - strlen (nick) - 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_draw_buffer_input_text: display text in input buffer, according to color mask
|
||||
*/
|
||||
|
||||
void
|
||||
gui_draw_buffer_input_text (t_gui_window *window, int input_width)
|
||||
{
|
||||
char *ptr_start, *ptr_next, saved_char;
|
||||
int pos_mask, size, last_color, color;
|
||||
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_1st_display);
|
||||
pos_mask = ptr_start - window->buffer->input_buffer;
|
||||
last_color = -1;
|
||||
while ((input_width > 0) && ptr_start && ptr_start[0])
|
||||
{
|
||||
ptr_next = utf8_next_char (ptr_start);
|
||||
if (ptr_next)
|
||||
{
|
||||
saved_char = ptr_next[0];
|
||||
ptr_next[0] = '\0';
|
||||
size = ptr_next - ptr_start;
|
||||
if (window->buffer->input_buffer_color_mask[pos_mask] != ' ')
|
||||
color = window->buffer->input_buffer_color_mask[pos_mask] - '0';
|
||||
else
|
||||
color = -1;
|
||||
if (color != last_color)
|
||||
{
|
||||
if (color == -1)
|
||||
gui_window_set_weechat_color (window->win_input, COLOR_WIN_INPUT);
|
||||
else
|
||||
gui_window_input_set_color (window, color);
|
||||
}
|
||||
last_color = color;
|
||||
wprintw (window->win_input, "%s", ptr_start);
|
||||
ptr_next[0] = saved_char;
|
||||
ptr_start = ptr_next;
|
||||
pos_mask += size;
|
||||
}
|
||||
else
|
||||
ptr_start = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_draw_buffer_input: draw input window for a buffer
|
||||
*/
|
||||
@@ -2456,9 +2541,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
|
||||
gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
snprintf (format, 32, "%%-%ds", input_width);
|
||||
if (ptr_win == gui_current_window)
|
||||
wprintw (ptr_win->win_input, format,
|
||||
utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_1st_display));
|
||||
gui_draw_buffer_input_text (ptr_win, input_width);
|
||||
else
|
||||
wprintw (ptr_win->win_input, format, "");
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
@@ -2480,9 +2563,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
|
||||
gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
snprintf (format, 32, "%%-%ds", input_width);
|
||||
if (ptr_win == gui_current_window)
|
||||
wprintw (ptr_win->win_input, format,
|
||||
utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_1st_display));
|
||||
gui_draw_buffer_input_text (ptr_win, input_width);
|
||||
else
|
||||
wprintw (ptr_win->win_input, format, "");
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
@@ -3503,7 +3584,7 @@ gui_rebuild_weechat_colors ()
|
||||
|
||||
if (has_colors ())
|
||||
{
|
||||
for (i = 0; i < NUM_COLORS; i++)
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../irc/irc.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -154,7 +157,9 @@ gui_input_default_key_bindings ()
|
||||
void
|
||||
gui_input_grab_end ()
|
||||
{
|
||||
char *expanded_key;
|
||||
char *expanded_key, *expanded_key2;
|
||||
int length;
|
||||
char *buffer_before_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
@@ -163,9 +168,27 @@ gui_input_grab_end ()
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
length = strlen (expanded_key) + 1 + 1;
|
||||
expanded_key2 = (char *) malloc (length);
|
||||
if (expanded_key2)
|
||||
{
|
||||
snprintf (expanded_key2, length, "*%s", expanded_key);
|
||||
(void) plugin_keyboard_handler_exec (expanded_key2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
free (expanded_key2);
|
||||
}
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
@@ -184,7 +207,8 @@ void
|
||||
gui_input_read ()
|
||||
{
|
||||
int key, i, insert_ok;
|
||||
char key_str[32];
|
||||
char key_str[32], key_str2[33];
|
||||
char *buffer_before_key;
|
||||
|
||||
i = 0;
|
||||
/* do not loop too much here (for example when big paste was made),
|
||||
@@ -283,10 +307,19 @@ gui_input_read ()
|
||||
switch (gui_current_window->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, key_str, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
snprintf (key_str2, sizeof (key_str2), "*%s", key_str);
|
||||
(void) plugin_keyboard_handler_exec (key_str2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
gui_exec_action_dcc (gui_current_window, key_str);
|
||||
|
||||
@@ -57,6 +57,19 @@
|
||||
#define COLOR_YELLOW 6
|
||||
#define COLOR_WHITE 7
|
||||
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
t_gui_color gui_weechat_colors[] =
|
||||
{ { -1, 0, 0, "default" },
|
||||
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
|
||||
@@ -76,7 +89,7 @@ t_gui_color gui_weechat_colors[] =
|
||||
{ 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
int gui_irc_colors[16][2] =
|
||||
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
|
||||
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
|
||||
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
|
||||
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
|
||||
@@ -95,7 +108,7 @@ int gui_irc_colors[16][2] =
|
||||
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
|
||||
};
|
||||
|
||||
t_gui_color *gui_color[NUM_COLORS];
|
||||
t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
GtkWidget *gtk_main_window;
|
||||
GtkWidget *vbox1;
|
||||
@@ -486,7 +499,7 @@ gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > NUM_COLORS - 1))
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
@@ -511,7 +524,7 @@ gui_color_get_pair (int num_color)
|
||||
/*void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
if ((num_color >= 0) && (num_color <= NUM_COLORS - 1))
|
||||
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
|
||||
{
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
|
||||
@@ -2114,7 +2127,7 @@ gui_rebuild_weechat_colors ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_COLORS; i++)
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
|
||||
+69
-23
@@ -95,18 +95,21 @@ gui_action_return (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
command = strdup (window->buffer->input_buffer);
|
||||
if (!command)
|
||||
return;
|
||||
history_buffer_add (window->buffer, window->buffer->input_buffer);
|
||||
history_global_add (window->buffer->input_buffer);
|
||||
window->buffer->input_buffer[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[0] = '\0';
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
window->buffer->completion.position = -1;
|
||||
window->buffer->ptr_history = NULL;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
user_command (SERVER(window->buffer), CHANNEL(window->buffer),
|
||||
command, 0);
|
||||
@@ -141,32 +144,46 @@ gui_action_tab (t_gui_window *window)
|
||||
window->buffer->completion.diff_size;
|
||||
window->buffer->input_buffer_length +=
|
||||
window->buffer->completion.diff_length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
for (i = window->buffer->input_buffer_size - 1;
|
||||
i >= window->buffer->completion.position_replace +
|
||||
(int)strlen (window->buffer->completion.word_found); i--)
|
||||
{
|
||||
window->buffer->input_buffer[i] =
|
||||
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
|
||||
window->buffer->input_buffer_color_mask[i] =
|
||||
window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = window->buffer->completion.position_replace +
|
||||
strlen (window->buffer->completion.word_found);
|
||||
i < window->buffer->input_buffer_size; i++)
|
||||
{
|
||||
window->buffer->input_buffer[i] =
|
||||
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
|
||||
window->buffer->input_buffer_color_mask[i] =
|
||||
window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
|
||||
}
|
||||
window->buffer->input_buffer_size +=
|
||||
window->buffer->completion.diff_size;
|
||||
window->buffer->input_buffer_length +=
|
||||
window->buffer->completion.diff_length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
}
|
||||
|
||||
strncpy (window->buffer->input_buffer + window->buffer->completion.position_replace,
|
||||
window->buffer->completion.word_found,
|
||||
strlen (window->buffer->completion.word_found));
|
||||
for (i = 0; i < (int)strlen (window->buffer->completion.word_found); i++)
|
||||
{
|
||||
window->buffer->input_buffer_color_mask[window->buffer->completion.position_replace + i] = ' ';
|
||||
}
|
||||
window->buffer->input_buffer_pos =
|
||||
utf8_pos (window->buffer->input_buffer,
|
||||
window->buffer->completion.position_replace) +
|
||||
@@ -238,12 +255,13 @@ gui_action_backspace (t_gui_window *window)
|
||||
pos_last = utf8_prev_char (window->buffer->input_buffer, pos);
|
||||
char_size = pos - pos_last;
|
||||
size_to_move = strlen (pos);
|
||||
memmove (pos_last, pos, size_to_move);
|
||||
gui_input_move (window->buffer, pos_last, pos, size_to_move);
|
||||
window->buffer->input_buffer_size -= char_size;
|
||||
window->buffer->input_buffer_length--;
|
||||
window->buffer->input_buffer_pos--;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -270,11 +288,12 @@ gui_action_delete (t_gui_window *window)
|
||||
pos_next = utf8_next_char (pos);
|
||||
char_size = pos_next - pos;
|
||||
size_to_move = strlen (pos_next);
|
||||
memmove (pos, pos_next, size_to_move);
|
||||
gui_input_move (window->buffer, pos, pos_next, size_to_move);
|
||||
window->buffer->input_buffer_size -= char_size;
|
||||
window->buffer->input_buffer_length--;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -327,13 +346,14 @@ gui_action_delete_previous_word (t_gui_window *window)
|
||||
|
||||
gui_action_clipboard_copy (string, size_deleted);
|
||||
|
||||
memmove (string, string + size_deleted, strlen (string + size_deleted));
|
||||
gui_input_move (window->buffer, string, string + size_deleted, strlen (string + size_deleted));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos -= length_deleted;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -367,12 +387,13 @@ gui_action_delete_next_word (t_gui_window *window)
|
||||
|
||||
gui_action_clipboard_copy(start, size_deleted);
|
||||
|
||||
memmove (start, string, strlen (string));
|
||||
gui_input_move (window->buffer, start, string, strlen (string));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -385,7 +406,7 @@ gui_action_delete_next_word (t_gui_window *window)
|
||||
void
|
||||
gui_action_delete_begin_of_line (t_gui_window *window)
|
||||
{
|
||||
int length_deleted, size_deleted;
|
||||
int length_deleted, size_deleted, pos_start;
|
||||
char *start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
@@ -394,18 +415,20 @@ gui_action_delete_begin_of_line (t_gui_window *window)
|
||||
{
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
size_deleted = start - window->buffer->input_buffer;
|
||||
length_deleted = utf8_strnlen (window->buffer->input_buffer, size_deleted);
|
||||
gui_action_clipboard_copy (window->buffer->input_buffer,
|
||||
start - window->buffer->input_buffer);
|
||||
|
||||
memmove (window->buffer->input_buffer, start, strlen (start));
|
||||
gui_input_move (window->buffer, window->buffer->input_buffer, start, strlen (start));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -420,19 +443,21 @@ void
|
||||
gui_action_delete_end_of_line (t_gui_window *window)
|
||||
{
|
||||
char *start;
|
||||
int size_deleted, length_deleted;
|
||||
int size_deleted, length_deleted, pos_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
size_deleted = strlen (start);
|
||||
length_deleted = utf8_strlen (start);
|
||||
gui_action_clipboard_copy (start, size_deleted);
|
||||
start[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[pos_start] = '\0';
|
||||
window->buffer->input_buffer_size = strlen (window->buffer->input_buffer);
|
||||
window->buffer->input_buffer_length = utf8_strlen (window->buffer->input_buffer);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -448,10 +473,11 @@ gui_action_delete_line (t_gui_window *window)
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
window->buffer->input_buffer[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[0] = '\0';
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -465,7 +491,8 @@ void
|
||||
gui_action_transpose_chars (t_gui_window *window)
|
||||
{
|
||||
char *start, *prev_char, saved_char[4];
|
||||
int size_current_char;
|
||||
int size_current_char, size_start_char;
|
||||
int pos_prev_char, pos_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
@@ -476,14 +503,23 @@ gui_action_transpose_chars (t_gui_window *window)
|
||||
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
prev_char = utf8_prev_char (window->buffer->input_buffer,
|
||||
start);
|
||||
pos_prev_char = prev_char - window->buffer->input_buffer;
|
||||
size_current_char = start - prev_char;
|
||||
size_start_char = utf8_char_size (start);
|
||||
|
||||
memcpy (saved_char, prev_char, size_current_char);
|
||||
memcpy (prev_char, start, utf8_char_size (start));
|
||||
start = utf8_next_char (prev_char);
|
||||
memcpy (prev_char, start, size_start_char);
|
||||
memcpy (start, saved_char, size_current_char);
|
||||
|
||||
memcpy (saved_char, window->buffer->input_buffer_color_mask + pos_prev_char, size_current_char);
|
||||
memcpy (window->buffer->input_buffer_color_mask + pos_prev_char,
|
||||
window->buffer->input_buffer_color_mask + pos_start, size_start_char);
|
||||
memcpy (window->buffer->input_buffer_color_mask + pos_start,
|
||||
saved_char, size_current_char);
|
||||
|
||||
window->buffer->input_buffer_pos++;
|
||||
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
@@ -693,6 +729,7 @@ gui_action_up (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
history_buffer_add (window->buffer, window->buffer->input_buffer);
|
||||
history_global_add (window->buffer->input_buffer);
|
||||
}
|
||||
@@ -702,6 +739,7 @@ gui_action_up (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
if (window->buffer->ptr_history->prev_history->text)
|
||||
free(window->buffer->ptr_history->prev_history->text);
|
||||
window->buffer->ptr_history->prev_history->text = strdup (window->buffer->input_buffer);
|
||||
@@ -711,12 +749,13 @@ gui_action_up (t_gui_window *window)
|
||||
strlen (window->buffer->ptr_history->text);
|
||||
window->buffer->input_buffer_length =
|
||||
utf8_strlen (window->buffer->ptr_history->text);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
strcpy (window->buffer->input_buffer,
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -745,12 +784,13 @@ gui_action_up_global (t_gui_window *window)
|
||||
strlen (history_global_ptr->text);
|
||||
window->buffer->input_buffer_length =
|
||||
utf8_strlen (history_global_ptr->text);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
strcpy (window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -810,13 +850,16 @@ gui_action_down (t_gui_window *window)
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
}
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
if (window->buffer->ptr_history)
|
||||
{
|
||||
strcpy (window->buffer->input_buffer,
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -846,13 +889,16 @@ gui_action_down_global (t_gui_window *window)
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
}
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
if (history_global_ptr)
|
||||
{
|
||||
strcpy (window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+87
-32
@@ -392,10 +392,15 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
|
||||
{
|
||||
new_buffer->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
|
||||
new_buffer->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer_color_mask = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer[0] = '\0';
|
||||
new_buffer->input_buffer_color_mask[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
new_buffer->input_buffer = NULL;
|
||||
new_buffer->input_buffer_color_mask = NULL;
|
||||
}
|
||||
new_buffer->input_buffer_size = 0;
|
||||
new_buffer->input_buffer_length = 0;
|
||||
new_buffer->input_buffer_pos = 0;
|
||||
@@ -709,6 +714,8 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
|
||||
|
||||
if (buffer->input_buffer)
|
||||
free (buffer->input_buffer);
|
||||
if (buffer->input_buffer_color_mask)
|
||||
free (buffer->input_buffer_color_mask);
|
||||
|
||||
completion_free (&(buffer->completion));
|
||||
|
||||
@@ -1206,12 +1213,12 @@ gui_infobar_remove_all ()
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_optimize_input_buffer_size: optimize input buffer size by adding
|
||||
* or deleting data block (predefined size)
|
||||
* gui_input_optimize_size: optimize input buffer size by adding
|
||||
* or deleting data block (predefined size)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_optimize_input_buffer_size (t_gui_buffer *buffer)
|
||||
gui_input_optimize_size (t_gui_buffer *buffer)
|
||||
{
|
||||
int optimal_size;
|
||||
|
||||
@@ -1223,10 +1230,46 @@ gui_optimize_input_buffer_size (t_gui_buffer *buffer)
|
||||
{
|
||||
buffer->input_buffer_alloc = optimal_size;
|
||||
buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
|
||||
buffer->input_buffer_color_mask = realloc (buffer->input_buffer_color_mask,
|
||||
optimal_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_init_color_mask: initialize color mask for input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_init_color_mask (t_gui_buffer *buffer)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (buffer->has_input)
|
||||
{
|
||||
for (i = 0; i < buffer->input_buffer_size; i++)
|
||||
buffer->input_buffer_color_mask[i] = ' ';
|
||||
buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_move: move data in input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_move (t_gui_buffer *buffer, char *target, char *source, int size)
|
||||
{
|
||||
int pos_source, pos_target;
|
||||
|
||||
pos_target = target - buffer->input_buffer;
|
||||
pos_source = source - buffer->input_buffer;
|
||||
|
||||
memmove (target, source, size);
|
||||
memmove (buffer->input_buffer_color_mask + pos_target,
|
||||
buffer->input_buffer_color_mask + pos_source, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_exec_action_dcc: execute an action on a DCC after a user input
|
||||
* return -1 if DCC buffer was closed due to action,
|
||||
@@ -1364,7 +1407,7 @@ gui_exec_action_raw_data (t_gui_window *window, char *actions)
|
||||
int
|
||||
gui_insert_string_input (t_gui_window *window, char *string, int pos)
|
||||
{
|
||||
int size, length;
|
||||
int i, pos_start, size, length;
|
||||
char *ptr_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
@@ -1378,15 +1421,26 @@ gui_insert_string_input (t_gui_window *window, char *string, int pos)
|
||||
/* increase buffer size */
|
||||
window->buffer->input_buffer_size += size;
|
||||
window->buffer->input_buffer_length += length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
|
||||
/* move end of string to the right */
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
|
||||
pos_start = ptr_start - window->buffer->input_buffer;
|
||||
memmove (ptr_start + size, ptr_start, strlen (ptr_start));
|
||||
memmove (window->buffer->input_buffer_color_mask + pos_start + size,
|
||||
window->buffer->input_buffer_color_mask + pos_start,
|
||||
strlen (window->buffer->input_buffer_color_mask + pos_start));
|
||||
|
||||
/* insert new string */
|
||||
strncpy (utf8_add_offset (window->buffer->input_buffer, pos), string, size);
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
|
||||
pos_start = ptr_start - window->buffer->input_buffer;
|
||||
strncpy (ptr_start, string, size);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
window->buffer->input_buffer_color_mask[pos_start + i] = ' ';
|
||||
}
|
||||
return length;
|
||||
}
|
||||
return 0;
|
||||
@@ -1869,32 +1923,33 @@ gui_buffer_print_log (t_gui_buffer *buffer)
|
||||
int num;
|
||||
|
||||
weechat_log_printf ("[buffer (addr:0x%X)]\n", buffer);
|
||||
weechat_log_printf (" num_displayed. . . . : %d\n", buffer->num_displayed);
|
||||
weechat_log_printf (" number . . . . . . . : %d\n", buffer->number);
|
||||
weechat_log_printf (" server . . . . . . . : 0x%X\n", buffer->server);
|
||||
weechat_log_printf (" all_servers. . . . . : %d\n", buffer->all_servers);
|
||||
weechat_log_printf (" channel. . . . . . . : 0x%X\n", buffer->channel);
|
||||
weechat_log_printf (" type . . . . . . . . : %d\n", buffer->type);
|
||||
weechat_log_printf (" lines. . . . . . . . : 0x%X\n", buffer->lines);
|
||||
weechat_log_printf (" last_line. . . . . . : 0x%X\n", buffer->last_line);
|
||||
weechat_log_printf (" last_read_line . . . : 0x%X\n", buffer->last_read_line);
|
||||
weechat_log_printf (" num_lines. . . . . . : %d\n", buffer->num_lines);
|
||||
weechat_log_printf (" line_complete. . . . : %d\n", buffer->line_complete);
|
||||
weechat_log_printf (" notify_level . . . . : %d\n", buffer->notify_level);
|
||||
weechat_log_printf (" log_filename . . . . : '%s'\n", buffer->log_filename);
|
||||
weechat_log_printf (" log_file . . . . . . : 0x%X\n", buffer->log_file);
|
||||
weechat_log_printf (" has_input. . . . . . : %d\n", buffer->has_input);
|
||||
weechat_log_printf (" input_buffer . . . . : '%s'\n", buffer->input_buffer);
|
||||
weechat_log_printf (" input_buffer_alloc . : %d\n", buffer->input_buffer_alloc);
|
||||
weechat_log_printf (" input_buffer_size. . : %d\n", buffer->input_buffer_size);
|
||||
weechat_log_printf (" input_buffer_length. : %d\n", buffer->input_buffer_length);
|
||||
weechat_log_printf (" input_buffer_pos . . : %d\n", buffer->input_buffer_pos);
|
||||
weechat_log_printf (" input_buffer_1st_disp: %d\n", buffer->input_buffer_1st_display);
|
||||
weechat_log_printf (" history. . . . . . . : 0x%X\n", buffer->history);
|
||||
weechat_log_printf (" last_history . . . . : 0x%X\n", buffer->last_history);
|
||||
weechat_log_printf (" ptr_history. . . . . : 0x%X\n", buffer->ptr_history);
|
||||
weechat_log_printf (" prev_buffer. . . . . : 0x%X\n", buffer->prev_buffer);
|
||||
weechat_log_printf (" next_buffer. . . . . : 0x%X\n", buffer->next_buffer);
|
||||
weechat_log_printf (" num_displayed. . . . . : %d\n", buffer->num_displayed);
|
||||
weechat_log_printf (" number . . . . . . . . : %d\n", buffer->number);
|
||||
weechat_log_printf (" server . . . . . . . . : 0x%X\n", buffer->server);
|
||||
weechat_log_printf (" all_servers. . . . . . : %d\n", buffer->all_servers);
|
||||
weechat_log_printf (" channel. . . . . . . . : 0x%X\n", buffer->channel);
|
||||
weechat_log_printf (" type . . . . . . . . . : %d\n", buffer->type);
|
||||
weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", buffer->lines);
|
||||
weechat_log_printf (" last_line. . . . . . . : 0x%X\n", buffer->last_line);
|
||||
weechat_log_printf (" last_read_line . . . . : 0x%X\n", buffer->last_read_line);
|
||||
weechat_log_printf (" num_lines. . . . . . . : %d\n", buffer->num_lines);
|
||||
weechat_log_printf (" line_complete. . . . . : %d\n", buffer->line_complete);
|
||||
weechat_log_printf (" notify_level . . . . . : %d\n", buffer->notify_level);
|
||||
weechat_log_printf (" log_filename . . . . . : '%s'\n", buffer->log_filename);
|
||||
weechat_log_printf (" log_file . . . . . . . : 0x%X\n", buffer->log_file);
|
||||
weechat_log_printf (" has_input. . . . . . . : %d\n", buffer->has_input);
|
||||
weechat_log_printf (" input_buffer . . . . . : '%s'\n", buffer->input_buffer);
|
||||
weechat_log_printf (" input_buffer_color_mask: '%s'\n", buffer->input_buffer_color_mask);
|
||||
weechat_log_printf (" input_buffer_alloc . . : %d\n", buffer->input_buffer_alloc);
|
||||
weechat_log_printf (" input_buffer_size. . . : %d\n", buffer->input_buffer_size);
|
||||
weechat_log_printf (" input_buffer_length. . : %d\n", buffer->input_buffer_length);
|
||||
weechat_log_printf (" input_buffer_pos . . . : %d\n", buffer->input_buffer_pos);
|
||||
weechat_log_printf (" input_buffer_1st_disp. : %d\n", buffer->input_buffer_1st_display);
|
||||
weechat_log_printf (" history. . . . . . . . : 0x%X\n", buffer->history);
|
||||
weechat_log_printf (" last_history . . . . . : 0x%X\n", buffer->last_history);
|
||||
weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", buffer->ptr_history);
|
||||
weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", buffer->prev_buffer);
|
||||
weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", buffer->next_buffer);
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" => last 100 lines:\n");
|
||||
|
||||
|
||||
+18
-1
@@ -32,6 +32,10 @@
|
||||
#include "gui.h"
|
||||
#include "../common/command.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
t_gui_key *gui_keys = NULL;
|
||||
t_gui_key *last_gui_key = NULL;
|
||||
@@ -506,7 +510,8 @@ gui_key_pressed (char *key_str)
|
||||
{
|
||||
int first_key;
|
||||
t_gui_key *ptr_key;
|
||||
|
||||
char *buffer_before_key;
|
||||
|
||||
/* add key to buffer */
|
||||
first_key = (gui_key_buffer[0] == '\0');
|
||||
strcat (gui_key_buffer, key_str);
|
||||
@@ -525,6 +530,9 @@ gui_key_pressed (char *key_str)
|
||||
if (ascii_strcasecmp (ptr_key->key, gui_key_buffer) == 0)
|
||||
{
|
||||
/* exact combo found => execute function or command */
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_key_buffer[0] = '\0';
|
||||
if (ptr_key->command)
|
||||
user_command (SERVER(gui_current_window->buffer),
|
||||
@@ -532,6 +540,15 @@ gui_key_pressed (char *key_str)
|
||||
ptr_key->command, 0);
|
||||
else
|
||||
(void)(ptr_key->function)(gui_current_window);
|
||||
#ifdef PLUGINS
|
||||
(void) plugin_keyboard_handler_exec (
|
||||
(ptr_key->command) ?
|
||||
ptr_key->command : gui_key_function_search_by_ptr (ptr_key->function),
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+8
-15
@@ -26,18 +26,6 @@
|
||||
|
||||
#define INPUT_BUFFER_BLOCK_SIZE 256
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
#define COLOR_WIN_NICK_NUMBER 10
|
||||
|
||||
typedef enum t_weechat_color t_weechat_color;
|
||||
@@ -103,9 +91,11 @@ enum t_weechat_color
|
||||
COLOR_DCC_DONE,
|
||||
COLOR_DCC_FAILED,
|
||||
COLOR_DCC_ABORTED,
|
||||
NUM_COLORS
|
||||
GUI_NUM_COLORS
|
||||
};
|
||||
|
||||
#define GUI_NUM_IRC_COLORS 16
|
||||
|
||||
/* attributes in IRC messages for color & style (bold, ..) */
|
||||
|
||||
#define GUI_ATTR_BOLD_CHAR '\x02'
|
||||
@@ -252,6 +242,7 @@ struct t_gui_buffer
|
||||
/* inupt buffer */
|
||||
int has_input; /* = 1 if buffer has input (DCC has not)*/
|
||||
char *input_buffer; /* input buffer */
|
||||
char *input_buffer_color_mask; /* color mask for input buffer */
|
||||
int input_buffer_alloc; /* input buffer: allocated size in mem */
|
||||
int input_buffer_size; /* buffer size in bytes */
|
||||
int input_buffer_length; /* number of chars in buffer */
|
||||
@@ -402,7 +393,7 @@ extern int gui_key_grab_count;
|
||||
extern char *gui_input_clipboard;
|
||||
extern time_t gui_last_activity_time;
|
||||
|
||||
extern t_gui_color *gui_color[NUM_COLORS];
|
||||
extern t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
/* GUI independent functions: windows & buffers */
|
||||
|
||||
@@ -427,7 +418,9 @@ extern int gui_word_strlen (t_gui_window *, char *);
|
||||
extern int gui_word_real_pos (t_gui_window *, char *, int);
|
||||
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_printf_raw_data (void *, int, char *);
|
||||
extern void gui_optimize_input_buffer_size (t_gui_buffer *);
|
||||
extern void gui_input_optimize_size (t_gui_buffer *);
|
||||
extern void gui_input_init_color_mask (t_gui_buffer *);
|
||||
extern void gui_input_move (t_gui_buffer *, char *, char *, int );
|
||||
extern void gui_exec_action_dcc (t_gui_window *, char *);
|
||||
extern void gui_exec_action_raw_data (t_gui_window *, char *);
|
||||
extern int gui_insert_string_input (t_gui_window *, char *, int);
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
#include "../common/hotlist.h"
|
||||
#include "../common/weeconfig.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
char *irc_last_command_received = NULL;
|
||||
|
||||
@@ -316,6 +316,22 @@ weechat_plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_keyboard_handler_add: add a keyboard handler
|
||||
*/
|
||||
|
||||
t_plugin_handler *
|
||||
weechat_plugin_keyboard_handler_add (t_weechat_plugin *plugin,
|
||||
t_plugin_handler_func *handler_func,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (plugin && handler_func)
|
||||
return plugin_keyboard_handler_add (plugin, handler_func,
|
||||
handler_args, handler_pointer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_handler_remove: remove a WeeChat handler
|
||||
*/
|
||||
@@ -385,7 +401,7 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
time_t inactivity;
|
||||
char *inactivity_str;
|
||||
char *return_str;
|
||||
|
||||
if (!plugin || !info)
|
||||
return NULL;
|
||||
@@ -420,11 +436,39 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
|
||||
inactivity = 0;
|
||||
else
|
||||
inactivity = time (NULL) - gui_last_activity_time;
|
||||
inactivity_str = (char *) malloc (128);
|
||||
if (!inactivity_str)
|
||||
return_str = (char *) malloc (32);
|
||||
if (!return_str)
|
||||
return NULL;
|
||||
snprintf (inactivity_str, 128, "%ld", inactivity);
|
||||
return inactivity_str;
|
||||
snprintf (return_str, 32, "%ld", inactivity);
|
||||
return return_str;
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
return strdup (gui_current_window->buffer->input_buffer);
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input_mask") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
return strdup (gui_current_window->buffer->input_buffer_color_mask);
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input_pos") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
return_str = (char *) malloc (32);
|
||||
if (!return_str)
|
||||
return NULL;
|
||||
snprintf (return_str, 32, "%d",
|
||||
gui_current_window->buffer->input_buffer_pos);
|
||||
return return_str;
|
||||
}
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
|
||||
/* below are infos that need server to return value */
|
||||
@@ -1009,3 +1053,38 @@ weechat_plugin_free_nick_info (t_weechat_plugin *plugin, t_plugin_nick_info *nic
|
||||
nick_info = new_nick_info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_input_color: add color in input buffer
|
||||
* if color < 0, input buffer is refresh
|
||||
* if start < 0 or length <= 0, color mask is reinit
|
||||
* otherwise, color is applied from start to start + length
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_plugin_input_color (t_weechat_plugin *plugin, int color, int start, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!plugin
|
||||
|| (!gui_current_window->buffer->has_input)
|
||||
|| (gui_current_window->buffer->input_buffer_size == 0))
|
||||
return;
|
||||
|
||||
if (color < 0)
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
else
|
||||
{
|
||||
if ((start < 0) || (length <= 0))
|
||||
gui_input_init_color_mask (gui_current_window->buffer);
|
||||
else
|
||||
{
|
||||
color %= GUI_NUM_IRC_COLORS;
|
||||
for (i = start; i < start + length; i++)
|
||||
{
|
||||
gui_current_window->buffer->input_buffer_color_mask[i] =
|
||||
'0' + color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+112
-9
@@ -370,6 +370,62 @@ plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
|
||||
return new_handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_keyboard_handler_add: add a timer handler
|
||||
* arguments:
|
||||
* 1. the plugin pointer
|
||||
* 2. the interval between two calls
|
||||
* 3. the handler function
|
||||
* 4. handler args: a string given to
|
||||
* handler when called (used by scripts)
|
||||
* 5. handler pointer: a pointer given to
|
||||
* handler when called (used by scripts)
|
||||
*/
|
||||
|
||||
t_plugin_handler *
|
||||
plugin_keyboard_handler_add (t_weechat_plugin *plugin,
|
||||
t_plugin_handler_func *handler_func,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
t_plugin_handler *new_handler;
|
||||
|
||||
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
|
||||
if (new_handler)
|
||||
{
|
||||
new_handler->type = HANDLER_KEYBOARD;
|
||||
new_handler->irc_command = NULL;
|
||||
new_handler->command = NULL;
|
||||
new_handler->description = NULL;
|
||||
new_handler->arguments = NULL;
|
||||
new_handler->arguments_description = NULL;
|
||||
new_handler->completion_template = NULL;
|
||||
new_handler->interval = 0;
|
||||
new_handler->remaining = 0;
|
||||
new_handler->handler = handler_func;
|
||||
new_handler->handler_args = (handler_args) ? strdup (handler_args) : NULL;
|
||||
new_handler->handler_pointer = handler_pointer;
|
||||
new_handler->running = 0;
|
||||
|
||||
/* add new handler to list */
|
||||
new_handler->prev_handler = plugin->last_handler;
|
||||
new_handler->next_handler = NULL;
|
||||
if (plugin->handlers)
|
||||
(plugin->last_handler)->next_handler = new_handler;
|
||||
else
|
||||
plugin->handlers = new_handler;
|
||||
plugin->last_handler = new_handler;
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s plugin %s: unable to add keyboard handler (not enough memory)\n"),
|
||||
WEECHAT_ERROR, plugin->name);
|
||||
return NULL;
|
||||
}
|
||||
return new_handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_msg_handler_exec: execute a message handler
|
||||
* return: code for informing WeeChat whether message
|
||||
@@ -382,6 +438,11 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code, final_return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = server;
|
||||
argv[1] = irc_command;
|
||||
argv[2] = irc_message;
|
||||
|
||||
final_return_code = PLUGIN_RC_OK;
|
||||
|
||||
@@ -398,9 +459,7 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
|
||||
{
|
||||
ptr_handler->running = 1;
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
server,
|
||||
irc_command,
|
||||
irc_message,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
ptr_handler->running = 0;
|
||||
@@ -432,6 +491,11 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = server;
|
||||
argv[1] = command;
|
||||
argv[2] = arguments;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
@@ -446,9 +510,7 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
|
||||
{
|
||||
ptr_handler->running = 1;
|
||||
return_code = (int) (ptr_handler->handler) (ptr_plugin,
|
||||
server,
|
||||
command,
|
||||
arguments,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer);
|
||||
ptr_handler->running = 0;
|
||||
@@ -488,9 +550,7 @@ plugin_timer_handler_exec ()
|
||||
if (ptr_handler->remaining <= 0)
|
||||
{
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0, NULL,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
ptr_handler->remaining = ptr_handler->interval;
|
||||
@@ -504,6 +564,47 @@ plugin_timer_handler_exec ()
|
||||
return final_return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_keyboard_handler_exec: execute all keyboard handlers
|
||||
* return: PLUGIN_RC_OK if all ok
|
||||
* PLUGIN_RC_KO if at least one handler failed
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_keyboard_handler_exec (char *key, char *input_before, char *input_after)
|
||||
{
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code, final_return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = key;
|
||||
argv[1] = input_before;
|
||||
argv[2] = input_after;
|
||||
|
||||
final_return_code = PLUGIN_RC_OK;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_KEYBOARD)
|
||||
{
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
if (return_code == PLUGIN_RC_KO)
|
||||
final_return_code = PLUGIN_RC_KO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return final_return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_handler_remove: remove a handler for a plugin
|
||||
*/
|
||||
@@ -736,6 +837,7 @@ plugin_load (char *filename)
|
||||
new_plugin->msg_handler_add = &weechat_plugin_msg_handler_add;
|
||||
new_plugin->cmd_handler_add = &weechat_plugin_cmd_handler_add;
|
||||
new_plugin->timer_handler_add = &weechat_plugin_timer_handler_add;
|
||||
new_plugin->keyboard_handler_add = &weechat_plugin_keyboard_handler_add;
|
||||
new_plugin->handler_remove = &weechat_plugin_handler_remove;
|
||||
new_plugin->handler_remove_all = &weechat_plugin_handler_remove_all;
|
||||
new_plugin->print = &weechat_plugin_print;
|
||||
@@ -757,6 +859,7 @@ plugin_load (char *filename)
|
||||
new_plugin->free_channel_info = &weechat_plugin_free_channel_info;
|
||||
new_plugin->get_nick_info = &weechat_plugin_get_nick_info;
|
||||
new_plugin->free_nick_info = &weechat_plugin_free_nick_info;
|
||||
new_plugin->input_color = &weechat_plugin_input_color;
|
||||
|
||||
/* handlers */
|
||||
new_plugin->handlers = NULL;
|
||||
|
||||
@@ -48,9 +48,13 @@ extern t_plugin_handler *plugin_cmd_handler_add (t_weechat_plugin *, char *,
|
||||
extern t_plugin_handler *plugin_timer_handler_add (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern t_plugin_handler *plugin_keyboard_handler_add (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern int plugin_msg_handler_exec (char *, char *, char *);
|
||||
extern int plugin_cmd_handler_exec (char *, char *, char *);
|
||||
extern int plugin_timer_handler_exec ();
|
||||
extern int plugin_keyboard_handler_exec (char *, char *, char *);
|
||||
extern void plugin_handler_remove (t_weechat_plugin *,
|
||||
t_plugin_handler *);
|
||||
extern void plugin_handler_remove_all (t_weechat_plugin *);
|
||||
|
||||
@@ -54,7 +54,7 @@ lua_State *lua_current_interpreter = NULL;
|
||||
int
|
||||
weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
|
||||
lua_current_interpreter = script->interpreter;
|
||||
@@ -62,10 +62,19 @@ weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
lua_getglobal (lua_current_interpreter, function);
|
||||
lua_current_script = script;
|
||||
|
||||
lua_pushstring (lua_current_interpreter, server == NULL ? "" : server);
|
||||
lua_pushstring (lua_current_interpreter, arguments == NULL ? "" : arguments);
|
||||
if (arg1)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, (arg1) ? arg1 : "");
|
||||
if (arg2)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, (arg2) ? arg2 : "");
|
||||
if (arg3)
|
||||
lua_pushstring (lua_current_interpreter, (arg3) ? arg3 : "");
|
||||
}
|
||||
}
|
||||
|
||||
if ( lua_pcall(lua_current_interpreter, 2, 1, 0) != 0)
|
||||
if (lua_pcall (lua_current_interpreter,
|
||||
(arg1) ? ((arg2) ? ((arg3) ? 3 : 2) : 1) : 0, 1, 0) != 0)
|
||||
{
|
||||
plugin->print_server (plugin,
|
||||
"Lua error: unable to run function \"%s\"",
|
||||
@@ -80,19 +89,52 @@ weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_handler: general message and command handler for Lua
|
||||
* weechat_lua_cmd_msg_handler: general command/message handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_lua_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_timer_handler: general timer handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_keyboard_handler: general keyboard handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 2)
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,6 +146,7 @@ weechat_lua_register (lua_State *L)
|
||||
{
|
||||
const char *name, *version, *shutdown_func, *description;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -179,6 +222,7 @@ weechat_lua_print (lua_State *L)
|
||||
{
|
||||
const char *message, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -199,24 +243,24 @@ weechat_lua_print (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"print\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"print\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->print (lua_plugin,
|
||||
@@ -237,6 +281,7 @@ weechat_lua_print_infobar (lua_State *L)
|
||||
{
|
||||
const char *message;
|
||||
int delay, n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -280,6 +325,7 @@ static int
|
||||
weechat_lua_remove_infobar (lua_State *L)
|
||||
{
|
||||
int n, how_many;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -314,6 +360,7 @@ weechat_lua_log (lua_State *L)
|
||||
{
|
||||
const char *message, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -334,24 +381,24 @@ weechat_lua_log (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"log\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"log\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->log (lua_plugin,
|
||||
@@ -372,6 +419,7 @@ weechat_lua_command (lua_State *L)
|
||||
{
|
||||
const char *command, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -392,24 +440,24 @@ weechat_lua_command (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"command\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"command\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->exec_command (lua_plugin,
|
||||
@@ -430,6 +478,7 @@ weechat_lua_add_message_handler (lua_State *L)
|
||||
{
|
||||
const char *irc_command, *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -460,7 +509,8 @@ weechat_lua_add_message_handler (lua_State *L)
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->msg_handler_add (lua_plugin, (char *) irc_command,
|
||||
weechat_lua_handler, (char *) function,
|
||||
weechat_lua_cmd_msg_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
@@ -481,6 +531,7 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
const char *command, *function, *description, *arguments, *arguments_description;
|
||||
const char *completion_template;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -504,24 +555,24 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 2:
|
||||
command = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 6:
|
||||
command = lua_tostring (lua_current_interpreter, -6);
|
||||
function = lua_tostring (lua_current_interpreter, -5);
|
||||
description = lua_tostring (lua_current_interpreter, -4);
|
||||
arguments = lua_tostring (lua_current_interpreter, -3);
|
||||
arguments_description = lua_tostring (lua_current_interpreter, -2);
|
||||
completion_template = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_command_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 2:
|
||||
command = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 6:
|
||||
command = lua_tostring (lua_current_interpreter, -6);
|
||||
function = lua_tostring (lua_current_interpreter, -5);
|
||||
description = lua_tostring (lua_current_interpreter, -4);
|
||||
arguments = lua_tostring (lua_current_interpreter, -3);
|
||||
arguments_description = lua_tostring (lua_current_interpreter, -2);
|
||||
completion_template = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_command_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!lua_plugin->cmd_handler_add (lua_plugin,
|
||||
@@ -530,7 +581,7 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
(char *) arguments,
|
||||
(char *) arguments_description,
|
||||
(char *) completion_template,
|
||||
weechat_lua_handler,
|
||||
weechat_lua_cmd_msg_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
@@ -552,6 +603,7 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
int interval;
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -582,7 +634,8 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->timer_handler_add (lua_plugin, interval,
|
||||
weechat_lua_handler, (char *) function,
|
||||
weechat_lua_timer_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
@@ -594,7 +647,57 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_handler: remove a handler
|
||||
* weechat_lua_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_add_keyboard_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n != 1)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->keyboard_handler_add (lua_plugin,
|
||||
weechat_lua_keyboard_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_handler: remove a command/message handler
|
||||
*/
|
||||
|
||||
static int
|
||||
@@ -602,6 +705,7 @@ weechat_lua_remove_handler (lua_State *L)
|
||||
{
|
||||
const char *command, *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -647,6 +751,7 @@ weechat_lua_remove_timer_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -681,6 +786,50 @@ weechat_lua_remove_timer_handler (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_remove_keyboard_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n != 1)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
weechat_script_remove_keyboard_handler (lua_plugin, lua_current_script,
|
||||
(char *) function);
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_get_info: get various infos
|
||||
*/
|
||||
@@ -691,6 +840,7 @@ weechat_lua_get_info (lua_State *L)
|
||||
const char *arg, *server_name;
|
||||
char *info;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -710,19 +860,19 @@ weechat_lua_get_info (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
arg = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
arg = lua_tostring (lua_current_interpreter, -2);
|
||||
server_name = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"get_info\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
arg = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
arg = lua_tostring (lua_current_interpreter, -2);
|
||||
server_name = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"get_info\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
info = lua_plugin->get_info (lua_plugin, (char *) arg, (char *) server_name);
|
||||
@@ -746,6 +896,7 @@ weechat_lua_get_dcc_info (lua_State *L)
|
||||
char timebuffer2[64];
|
||||
struct in_addr in;
|
||||
int i;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -767,7 +918,7 @@ weechat_lua_get_dcc_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(i=0, ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc, i++)
|
||||
for (i = 0, ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc, i++)
|
||||
{
|
||||
strftime(timebuffer1, sizeof(timebuffer1), "%F %T",
|
||||
localtime(&ptr_dcc->start_time));
|
||||
@@ -860,6 +1011,7 @@ weechat_lua_get_config (lua_State *L)
|
||||
const char *option;
|
||||
char *return_value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -905,6 +1057,7 @@ weechat_lua_set_config (lua_State *L)
|
||||
{
|
||||
const char *option, *value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -952,6 +1105,7 @@ weechat_lua_get_plugin_config (lua_State *L)
|
||||
const char *option;
|
||||
char *return_value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -999,6 +1153,7 @@ weechat_lua_set_plugin_config (lua_State *L)
|
||||
{
|
||||
const char *option, *value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1047,6 +1202,7 @@ weechat_lua_get_server_info (lua_State *L)
|
||||
{
|
||||
t_plugin_server_info *server_info, *ptr_server;
|
||||
char timebuffer[64];
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1067,7 +1223,7 @@ weechat_lua_get_server_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(ptr_server = server_info; ptr_server; ptr_server = ptr_server->next_server)
|
||||
for (ptr_server = server_info; ptr_server; ptr_server = ptr_server->next_server)
|
||||
{
|
||||
strftime(timebuffer, sizeof(timebuffer), "%F %T",
|
||||
localtime(&ptr_server->away_time));
|
||||
@@ -1201,6 +1357,7 @@ weechat_lua_get_channel_info (lua_State *L)
|
||||
t_plugin_channel_info *channel_info, *ptr_channel;
|
||||
const char *server;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1237,7 +1394,7 @@ weechat_lua_get_channel_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(ptr_channel = channel_info; ptr_channel; ptr_channel = ptr_channel->next_channel)
|
||||
for (ptr_channel = channel_info; ptr_channel; ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, ptr_channel->name);
|
||||
lua_newtable (lua_current_interpreter);
|
||||
@@ -1284,6 +1441,7 @@ weechat_lua_get_nick_info (lua_State *L)
|
||||
t_plugin_nick_info *nick_info, *ptr_nick;
|
||||
const char *server, *channel;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1349,6 +1507,7 @@ weechat_lua_constant_plugin_rc_ok (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK);
|
||||
return 1;
|
||||
}
|
||||
@@ -1358,6 +1517,7 @@ weechat_lua_constant_plugin_rc_ko (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_KO);
|
||||
return 1;
|
||||
}
|
||||
@@ -1367,6 +1527,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_weechat (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_WEECHAT);
|
||||
return 1;
|
||||
}
|
||||
@@ -1376,6 +1537,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_plugins (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_PLUGINS);
|
||||
return 1;
|
||||
}
|
||||
@@ -1385,6 +1547,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_all (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_ALL);
|
||||
return 1;
|
||||
}
|
||||
@@ -1404,8 +1567,10 @@ const struct luaL_reg weechat_lua_funcs[] = {
|
||||
{ "add_message_handler", weechat_lua_add_message_handler},
|
||||
{ "add_command_handler", weechat_lua_add_command_handler},
|
||||
{ "add_timer_handler", weechat_lua_add_timer_handler},
|
||||
{ "add_keyboard_handler", weechat_lua_add_keyboard_handler},
|
||||
{ "remove_handler", weechat_lua_remove_handler},
|
||||
{ "remove_timer_handler", weechat_lua_remove_timer_handler},
|
||||
{ "remove_keyboard_handler", weechat_lua_remove_keyboard_handler},
|
||||
{ "get_info", weechat_lua_get_info},
|
||||
{ "get_dcc_info", weechat_lua_get_dcc_info},
|
||||
{ "get_config", weechat_lua_get_config},
|
||||
@@ -1536,7 +1701,7 @@ weechat_lua_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_lua_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_lua_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
lua_close (script->interpreter);
|
||||
|
||||
@@ -1590,8 +1755,8 @@ weechat_lua_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
char **argv, *path_script;
|
||||
@@ -1599,13 +1764,14 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1687,6 +1853,24 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Lua keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Lua keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Lua(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1730,7 +1914,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -103,11 +103,11 @@ char *weechat_perl_code =
|
||||
int
|
||||
weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
char empty_server[1] = { '\0' };
|
||||
char empty_arg[1] = { '\0' };
|
||||
char *func;
|
||||
char *argv[3];
|
||||
char *argv[4];
|
||||
unsigned int count;
|
||||
int return_code;
|
||||
SV *sv;
|
||||
@@ -116,11 +116,11 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
dSP;
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
int size = strlen(script->interpreter) + strlen(function) + 3;
|
||||
int size = strlen (script->interpreter) + strlen(function) + 3;
|
||||
func = (char *) malloc ( size * sizeof(char));
|
||||
if (func == NULL)
|
||||
if (!func)
|
||||
return PLUGIN_RC_KO;
|
||||
snprintf(func, size, "%s::%s", (char *) script->interpreter, function);
|
||||
snprintf (func, size, "%s::%s", (char *) script->interpreter, function);
|
||||
#else
|
||||
func = function;
|
||||
PERL_SET_CONTEXT (script->interpreter);
|
||||
@@ -129,12 +129,25 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(sp);
|
||||
if (!server)
|
||||
argv[0] = empty_server;
|
||||
if (arg1)
|
||||
{
|
||||
argv[0] = (arg1) ? arg1 : empty_arg;
|
||||
if (arg2)
|
||||
{
|
||||
argv[1] = (arg2) ? arg2 : empty_arg;
|
||||
if (arg3)
|
||||
{
|
||||
argv[2] = (arg3) ? arg3 : empty_arg;
|
||||
argv[3] = NULL;
|
||||
}
|
||||
else
|
||||
argv[2] = NULL;
|
||||
}
|
||||
else
|
||||
argv[1] = NULL;
|
||||
}
|
||||
else
|
||||
argv[0] = server;
|
||||
argv[1] = arguments;
|
||||
argv[2] = NULL;
|
||||
argv[0] = NULL;
|
||||
|
||||
perl_current_script = script;
|
||||
|
||||
@@ -166,26 +179,59 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
LEAVE;
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
free(func);
|
||||
free (func);
|
||||
#endif
|
||||
|
||||
return return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_handler: general message and command handler for Perl
|
||||
* weechat_perl_cmd_msg_handler: general command/message handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_perl_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_timer_handler: general timer handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_keyboard_handler: general keyboard handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -456,7 +502,7 @@ static XS (XS_weechat_command)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_message_handler: add handler for messages (privmsg, ...)
|
||||
* weechat::add_message_handler: add a handler for messages (privmsg, ...)
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_message_handler)
|
||||
@@ -488,7 +534,7 @@ static XS (XS_weechat_add_message_handler)
|
||||
function = SvPV (ST (1), integer);
|
||||
|
||||
if (perl_plugin->msg_handler_add (perl_plugin, irc_command,
|
||||
weechat_perl_handler, function,
|
||||
weechat_perl_cmd_msg_handler, function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
@@ -496,7 +542,7 @@ static XS (XS_weechat_add_message_handler)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_command_handler: add command handler (define/redefine commands)
|
||||
* weechat::add_command_handler: add a command handler (define/redefine commands)
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_command_handler)
|
||||
@@ -538,7 +584,7 @@ static XS (XS_weechat_add_command_handler)
|
||||
arguments,
|
||||
arguments_description,
|
||||
completion_template,
|
||||
weechat_perl_handler,
|
||||
weechat_perl_cmd_msg_handler,
|
||||
function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
@@ -547,7 +593,7 @@ static XS (XS_weechat_add_command_handler)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_timer_handler: add timer handler
|
||||
* weechat::add_timer_handler: add a timer handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_timer_handler)
|
||||
@@ -579,16 +625,54 @@ static XS (XS_weechat_add_timer_handler)
|
||||
interval = SvIV (ST (0));
|
||||
function = SvPV (ST (1), integer);
|
||||
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl add timer: interval = %d", interval);
|
||||
if (perl_plugin->timer_handler_add (perl_plugin, interval,
|
||||
weechat_perl_handler, function,
|
||||
weechat_perl_timer_handler, function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_keyboard_handler)
|
||||
{
|
||||
char *function;
|
||||
unsigned int integer;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
function = SvPV (ST (0), integer);
|
||||
|
||||
if (perl_plugin->keyboard_handler_add (perl_plugin,
|
||||
weechat_perl_keyboard_handler,
|
||||
function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::remove_handler: remove a message/command handler
|
||||
*/
|
||||
@@ -664,6 +748,43 @@ static XS (XS_weechat_remove_timer_handler)
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_remove_keyboard_handler)
|
||||
{
|
||||
char *function;
|
||||
unsigned int integer;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
function = SvPV (ST (0), integer);
|
||||
|
||||
weechat_script_remove_keyboard_handler (perl_plugin, perl_current_script,
|
||||
function);
|
||||
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::get_info: get various infos
|
||||
*/
|
||||
@@ -1170,6 +1291,43 @@ static XS (XS_weechat_get_nick_info)
|
||||
XSRETURN (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::color_input: add color in input buffer
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_input_color)
|
||||
{
|
||||
int color, start, length;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to colorize input, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"color_input\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
color = SvIV (ST (0));
|
||||
start = SvIV (ST (1));
|
||||
length = SvIV (ST (2));
|
||||
|
||||
perl_plugin->input_color (perl_plugin, color, start, length);
|
||||
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_xs_init: initialize subroutines
|
||||
*/
|
||||
@@ -1191,8 +1349,10 @@ weechat_perl_xs_init (pTHX)
|
||||
newXS ("weechat::add_message_handler", XS_weechat_add_message_handler, "weechat");
|
||||
newXS ("weechat::add_command_handler", XS_weechat_add_command_handler, "weechat");
|
||||
newXS ("weechat::add_timer_handler", XS_weechat_add_timer_handler, "weechat");
|
||||
newXS ("weechat::add_keyboard_handler", XS_weechat_add_keyboard_handler, "weechat");
|
||||
newXS ("weechat::remove_handler", XS_weechat_remove_handler, "weechat");
|
||||
newXS ("weechat::remove_timer_handler", XS_weechat_remove_timer_handler, "weechat");
|
||||
newXS ("weechat::remove_keyboard_handler", XS_weechat_remove_keyboard_handler, "weechat");
|
||||
newXS ("weechat::get_info", XS_weechat_get_info, "weechat");
|
||||
newXS ("weechat::get_dcc_info", XS_weechat_get_dcc_info, "weechat");
|
||||
newXS ("weechat::get_config", XS_weechat_get_config, "weechat");
|
||||
@@ -1202,6 +1362,7 @@ weechat_perl_xs_init (pTHX)
|
||||
newXS ("weechat::get_server_info", XS_weechat_get_server_info, "weechat");
|
||||
newXS ("weechat::get_channel_info", XS_weechat_get_channel_info, "weechat");
|
||||
newXS ("weechat::get_nick_info", XS_weechat_get_nick_info, "weechat");
|
||||
newXS ("weechat::input_color", XS_weechat_input_color, "weechat");
|
||||
|
||||
/* interface constants */
|
||||
stash = gv_stashpv ("weechat", TRUE);
|
||||
@@ -1237,7 +1398,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
|
||||
snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, packnum);
|
||||
packnum++;
|
||||
tempscript.interpreter = "WeechatPerlScriptLoader";
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, pkgname);
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, pkgname, "");
|
||||
#else
|
||||
perl_current_interpreter = perl_alloc();
|
||||
|
||||
@@ -1256,7 +1417,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
|
||||
perl_parse (perl_current_interpreter, weechat_perl_xs_init, 3, perl_args, NULL);
|
||||
|
||||
eval_pv (weechat_perl_code, TRUE);
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, "");
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, "", "");
|
||||
|
||||
free (perl_current_script_filename);
|
||||
|
||||
@@ -1338,7 +1499,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
#endif
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_perl_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_perl_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
if (script->interpreter)
|
||||
@@ -1398,7 +1559,7 @@ weechat_perl_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1406,14 +1567,15 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_script *ptr_script;
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1497,6 +1659,22 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Perl keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Perl keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Perl(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (plugin->ascii_strcasecmp (plugin, argv[0], "autoload") == 0)
|
||||
@@ -1538,7 +1716,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -50,7 +50,7 @@ PyThreadState *python_mainThreadState = NULL;
|
||||
int
|
||||
weechat_python_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
PyObject *evMain;
|
||||
PyObject *evDict;
|
||||
@@ -75,8 +75,21 @@ weechat_python_exec (t_weechat_plugin *plugin,
|
||||
ret = -1;
|
||||
|
||||
python_current_script = script;
|
||||
|
||||
rc = PyObject_CallFunction(evFunc, "ss", server == NULL ? "" : server, arguments == NULL ? "" : arguments);
|
||||
|
||||
if (arg1)
|
||||
{
|
||||
if (arg2)
|
||||
{
|
||||
if (arg3)
|
||||
rc = PyObject_CallFunction (evFunc, "sss", arg1, arg2, arg3);
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "ss", arg1, arg2);
|
||||
}
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "s", arg1);
|
||||
}
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "");
|
||||
|
||||
if (rc)
|
||||
{
|
||||
@@ -94,19 +107,52 @@ weechat_python_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_handler: general message and command handler for Python
|
||||
* weechat_python_cmd_msg_handler: general command/message handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_python_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_timer_handler: general timer handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_keyboard_handler: general keyboard handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -392,7 +438,8 @@ weechat_python_add_message_handler (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (python_plugin->msg_handler_add (python_plugin, irc_command,
|
||||
weechat_python_handler, function,
|
||||
weechat_python_cmd_msg_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
@@ -443,7 +490,7 @@ weechat_python_add_command_handler (PyObject *self, PyObject *args)
|
||||
arguments,
|
||||
arguments_description,
|
||||
completion_template,
|
||||
weechat_python_handler,
|
||||
weechat_python_cmd_msg_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
@@ -484,13 +531,53 @@ weechat_python_add_timer_handler (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (python_plugin->timer_handler_add (python_plugin, interval,
|
||||
weechat_python_handler, function,
|
||||
weechat_python_timer_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_add_keyboard_handler (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &function))
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
if (python_plugin->keyboard_handler_add (python_plugin,
|
||||
weechat_python_keyboard_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_remove_handler: remove a handler
|
||||
*/
|
||||
@@ -564,6 +651,42 @@ weechat_python_remove_timer_handler (PyObject *self, PyObject *args)
|
||||
return Py_BuildValue ("i", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_remove_keyboard_handler (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &function))
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
weechat_script_remove_keyboard_handler (python_plugin, python_current_script,
|
||||
function);
|
||||
|
||||
return Py_BuildValue ("i", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_get_info: get various infos
|
||||
*/
|
||||
@@ -1132,8 +1255,10 @@ PyMethodDef weechat_python_funcs[] = {
|
||||
{ "add_message_handler", weechat_python_add_message_handler, METH_VARARGS, "" },
|
||||
{ "add_command_handler", weechat_python_add_command_handler, METH_VARARGS, "" },
|
||||
{ "add_timer_handler", weechat_python_add_timer_handler, METH_VARARGS, "" },
|
||||
{ "add_keyboard_handler", weechat_python_add_keyboard_handler, METH_VARARGS, "" },
|
||||
{ "remove_handler", weechat_python_remove_handler, METH_VARARGS, "" },
|
||||
{ "remove_timer_handler", weechat_python_remove_timer_handler, METH_VARARGS, "" },
|
||||
{ "remove_keyboard_handler", weechat_python_remove_keyboard_handler, METH_VARARGS, "" },
|
||||
{ "get_info", weechat_python_get_info, METH_VARARGS, "" },
|
||||
{ "get_dcc_info", weechat_python_get_dcc_info, METH_VARARGS, "" },
|
||||
{ "get_config", weechat_python_get_config, METH_VARARGS, "" },
|
||||
@@ -1307,7 +1432,7 @@ weechat_python_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_python_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_python_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
PyThreadState_Swap (script->interpreter);
|
||||
Py_EndInterpreter (script->interpreter);
|
||||
@@ -1362,7 +1487,7 @@ weechat_python_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1371,13 +1496,14 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1459,6 +1585,24 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Python keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Python(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1502,7 +1646,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -104,7 +104,7 @@ rb_protect_funcall(VALUE recv, ID mid, int *state, int argc, ...)
|
||||
int
|
||||
weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
VALUE ruby_retcode, err;
|
||||
int ruby_error;
|
||||
@@ -112,11 +112,32 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
(void) plugin;
|
||||
|
||||
ruby_current_script = script;
|
||||
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 2,
|
||||
rb_str_new2((server == NULL) ? "" : server),
|
||||
rb_str_new2((arguments == NULL) ? "" : arguments));
|
||||
|
||||
if (arg1)
|
||||
{
|
||||
if (arg2)
|
||||
{
|
||||
if (arg3)
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 3,
|
||||
rb_str_new2(arg1),
|
||||
rb_str_new2(arg2),
|
||||
rb_str_new2(arg3));
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 2,
|
||||
rb_str_new2(arg1),
|
||||
rb_str_new2(arg2));
|
||||
}
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 1,
|
||||
rb_str_new2(arg1));
|
||||
}
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 0);
|
||||
|
||||
if (ruby_error)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
@@ -137,19 +158,52 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_handler: general message and command handler for Ruby
|
||||
* weechat_ruby_cmd_msg_handler: general command/message handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_ruby_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_timer_handler: general timer handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_keyboard_handler: general keyboard handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 2)
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -482,7 +536,7 @@ weechat_ruby_command (int argc, VALUE *argv, VALUE class)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_message_handler: add handler for messages
|
||||
* weechat_ruby_add_message_handler: add a handler for messages (privmsg, ...)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
@@ -519,7 +573,8 @@ weechat_ruby_add_message_handler (VALUE class, VALUE message, VALUE function)
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->msg_handler_add (ruby_plugin, c_message,
|
||||
weechat_ruby_handler, c_function,
|
||||
weechat_ruby_cmd_msg_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
@@ -527,7 +582,7 @@ weechat_ruby_add_message_handler (VALUE class, VALUE message, VALUE function)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_command_handler: define/redefines commands
|
||||
* weechat_ruby_add_command_handler: add a command handler (define/redefine commands)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
@@ -608,7 +663,7 @@ weechat_ruby_add_command_handler (int argc, VALUE *argv, VALUE class)
|
||||
c_arguments,
|
||||
c_arguments_description,
|
||||
c_completion_template,
|
||||
weechat_ruby_handler,
|
||||
weechat_ruby_cmd_msg_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
@@ -655,13 +710,57 @@ weechat_ruby_add_timer_handler (VALUE class, VALUE interval, VALUE function)
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->timer_handler_add (ruby_plugin, c_interval,
|
||||
weechat_ruby_handler, c_function,
|
||||
weechat_ruby_timer_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_add_keyboard_handler (VALUE class, VALUE function)
|
||||
{
|
||||
char *c_function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (function))
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->keyboard_handler_add (ruby_plugin,
|
||||
weechat_ruby_keyboard_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_remove_handler: remove a handler
|
||||
*/
|
||||
@@ -745,6 +844,46 @@ weechat_ruby_remove_timer_handler (VALUE class, VALUE function)
|
||||
return INT2FIX (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_remove_keyboard_handler (VALUE class, VALUE function)
|
||||
{
|
||||
char *c_function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (function))
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
weechat_script_remove_keyboard_handler (ruby_plugin, ruby_current_script,
|
||||
c_function);
|
||||
|
||||
return INT2FIX (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_get_info: get various infos
|
||||
*/
|
||||
@@ -1485,7 +1624,7 @@ weechat_ruby_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_ruby_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_ruby_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
if (script->interpreter)
|
||||
rb_gc_unregister_address (script->interpreter);
|
||||
@@ -1541,7 +1680,7 @@ weechat_ruby_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1550,13 +1689,14 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1638,6 +1778,24 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Ruby keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Ruby keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Ruby(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1681,7 +1839,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1758,8 +1916,10 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
rb_define_module_function (mWeechat, "add_message_handler", weechat_ruby_add_message_handler, 2);
|
||||
rb_define_module_function (mWeechat, "add_command_handler", weechat_ruby_add_command_handler, -1);
|
||||
rb_define_module_function (mWeechat, "add_timer_handler", weechat_ruby_add_timer_handler, 2);
|
||||
rb_define_module_function (mWeechat, "add_keyboard_handler", weechat_ruby_add_keyboard_handler, 1);
|
||||
rb_define_module_function (mWeechat, "remove_handler", weechat_ruby_remove_handler, 2);
|
||||
rb_define_module_function (mWeechat, "remove_timer_handler", weechat_ruby_remove_timer_handler, 1);
|
||||
rb_define_module_function (mWeechat, "remove_keyboard_handler", weechat_ruby_remove_keyboard_handler, 1);
|
||||
rb_define_module_function (mWeechat, "get_info", weechat_ruby_get_info, -1);
|
||||
rb_define_module_function (mWeechat, "get_dcc_info", weechat_ruby_get_dcc_info, 0);
|
||||
rb_define_module_function (mWeechat, "get_config", weechat_ruby_get_config, 1);
|
||||
|
||||
@@ -317,7 +317,36 @@ weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
|
||||
ptr_handler = plugin->handlers;
|
||||
while (ptr_handler)
|
||||
{
|
||||
if (((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
if ((ptr_handler->type == HANDLER_TIMER)
|
||||
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
|
||||
{
|
||||
next_handler = ptr_handler->next_handler;
|
||||
plugin->handler_remove (plugin, ptr_handler);
|
||||
ptr_handler = next_handler;
|
||||
}
|
||||
else
|
||||
ptr_handler = ptr_handler->next_handler;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_remove_keyboard_handler: remove a keyboard handler for a script
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function)
|
||||
{
|
||||
t_plugin_handler *ptr_handler, *next_handler;
|
||||
|
||||
/* search and remove keyboard handlers */
|
||||
ptr_handler = plugin->handlers;
|
||||
while (ptr_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
|
||||
{
|
||||
next_handler = ptr_handler->next_handler;
|
||||
|
||||
@@ -56,6 +56,9 @@ extern void weechat_script_remove_handler (t_weechat_plugin *,
|
||||
extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
extern char *weechat_script_get_plugin_config (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
|
||||
@@ -125,7 +125,7 @@ struct t_plugin_nick_info
|
||||
|
||||
typedef struct t_weechat_plugin t_weechat_plugin;
|
||||
|
||||
typedef int (t_plugin_handler_func) (t_weechat_plugin *, char *, char *, char *, char *, void *);
|
||||
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
|
||||
|
||||
/* handlers */
|
||||
|
||||
@@ -135,7 +135,8 @@ enum t_handler_type
|
||||
{
|
||||
HANDLER_MESSAGE = 0, /* IRC message handler */
|
||||
HANDLER_COMMAND, /* command handler */
|
||||
HANDLER_TIMER /* timer handler */
|
||||
HANDLER_TIMER, /* timer handler */
|
||||
HANDLER_KEYBOARD /* keyboard handler */
|
||||
};
|
||||
|
||||
typedef struct t_plugin_handler t_plugin_handler;
|
||||
@@ -219,6 +220,9 @@ struct t_weechat_plugin
|
||||
t_plugin_handler *(*timer_handler_add) (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
t_plugin_handler *(*keyboard_handler_add) (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
void (*handler_remove) (t_weechat_plugin *, t_plugin_handler *);
|
||||
void (*handler_remove_all) (t_weechat_plugin *);
|
||||
|
||||
@@ -239,6 +243,8 @@ struct t_weechat_plugin
|
||||
|
||||
void (*log) (t_weechat_plugin *, char *, char *, char *, ...);
|
||||
|
||||
void (*input_color) (t_weechat_plugin *, int, int, int);
|
||||
|
||||
/* WeeChat developers: ALWAYS add new functions at the end */
|
||||
};
|
||||
|
||||
@@ -272,6 +278,9 @@ extern t_plugin_handler *weechat_plugin_cmd_handler_add (t_weechat_plugin *, cha
|
||||
extern t_plugin_handler *weechat_plugin_timer_handler_add (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern t_plugin_handler *weechat_plugin_keyboard_handler_add (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern void weechat_plugin_handler_remove (t_weechat_plugin *, t_plugin_handler *);
|
||||
extern void weechat_plugin_handler_remove_all (t_weechat_plugin *);
|
||||
|
||||
@@ -290,5 +299,6 @@ extern t_plugin_channel_info *weechat_plugin_get_channel_info (t_weechat_plugin
|
||||
extern void weechat_plugin_free_channel_info (t_weechat_plugin *, t_plugin_channel_info *);
|
||||
extern t_plugin_nick_info *weechat_plugin_get_nick_info (t_weechat_plugin *, char *, char *);
|
||||
extern void weechat_plugin_free_nick_info (t_weechat_plugin *, t_plugin_nick_info *);
|
||||
extern void weechat_plugin_input_color (t_weechat_plugin *, int, int, int);
|
||||
|
||||
#endif /* weechat-plugin.h */
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-03-26
|
||||
ChangeLog - 2006-03-30
|
||||
|
||||
|
||||
Version 0.1.9 (under dev!):
|
||||
* added keyboard handler to plugin API
|
||||
* improved script plugin loader
|
||||
* added hostname/IP option for connection to server
|
||||
* fixed --disable-plugins option in configure script
|
||||
|
||||
+364
-12
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
<bookinfo>
|
||||
|
||||
<title>WeeChat 0.1.8 - User guide</title>
|
||||
<title>WeeChat 0.1.9-cvs - User guide</title>
|
||||
<subtitle>Fast, light and extensible IRC client</subtitle>
|
||||
|
||||
<author>
|
||||
@@ -1801,6 +1801,29 @@ plugin->log (plugin, "freenode", "#weechat", "test");
|
||||
<option>function</option>: function called when message
|
||||
is received
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 3, following values are set in
|
||||
argv array:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = server name</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = IRC message</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = command arguments</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2036,6 +2059,29 @@ plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
|
||||
<option>function</option>: function called when command
|
||||
is executed
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 3, following values are set in
|
||||
argc array:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = server name</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = command</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = command arguments</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2123,6 +2169,119 @@ plugin->cmd_handler_add (plugin, "test", "Test command",
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Argument argc is set to 0, and argv is set to NULL.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_args</option>: arguments given to function
|
||||
when called
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_pointer</option>: pointer given to function
|
||||
when called
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: pointer to new timer handler.
|
||||
</para>
|
||||
<para>
|
||||
Note: function called has to return one of following values:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal>: function failed
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal>: function successfully
|
||||
completed
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Example:
|
||||
<screen>
|
||||
int my_timer (t_weechat_plugin *plugin, char *server, char *command,
|
||||
char *arguments, char *handler_args, void *handler_pointer)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "my timer");
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_keyboard_handler_add">
|
||||
<title>keyboard_handler_add</title>
|
||||
|
||||
<para>
|
||||
Prototype:
|
||||
<command>
|
||||
t_plugin_handler *keyboard_handler_add (t_weechat_plugin
|
||||
*plugin, t_plugin_handler_func *function,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Add a keyboard handler, called for any key pressed.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>plugin</option>: pointer to plugin structure
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
<para>
|
||||
It uses following prototype:
|
||||
<command>
|
||||
int my_function (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 2 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[0] = touche appuyée (nom d'une fonction interne
|
||||
ou bien '*' suivi du code d'une touche si la touche
|
||||
n'est pas associée à une fonction)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[1] = "1" si la ligne de commande a changé suite
|
||||
à l'action de cette touche, "0" sinon
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2160,14 +2319,21 @@ plugin->cmd_handler_add (plugin, "test", "Test command",
|
||||
<para>
|
||||
Example:
|
||||
<screen>
|
||||
int my_timer (t_weechat_plugin *plugin, char *server, char *command,
|
||||
char *arguments, char *handler_args, void *handler_pointer)
|
||||
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "my timer");
|
||||
if (argc == 2)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "key pressed: %s", argv[0]);
|
||||
if (argv[1] && (argv[1][0] == '1'))
|
||||
plugin->print (plugin, NULL, NULL, "input text changed");
|
||||
else
|
||||
plugin->print (plugin, NULL, NULL, "input text not changed");
|
||||
}
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
plugin->keyboard_handler_add (plugin, &keyb_handler);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -2183,7 +2349,7 @@ plugin->timer_handler_add (plugin, 60, &my_timer);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Remove a handler.
|
||||
Remove a command or message handler.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
@@ -2353,6 +2519,24 @@ plugin->exec_command (plugin, "freenode", "#weechat", "hello");
|
||||
number of seconds since last key was pressed
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input</literal></entry>
|
||||
<entry>
|
||||
content of command line for current window
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_mask</literal></entry>
|
||||
<entry>
|
||||
content of color mask for command line
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_pos</literal></entry>
|
||||
<entry>
|
||||
cursor position in command line
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>weechat_dir</literal></entry>
|
||||
<entry>
|
||||
@@ -2400,9 +2584,12 @@ plugin->print (plugin, NULL, NULL,
|
||||
"(inactive for %s seconds)",
|
||||
version, nick, inactivity);
|
||||
|
||||
free (version);
|
||||
free (nick);
|
||||
free (inactivity);
|
||||
if (version)
|
||||
free (version);
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (inactivity)
|
||||
free (inactivity);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -4288,20 +4475,20 @@ sub my_timer
|
||||
|
||||
# python
|
||||
weechat.add_timer_handler(60, "my_timer")
|
||||
def my_timer(server, args):
|
||||
def my_timer():
|
||||
weechat.prnt("this is timer handler")
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_timer_handler(60, "my_timer")
|
||||
def my_timer(server, args)
|
||||
def my_timer()
|
||||
Weechat.print("this is timer handler")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_timer_handler(60, "my_timer")
|
||||
function my_timer(server, args)
|
||||
function my_timer()
|
||||
weechat.print("this is timer handler)
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
@@ -4325,6 +4512,110 @@ end
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>add_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Perl prototype:
|
||||
<command>
|
||||
weechat::add_keyboard_handler(message, function);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Python prototype:
|
||||
<command>
|
||||
weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ruby prototype:
|
||||
<command>
|
||||
Weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Lua prototype:
|
||||
<command>
|
||||
weechat.add_keyboard_handler(message, function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Add a keyboard handler, called for any key pressed.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function called
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: 1 if success, 0 if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
Examples:
|
||||
<screen>
|
||||
# perl
|
||||
weechat::add_keyboard_handler("my_keyboard");
|
||||
sub my_keyboard
|
||||
{
|
||||
my $key = shift;
|
||||
my $input_before = shift;
|
||||
my $input_after = shift;
|
||||
weechat::print("keyboard handler: key = '$key', "
|
||||
."input before = '$input_before' "
|
||||
."after = '$input_after'");
|
||||
return weechat::PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
# python
|
||||
weechat.add_keyboard_handler("my_keyboard")
|
||||
def my_keyboard(key, input_before, input_after):
|
||||
weechat.prnt("keyboard handler: key = '%s', " \
|
||||
"input before = '%s' after = '%s'"
|
||||
%(key, input_before, input_after))
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_keyboard_handler("my_keyboard")
|
||||
def my_keyboard(server, input_before, input_after)
|
||||
Weechat.print("keyboard handler: key = '#{key}', " \
|
||||
"input before = '#{input_before}' " \
|
||||
"after = '#{input_after}'")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_keyboard_handler("my_keyboard")
|
||||
function my_keyboard(server, input_before, input_after)
|
||||
weechat.print("keyboard handler: key = '"..key..
|
||||
"', input before = '"..input_before..
|
||||
"' after = '"..input_after.."'")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Note: function called has to return one of following values:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal>: function failed
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal>: function successfully
|
||||
completed
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_handler</title>
|
||||
|
||||
@@ -4452,6 +4743,67 @@ weechat.remove_timer_handler("my_timer")
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Perl prototype:
|
||||
<command>
|
||||
weechat::remove_keyboard_handler(function);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Python prototype:
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ruby prototype:
|
||||
<command>
|
||||
Weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Lua prototype:
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(function)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Remove a keyboard handler.
|
||||
</para>
|
||||
<para>
|
||||
Arguments:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>function</option>: function
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Return value: 1 if success, 0 if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
Examples:
|
||||
<screen>
|
||||
# perl
|
||||
weechat::remove_keyboard_handler("my_keyboard");
|
||||
|
||||
# python
|
||||
weechat.remove_keyboard_handler("my_keyboard")
|
||||
|
||||
# ruby
|
||||
Weechat.remove_keyboard_handler("my_keyboard")
|
||||
|
||||
-- lua
|
||||
weechat.remove_keyboard_handler("my_keyboard")
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>command</title>
|
||||
|
||||
|
||||
+368
-10
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
<bookinfo>
|
||||
|
||||
<title>WeeChat 0.1.8 - Guide utilisateur</title>
|
||||
<title>WeeChat 0.1.9-cvs - Guide utilisateur</title>
|
||||
<subtitle>Client IRC rapide, léger et extensible</subtitle>
|
||||
|
||||
<author>
|
||||
@@ -1839,6 +1839,29 @@ plugin->log (plugin, "freenode", "#weechat", "test");
|
||||
<option>fonction</option> : fonction appelée lorsque le
|
||||
message est reçu
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 3 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = nom du serveur</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = message IRC</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = arguments de la commande</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2075,7 +2098,30 @@ plugin->msg_handler_add (plugin, "KICK", &msg_kick, NULL, NULL);
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée lorsque la
|
||||
commande est exécutée
|
||||
commande est exécutée.
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 3 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>argv[0] = nom du serveur</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[1] = commande</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>argv[2] = arguments de la commande</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
@@ -2166,6 +2212,17 @@ plugin->cmd_handler_add (plugin, "test", "Commande test",
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 0 et argv vaut NULL.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -2183,7 +2240,7 @@ plugin->cmd_handler_add (plugin, "test", "Commande test",
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : le pointeur vers le nouveau gestionnaire de
|
||||
messages.
|
||||
temps.
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
@@ -2216,6 +2273,118 @@ plugin->timer_handler_add (plugin, 60, &mon_timer);
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_keyboard_handler_add">
|
||||
<title>keyboard_handler_add</title>
|
||||
|
||||
<para>
|
||||
Prototype :
|
||||
<command>
|
||||
t_plugin_handler *keyboard_handler_add (t_weechat_plugin
|
||||
*plugin, t_plugin_handler_func *fonction,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ajoute un gestionnaire de clavier, appelé dès qu'une touche est
|
||||
pressée.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>plugin</option> : pointeur vers la structure
|
||||
de l'extension
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
<para>
|
||||
Elle a le prototype suivant :
|
||||
<command>
|
||||
int ma_fonction (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Le paramètre argc vaut 2 et les arguments suivants sont
|
||||
passés dans le tableau argv :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[0] = touche appuyée (nom d'une fonction interne
|
||||
ou bien '*' suivi du code d'une touche si la touche
|
||||
n'est pas associée à une fonction)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
argv[1] = "1" si la ligne de commande a changé suite
|
||||
à l'action de cette touche, "0" sinon
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_args</option> : paramètres passés à la
|
||||
fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>handler_pointer</option> : pointeur passé à la
|
||||
fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : le pointeur vers le nouveau gestionnaire de
|
||||
clavier.
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
suivantes :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal> : la fonction a échoué
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal> : la fonction a réussi
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Exemple :
|
||||
<screen>
|
||||
int keyb_handler (t_weechat_plugin *plugin, int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "touche appuyée: %s", argv[0]);
|
||||
if (argv[1] && (argv[1][0] == '1'))
|
||||
plugin->print (plugin, NULL, NULL, "le texte d'entrée a changé");
|
||||
else
|
||||
plugin->print (plugin, NULL, NULL, "le texte d'entrée n'a pas changé");
|
||||
}
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
...
|
||||
plugin->keyboard_handler_add (plugin, &keyb_handler);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="secAPI_handler_remove">
|
||||
<title>handler_remove</title>
|
||||
|
||||
@@ -2227,7 +2396,7 @@ plugin->timer_handler_add (plugin, 60, &mon_timer);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Supprime un gestionnaire.
|
||||
Supprime un gestionnaire de commande ou message.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
@@ -2402,6 +2571,26 @@ plugin->exec_command (plugin, "freenode", "#weechat", "bonjour");
|
||||
touche a été appuyée
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input</literal></entry>
|
||||
<entry>
|
||||
contenu de la ligne de commande de la fenêtre
|
||||
courante
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_mask</literal></entry>
|
||||
<entry>
|
||||
contenu du masque de couleur de la ligne de
|
||||
commande
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>input_pos</literal></entry>
|
||||
<entry>
|
||||
position du curseur dans la ligne de commande
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>weechat_dir</literal></entry>
|
||||
<entry>
|
||||
@@ -2449,9 +2638,12 @@ plugin->print (plugin, NULL, NULL,
|
||||
"(inactif depuis %s secondes)",
|
||||
version, nick, inactivity);
|
||||
|
||||
free (version);
|
||||
free (nick);
|
||||
free (inactivity);
|
||||
if (version)
|
||||
free (version);
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (inactivity)
|
||||
free (inactivity);
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -4369,20 +4561,20 @@ sub mon_timer
|
||||
|
||||
# python
|
||||
weechat.add_timer_handler(60, "mon_timer")
|
||||
def mon_timer(serveur, args):
|
||||
def mon_timer():
|
||||
weechat.prnt("ceci est le timer handler")
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_timer_handler(60, "mon_timer")
|
||||
def mon_timer(server, args)
|
||||
def mon_timer()
|
||||
Weechat.print("ceci est le timer handler")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_timer_handler(60, "mon_timer")
|
||||
function mon_timer(server, args)
|
||||
function mon_timer()
|
||||
weechat.print("ceci est le timer handler")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
@@ -4406,6 +4598,111 @@ end
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>add_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Prototype Perl :
|
||||
<command>
|
||||
weechat::add_keyboard_handler(fonction);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Python :
|
||||
<command>
|
||||
weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Ruby :
|
||||
<command>
|
||||
Weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Lua :
|
||||
<command>
|
||||
weechat.add_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Ajoute un gestionnaire de clavier, appelé dès qu'une touche est
|
||||
pressée.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction appelée
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
|
||||
</para>
|
||||
<para>
|
||||
Exemples :
|
||||
<screen>
|
||||
# perl
|
||||
weechat::add_keyboard_handler("mon_clavier");
|
||||
sub mon_clavier
|
||||
{
|
||||
my $key = shift;
|
||||
my $input_before = shift;
|
||||
my $input_after = shift;
|
||||
weechat::print("gestionnaire clavier: key = '$key', "
|
||||
."entrée avant = '$input_before' "
|
||||
."après = '$input_after'");
|
||||
return weechat::PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
# python
|
||||
weechat.add_keyboard_handler("mon_clavier")
|
||||
def mon_clavier(key, input_before, input_after):
|
||||
weechat.prnt("gestionnaire clavier: touche = '%s', " \
|
||||
"entrée avant = '%s' après = '%s'"
|
||||
%(key, input_before, input_after))
|
||||
return weechat.PLUGIN_RC_OK
|
||||
|
||||
# ruby
|
||||
Weechat.add_clavier_handler("mon_clavier")
|
||||
def mon_clavier(server, input_before, input_after)
|
||||
Weechat.print("gestionnaire clavier: touche = '#{key}', " \
|
||||
"entrée avant = '#{input_before}' " \
|
||||
"après = '#{input_after}'")
|
||||
return Weechat::PLUGIN_RC_OK
|
||||
end
|
||||
|
||||
-- lua
|
||||
weechat.add_clavier_handler("mon_clavier")
|
||||
function mon_clavier(server, input_before, input_after)
|
||||
weechat.print("gestionnaire clavier: touche = '"..key..
|
||||
"', entrée avant = '"..input_before..
|
||||
"' après = '"..input_after.."'")
|
||||
return weechat.PLUGIN_RC_OK()
|
||||
end
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
Note : la fonction appelée doit renvoyer une des valeurs
|
||||
suivantes :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_KO</literal> : la fonction a échoué
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>PLUGIN_RC_OK</literal> : la fonction a réussi
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_handler</title>
|
||||
|
||||
@@ -4533,6 +4830,67 @@ weechat.remove_timer_handler("mon_timer")
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>remove_keyboard_handler</title>
|
||||
|
||||
<para>
|
||||
Prototype Perl :
|
||||
<command>
|
||||
weechat::remove_keyboard_handler(fonction);
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Python :
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Ruby :
|
||||
<command>
|
||||
Weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Prototype Lua :
|
||||
<command>
|
||||
weechat.remove_keyboard_handler(fonction)
|
||||
</command>
|
||||
</para>
|
||||
<para>
|
||||
Supprime un gestionnaire de clavier.
|
||||
</para>
|
||||
<para>
|
||||
Paramètres :
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<option>fonction</option> : fonction
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
Valeur renvoyée : 1 si succès, 0 si une erreur s'est produite.
|
||||
</para>
|
||||
<para>
|
||||
Exemples :
|
||||
<screen>
|
||||
# perl
|
||||
weechat::remove_keyboard_handler("mon_clavier");
|
||||
|
||||
# python
|
||||
weechat.remove_keyboard_handler("mon_clavier")
|
||||
|
||||
# ruby
|
||||
Weechat.remove_keyboard_handler("mon_clavier")
|
||||
|
||||
-- lua
|
||||
weechat.remove_keyboard_handler("mon_clavier")
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>command</title>
|
||||
|
||||
|
||||
+439
-402
File diff suppressed because it is too large
Load Diff
+446
-409
File diff suppressed because it is too large
Load Diff
+435
-400
File diff suppressed because it is too large
Load Diff
+435
-404
File diff suppressed because it is too large
Load Diff
+433
-402
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,10 @@
|
||||
#include "fifo.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* WeeChat internal commands */
|
||||
@@ -2539,6 +2542,44 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" (no command handler)\n"));
|
||||
}
|
||||
|
||||
/* timer handlers */
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" timer handlers:\n"));
|
||||
handler_found = 0;
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_TIMER)
|
||||
{
|
||||
handler_found = 1;
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" %d seconds\n"),
|
||||
ptr_handler->interval);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" (no timer handler)\n"));
|
||||
}
|
||||
|
||||
/* keyboard handlers */
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
gui_printf (NULL, _(" keyboard handlers:\n"));
|
||||
handler_found = 0;
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_KEYBOARD)
|
||||
handler_found++;
|
||||
}
|
||||
irc_display_prefix (NULL, NULL, PREFIX_PLUGIN);
|
||||
if (!handler_found)
|
||||
gui_printf (NULL, _(" (no keyboard handler)\n"));
|
||||
else
|
||||
gui_printf (NULL, _(" %d defined\n"),
|
||||
handler_found);
|
||||
}
|
||||
if (!weechat_plugins)
|
||||
{
|
||||
@@ -2583,6 +2624,8 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel,
|
||||
"without plugins support.\n"),
|
||||
"plugin");
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) channel;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
#endif /* PLUGINS */
|
||||
|
||||
@@ -424,6 +424,9 @@ completion_list_add_plugin_option (t_completion *completion)
|
||||
&completion->last_completion,
|
||||
ptr_option->name);
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -457,6 +460,9 @@ completion_list_add_plugin (t_completion *completion)
|
||||
&completion->last_completion,
|
||||
ptr_plugin->name);
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -634,6 +640,9 @@ completion_list_add_plugin_option_value (t_completion *completion)
|
||||
if (pos)
|
||||
pos[0] = ' ';
|
||||
}
|
||||
#else
|
||||
/* make gcc happy */
|
||||
(void) completion;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,18 @@
|
||||
#include "../../irc/irc.h"
|
||||
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
t_gui_color gui_weechat_colors[] =
|
||||
{ { -1, 0, 0, "default" },
|
||||
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
|
||||
@@ -67,7 +79,7 @@ t_gui_color gui_weechat_colors[] =
|
||||
{ 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
int gui_irc_colors[16][2] =
|
||||
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
|
||||
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
|
||||
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
|
||||
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
|
||||
@@ -86,7 +98,7 @@ int gui_irc_colors[16][2] =
|
||||
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
|
||||
};
|
||||
|
||||
t_gui_color *gui_color[NUM_COLORS];
|
||||
t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
|
||||
/*
|
||||
@@ -205,13 +217,13 @@ gui_color_decode (unsigned char *string, int keep_colors)
|
||||
if (str_fg[0])
|
||||
{
|
||||
sscanf (str_fg, "%d", &fg);
|
||||
fg %= 16;
|
||||
fg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[fg][1];
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
sscanf (str_bg, "%d", &bg);
|
||||
bg %= 16;
|
||||
bg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[bg][1];
|
||||
}
|
||||
if (attr & A_BOLD)
|
||||
@@ -465,7 +477,7 @@ gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > NUM_COLORS - 1))
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
@@ -489,7 +501,7 @@ gui_color_get_pair (int num_color)
|
||||
void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
if ((num_color >= 0) && (num_color <= NUM_COLORS - 1))
|
||||
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
|
||||
{
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
|
||||
@@ -620,6 +632,35 @@ gui_window_chat_set_weechat_color (t_gui_window *window, int weechat_color)
|
||||
gui_color[weechat_color]->background);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_input_set_color: set color for an input window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_input_set_color (t_gui_window *window, int irc_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
fg = gui_irc_colors[irc_color][0];
|
||||
bg = gui_color[COLOR_WIN_INPUT]->background;
|
||||
|
||||
irc_color %= GUI_NUM_IRC_COLORS;
|
||||
if (gui_irc_colors[irc_color][1] & A_BOLD)
|
||||
wattron (window->win_input, A_BOLD);
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window->win_input, COLOR_PAIR(63));
|
||||
else
|
||||
{
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window->win_input, COLOR_PAIR((bg * 8) + fg));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_calculate_pos_size: calculate position and size for a buffer & subwindows
|
||||
*/
|
||||
@@ -2384,6 +2425,50 @@ gui_get_input_width (t_gui_window *window, char *nick)
|
||||
return (window->win_width - strlen (nick) - 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_draw_buffer_input_text: display text in input buffer, according to color mask
|
||||
*/
|
||||
|
||||
void
|
||||
gui_draw_buffer_input_text (t_gui_window *window, int input_width)
|
||||
{
|
||||
char *ptr_start, *ptr_next, saved_char;
|
||||
int pos_mask, size, last_color, color;
|
||||
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_1st_display);
|
||||
pos_mask = ptr_start - window->buffer->input_buffer;
|
||||
last_color = -1;
|
||||
while ((input_width > 0) && ptr_start && ptr_start[0])
|
||||
{
|
||||
ptr_next = utf8_next_char (ptr_start);
|
||||
if (ptr_next)
|
||||
{
|
||||
saved_char = ptr_next[0];
|
||||
ptr_next[0] = '\0';
|
||||
size = ptr_next - ptr_start;
|
||||
if (window->buffer->input_buffer_color_mask[pos_mask] != ' ')
|
||||
color = window->buffer->input_buffer_color_mask[pos_mask] - '0';
|
||||
else
|
||||
color = -1;
|
||||
if (color != last_color)
|
||||
{
|
||||
if (color == -1)
|
||||
gui_window_set_weechat_color (window->win_input, COLOR_WIN_INPUT);
|
||||
else
|
||||
gui_window_input_set_color (window, color);
|
||||
}
|
||||
last_color = color;
|
||||
wprintw (window->win_input, "%s", ptr_start);
|
||||
ptr_next[0] = saved_char;
|
||||
ptr_start = ptr_next;
|
||||
pos_mask += size;
|
||||
}
|
||||
else
|
||||
ptr_start = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_draw_buffer_input: draw input window for a buffer
|
||||
*/
|
||||
@@ -2456,9 +2541,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
|
||||
gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
snprintf (format, 32, "%%-%ds", input_width);
|
||||
if (ptr_win == gui_current_window)
|
||||
wprintw (ptr_win->win_input, format,
|
||||
utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_1st_display));
|
||||
gui_draw_buffer_input_text (ptr_win, input_width);
|
||||
else
|
||||
wprintw (ptr_win->win_input, format, "");
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
@@ -2480,9 +2563,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
|
||||
gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
snprintf (format, 32, "%%-%ds", input_width);
|
||||
if (ptr_win == gui_current_window)
|
||||
wprintw (ptr_win->win_input, format,
|
||||
utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_1st_display));
|
||||
gui_draw_buffer_input_text (ptr_win, input_width);
|
||||
else
|
||||
wprintw (ptr_win->win_input, format, "");
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
@@ -3503,7 +3584,7 @@ gui_rebuild_weechat_colors ()
|
||||
|
||||
if (has_colors ())
|
||||
{
|
||||
for (i = 0; i < NUM_COLORS; i++)
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../irc/irc.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -154,7 +157,9 @@ gui_input_default_key_bindings ()
|
||||
void
|
||||
gui_input_grab_end ()
|
||||
{
|
||||
char *expanded_key;
|
||||
char *expanded_key, *expanded_key2;
|
||||
int length;
|
||||
char *buffer_before_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
@@ -163,9 +168,27 @@ gui_input_grab_end ()
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
length = strlen (expanded_key) + 1 + 1;
|
||||
expanded_key2 = (char *) malloc (length);
|
||||
if (expanded_key2)
|
||||
{
|
||||
snprintf (expanded_key2, length, "*%s", expanded_key);
|
||||
(void) plugin_keyboard_handler_exec (expanded_key2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
free (expanded_key2);
|
||||
}
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
@@ -184,7 +207,8 @@ void
|
||||
gui_input_read ()
|
||||
{
|
||||
int key, i, insert_ok;
|
||||
char key_str[32];
|
||||
char key_str[32], key_str2[33];
|
||||
char *buffer_before_key;
|
||||
|
||||
i = 0;
|
||||
/* do not loop too much here (for example when big paste was made),
|
||||
@@ -283,10 +307,19 @@ gui_input_read ()
|
||||
switch (gui_current_window->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, key_str, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
snprintf (key_str2, sizeof (key_str2), "*%s", key_str);
|
||||
(void) plugin_keyboard_handler_exec (key_str2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
gui_exec_action_dcc (gui_current_window, key_str);
|
||||
|
||||
@@ -57,6 +57,19 @@
|
||||
#define COLOR_YELLOW 6
|
||||
#define COLOR_WHITE 7
|
||||
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
t_gui_color gui_weechat_colors[] =
|
||||
{ { -1, 0, 0, "default" },
|
||||
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
|
||||
@@ -76,7 +89,7 @@ t_gui_color gui_weechat_colors[] =
|
||||
{ 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
int gui_irc_colors[16][2] =
|
||||
int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
|
||||
{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
|
||||
{ /* 1 */ WEECHAT_COLOR_BLACK, 0 },
|
||||
{ /* 2 */ WEECHAT_COLOR_BLUE, 0 },
|
||||
@@ -95,7 +108,7 @@ int gui_irc_colors[16][2] =
|
||||
{ /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
|
||||
};
|
||||
|
||||
t_gui_color *gui_color[NUM_COLORS];
|
||||
t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
GtkWidget *gtk_main_window;
|
||||
GtkWidget *vbox1;
|
||||
@@ -486,7 +499,7 @@ gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > NUM_COLORS - 1))
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
@@ -511,7 +524,7 @@ gui_color_get_pair (int num_color)
|
||||
/*void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
if ((num_color >= 0) && (num_color <= NUM_COLORS - 1))
|
||||
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
|
||||
{
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
|
||||
@@ -2114,7 +2127,7 @@ gui_rebuild_weechat_colors ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_COLORS; i++)
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
|
||||
@@ -95,18 +95,21 @@ gui_action_return (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
command = strdup (window->buffer->input_buffer);
|
||||
if (!command)
|
||||
return;
|
||||
history_buffer_add (window->buffer, window->buffer->input_buffer);
|
||||
history_global_add (window->buffer->input_buffer);
|
||||
window->buffer->input_buffer[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[0] = '\0';
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
window->buffer->completion.position = -1;
|
||||
window->buffer->ptr_history = NULL;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
user_command (SERVER(window->buffer), CHANNEL(window->buffer),
|
||||
command, 0);
|
||||
@@ -141,32 +144,46 @@ gui_action_tab (t_gui_window *window)
|
||||
window->buffer->completion.diff_size;
|
||||
window->buffer->input_buffer_length +=
|
||||
window->buffer->completion.diff_length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
for (i = window->buffer->input_buffer_size - 1;
|
||||
i >= window->buffer->completion.position_replace +
|
||||
(int)strlen (window->buffer->completion.word_found); i--)
|
||||
{
|
||||
window->buffer->input_buffer[i] =
|
||||
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
|
||||
window->buffer->input_buffer_color_mask[i] =
|
||||
window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = window->buffer->completion.position_replace +
|
||||
strlen (window->buffer->completion.word_found);
|
||||
i < window->buffer->input_buffer_size; i++)
|
||||
{
|
||||
window->buffer->input_buffer[i] =
|
||||
window->buffer->input_buffer[i - window->buffer->completion.diff_size];
|
||||
window->buffer->input_buffer_color_mask[i] =
|
||||
window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
|
||||
}
|
||||
window->buffer->input_buffer_size +=
|
||||
window->buffer->completion.diff_size;
|
||||
window->buffer->input_buffer_length +=
|
||||
window->buffer->completion.diff_length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
}
|
||||
|
||||
strncpy (window->buffer->input_buffer + window->buffer->completion.position_replace,
|
||||
window->buffer->completion.word_found,
|
||||
strlen (window->buffer->completion.word_found));
|
||||
for (i = 0; i < (int)strlen (window->buffer->completion.word_found); i++)
|
||||
{
|
||||
window->buffer->input_buffer_color_mask[window->buffer->completion.position_replace + i] = ' ';
|
||||
}
|
||||
window->buffer->input_buffer_pos =
|
||||
utf8_pos (window->buffer->input_buffer,
|
||||
window->buffer->completion.position_replace) +
|
||||
@@ -238,12 +255,13 @@ gui_action_backspace (t_gui_window *window)
|
||||
pos_last = utf8_prev_char (window->buffer->input_buffer, pos);
|
||||
char_size = pos - pos_last;
|
||||
size_to_move = strlen (pos);
|
||||
memmove (pos_last, pos, size_to_move);
|
||||
gui_input_move (window->buffer, pos_last, pos, size_to_move);
|
||||
window->buffer->input_buffer_size -= char_size;
|
||||
window->buffer->input_buffer_length--;
|
||||
window->buffer->input_buffer_pos--;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -270,11 +288,12 @@ gui_action_delete (t_gui_window *window)
|
||||
pos_next = utf8_next_char (pos);
|
||||
char_size = pos_next - pos;
|
||||
size_to_move = strlen (pos_next);
|
||||
memmove (pos, pos_next, size_to_move);
|
||||
gui_input_move (window->buffer, pos, pos_next, size_to_move);
|
||||
window->buffer->input_buffer_size -= char_size;
|
||||
window->buffer->input_buffer_length--;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -327,13 +346,14 @@ gui_action_delete_previous_word (t_gui_window *window)
|
||||
|
||||
gui_action_clipboard_copy (string, size_deleted);
|
||||
|
||||
memmove (string, string + size_deleted, strlen (string + size_deleted));
|
||||
gui_input_move (window->buffer, string, string + size_deleted, strlen (string + size_deleted));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos -= length_deleted;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -367,12 +387,13 @@ gui_action_delete_next_word (t_gui_window *window)
|
||||
|
||||
gui_action_clipboard_copy(start, size_deleted);
|
||||
|
||||
memmove (start, string, strlen (string));
|
||||
gui_input_move (window->buffer, start, string, strlen (string));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -385,7 +406,7 @@ gui_action_delete_next_word (t_gui_window *window)
|
||||
void
|
||||
gui_action_delete_begin_of_line (t_gui_window *window)
|
||||
{
|
||||
int length_deleted, size_deleted;
|
||||
int length_deleted, size_deleted, pos_start;
|
||||
char *start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
@@ -394,18 +415,20 @@ gui_action_delete_begin_of_line (t_gui_window *window)
|
||||
{
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
size_deleted = start - window->buffer->input_buffer;
|
||||
length_deleted = utf8_strnlen (window->buffer->input_buffer, size_deleted);
|
||||
gui_action_clipboard_copy (window->buffer->input_buffer,
|
||||
start - window->buffer->input_buffer);
|
||||
|
||||
memmove (window->buffer->input_buffer, start, strlen (start));
|
||||
gui_input_move (window->buffer, window->buffer->input_buffer, start, strlen (start));
|
||||
|
||||
window->buffer->input_buffer_size -= size_deleted;
|
||||
window->buffer->input_buffer_length -= length_deleted;
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -420,19 +443,21 @@ void
|
||||
gui_action_delete_end_of_line (t_gui_window *window)
|
||||
{
|
||||
char *start;
|
||||
int size_deleted, length_deleted;
|
||||
int size_deleted, length_deleted, pos_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
size_deleted = strlen (start);
|
||||
length_deleted = utf8_strlen (start);
|
||||
gui_action_clipboard_copy (start, size_deleted);
|
||||
start[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[pos_start] = '\0';
|
||||
window->buffer->input_buffer_size = strlen (window->buffer->input_buffer);
|
||||
window->buffer->input_buffer_length = utf8_strlen (window->buffer->input_buffer);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -448,10 +473,11 @@ gui_action_delete_line (t_gui_window *window)
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
window->buffer->input_buffer[0] = '\0';
|
||||
window->buffer->input_buffer_color_mask[0] = '\0';
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
@@ -465,7 +491,8 @@ void
|
||||
gui_action_transpose_chars (t_gui_window *window)
|
||||
{
|
||||
char *start, *prev_char, saved_char[4];
|
||||
int size_current_char;
|
||||
int size_current_char, size_start_char;
|
||||
int pos_prev_char, pos_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
{
|
||||
@@ -476,14 +503,23 @@ gui_action_transpose_chars (t_gui_window *window)
|
||||
|
||||
start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_pos);
|
||||
pos_start = start - window->buffer->input_buffer;
|
||||
prev_char = utf8_prev_char (window->buffer->input_buffer,
|
||||
start);
|
||||
pos_prev_char = prev_char - window->buffer->input_buffer;
|
||||
size_current_char = start - prev_char;
|
||||
size_start_char = utf8_char_size (start);
|
||||
|
||||
memcpy (saved_char, prev_char, size_current_char);
|
||||
memcpy (prev_char, start, utf8_char_size (start));
|
||||
start = utf8_next_char (prev_char);
|
||||
memcpy (prev_char, start, size_start_char);
|
||||
memcpy (start, saved_char, size_current_char);
|
||||
|
||||
memcpy (saved_char, window->buffer->input_buffer_color_mask + pos_prev_char, size_current_char);
|
||||
memcpy (window->buffer->input_buffer_color_mask + pos_prev_char,
|
||||
window->buffer->input_buffer_color_mask + pos_start, size_start_char);
|
||||
memcpy (window->buffer->input_buffer_color_mask + pos_start,
|
||||
saved_char, size_current_char);
|
||||
|
||||
window->buffer->input_buffer_pos++;
|
||||
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
@@ -693,6 +729,7 @@ gui_action_up (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
history_buffer_add (window->buffer, window->buffer->input_buffer);
|
||||
history_global_add (window->buffer->input_buffer);
|
||||
}
|
||||
@@ -702,6 +739,7 @@ gui_action_up (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
if (window->buffer->ptr_history->prev_history->text)
|
||||
free(window->buffer->ptr_history->prev_history->text);
|
||||
window->buffer->ptr_history->prev_history->text = strdup (window->buffer->input_buffer);
|
||||
@@ -711,12 +749,13 @@ gui_action_up (t_gui_window *window)
|
||||
strlen (window->buffer->ptr_history->text);
|
||||
window->buffer->input_buffer_length =
|
||||
utf8_strlen (window->buffer->ptr_history->text);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
strcpy (window->buffer->input_buffer,
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -745,12 +784,13 @@ gui_action_up_global (t_gui_window *window)
|
||||
strlen (history_global_ptr->text);
|
||||
window->buffer->input_buffer_length =
|
||||
utf8_strlen (history_global_ptr->text);
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
strcpy (window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -810,13 +850,16 @@ gui_action_down (t_gui_window *window)
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
}
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
if (window->buffer->ptr_history)
|
||||
{
|
||||
strcpy (window->buffer->input_buffer,
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -846,13 +889,16 @@ gui_action_down_global (t_gui_window *window)
|
||||
window->buffer->input_buffer_size = 0;
|
||||
window->buffer->input_buffer_length = 0;
|
||||
}
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
window->buffer->input_buffer_1st_display = 0;
|
||||
if (history_global_ptr)
|
||||
{
|
||||
strcpy (window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,10 +392,15 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
|
||||
{
|
||||
new_buffer->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
|
||||
new_buffer->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer_color_mask = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer[0] = '\0';
|
||||
new_buffer->input_buffer_color_mask[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
new_buffer->input_buffer = NULL;
|
||||
new_buffer->input_buffer_color_mask = NULL;
|
||||
}
|
||||
new_buffer->input_buffer_size = 0;
|
||||
new_buffer->input_buffer_length = 0;
|
||||
new_buffer->input_buffer_pos = 0;
|
||||
@@ -709,6 +714,8 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
|
||||
|
||||
if (buffer->input_buffer)
|
||||
free (buffer->input_buffer);
|
||||
if (buffer->input_buffer_color_mask)
|
||||
free (buffer->input_buffer_color_mask);
|
||||
|
||||
completion_free (&(buffer->completion));
|
||||
|
||||
@@ -1206,12 +1213,12 @@ gui_infobar_remove_all ()
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_optimize_input_buffer_size: optimize input buffer size by adding
|
||||
* or deleting data block (predefined size)
|
||||
* gui_input_optimize_size: optimize input buffer size by adding
|
||||
* or deleting data block (predefined size)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_optimize_input_buffer_size (t_gui_buffer *buffer)
|
||||
gui_input_optimize_size (t_gui_buffer *buffer)
|
||||
{
|
||||
int optimal_size;
|
||||
|
||||
@@ -1223,10 +1230,46 @@ gui_optimize_input_buffer_size (t_gui_buffer *buffer)
|
||||
{
|
||||
buffer->input_buffer_alloc = optimal_size;
|
||||
buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
|
||||
buffer->input_buffer_color_mask = realloc (buffer->input_buffer_color_mask,
|
||||
optimal_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_init_color_mask: initialize color mask for input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_init_color_mask (t_gui_buffer *buffer)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (buffer->has_input)
|
||||
{
|
||||
for (i = 0; i < buffer->input_buffer_size; i++)
|
||||
buffer->input_buffer_color_mask[i] = ' ';
|
||||
buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_move: move data in input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_move (t_gui_buffer *buffer, char *target, char *source, int size)
|
||||
{
|
||||
int pos_source, pos_target;
|
||||
|
||||
pos_target = target - buffer->input_buffer;
|
||||
pos_source = source - buffer->input_buffer;
|
||||
|
||||
memmove (target, source, size);
|
||||
memmove (buffer->input_buffer_color_mask + pos_target,
|
||||
buffer->input_buffer_color_mask + pos_source, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_exec_action_dcc: execute an action on a DCC after a user input
|
||||
* return -1 if DCC buffer was closed due to action,
|
||||
@@ -1364,7 +1407,7 @@ gui_exec_action_raw_data (t_gui_window *window, char *actions)
|
||||
int
|
||||
gui_insert_string_input (t_gui_window *window, char *string, int pos)
|
||||
{
|
||||
int size, length;
|
||||
int i, pos_start, size, length;
|
||||
char *ptr_start;
|
||||
|
||||
if (window->buffer->has_input)
|
||||
@@ -1378,15 +1421,26 @@ gui_insert_string_input (t_gui_window *window, char *string, int pos)
|
||||
/* increase buffer size */
|
||||
window->buffer->input_buffer_size += size;
|
||||
window->buffer->input_buffer_length += length;
|
||||
gui_optimize_input_buffer_size (window->buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
|
||||
/* move end of string to the right */
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
|
||||
pos_start = ptr_start - window->buffer->input_buffer;
|
||||
memmove (ptr_start + size, ptr_start, strlen (ptr_start));
|
||||
memmove (window->buffer->input_buffer_color_mask + pos_start + size,
|
||||
window->buffer->input_buffer_color_mask + pos_start,
|
||||
strlen (window->buffer->input_buffer_color_mask + pos_start));
|
||||
|
||||
/* insert new string */
|
||||
strncpy (utf8_add_offset (window->buffer->input_buffer, pos), string, size);
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
|
||||
pos_start = ptr_start - window->buffer->input_buffer;
|
||||
strncpy (ptr_start, string, size);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
window->buffer->input_buffer_color_mask[pos_start + i] = ' ';
|
||||
}
|
||||
return length;
|
||||
}
|
||||
return 0;
|
||||
@@ -1869,32 +1923,33 @@ gui_buffer_print_log (t_gui_buffer *buffer)
|
||||
int num;
|
||||
|
||||
weechat_log_printf ("[buffer (addr:0x%X)]\n", buffer);
|
||||
weechat_log_printf (" num_displayed. . . . : %d\n", buffer->num_displayed);
|
||||
weechat_log_printf (" number . . . . . . . : %d\n", buffer->number);
|
||||
weechat_log_printf (" server . . . . . . . : 0x%X\n", buffer->server);
|
||||
weechat_log_printf (" all_servers. . . . . : %d\n", buffer->all_servers);
|
||||
weechat_log_printf (" channel. . . . . . . : 0x%X\n", buffer->channel);
|
||||
weechat_log_printf (" type . . . . . . . . : %d\n", buffer->type);
|
||||
weechat_log_printf (" lines. . . . . . . . : 0x%X\n", buffer->lines);
|
||||
weechat_log_printf (" last_line. . . . . . : 0x%X\n", buffer->last_line);
|
||||
weechat_log_printf (" last_read_line . . . : 0x%X\n", buffer->last_read_line);
|
||||
weechat_log_printf (" num_lines. . . . . . : %d\n", buffer->num_lines);
|
||||
weechat_log_printf (" line_complete. . . . : %d\n", buffer->line_complete);
|
||||
weechat_log_printf (" notify_level . . . . : %d\n", buffer->notify_level);
|
||||
weechat_log_printf (" log_filename . . . . : '%s'\n", buffer->log_filename);
|
||||
weechat_log_printf (" log_file . . . . . . : 0x%X\n", buffer->log_file);
|
||||
weechat_log_printf (" has_input. . . . . . : %d\n", buffer->has_input);
|
||||
weechat_log_printf (" input_buffer . . . . : '%s'\n", buffer->input_buffer);
|
||||
weechat_log_printf (" input_buffer_alloc . : %d\n", buffer->input_buffer_alloc);
|
||||
weechat_log_printf (" input_buffer_size. . : %d\n", buffer->input_buffer_size);
|
||||
weechat_log_printf (" input_buffer_length. : %d\n", buffer->input_buffer_length);
|
||||
weechat_log_printf (" input_buffer_pos . . : %d\n", buffer->input_buffer_pos);
|
||||
weechat_log_printf (" input_buffer_1st_disp: %d\n", buffer->input_buffer_1st_display);
|
||||
weechat_log_printf (" history. . . . . . . : 0x%X\n", buffer->history);
|
||||
weechat_log_printf (" last_history . . . . : 0x%X\n", buffer->last_history);
|
||||
weechat_log_printf (" ptr_history. . . . . : 0x%X\n", buffer->ptr_history);
|
||||
weechat_log_printf (" prev_buffer. . . . . : 0x%X\n", buffer->prev_buffer);
|
||||
weechat_log_printf (" next_buffer. . . . . : 0x%X\n", buffer->next_buffer);
|
||||
weechat_log_printf (" num_displayed. . . . . : %d\n", buffer->num_displayed);
|
||||
weechat_log_printf (" number . . . . . . . . : %d\n", buffer->number);
|
||||
weechat_log_printf (" server . . . . . . . . : 0x%X\n", buffer->server);
|
||||
weechat_log_printf (" all_servers. . . . . . : %d\n", buffer->all_servers);
|
||||
weechat_log_printf (" channel. . . . . . . . : 0x%X\n", buffer->channel);
|
||||
weechat_log_printf (" type . . . . . . . . . : %d\n", buffer->type);
|
||||
weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", buffer->lines);
|
||||
weechat_log_printf (" last_line. . . . . . . : 0x%X\n", buffer->last_line);
|
||||
weechat_log_printf (" last_read_line . . . . : 0x%X\n", buffer->last_read_line);
|
||||
weechat_log_printf (" num_lines. . . . . . . : %d\n", buffer->num_lines);
|
||||
weechat_log_printf (" line_complete. . . . . : %d\n", buffer->line_complete);
|
||||
weechat_log_printf (" notify_level . . . . . : %d\n", buffer->notify_level);
|
||||
weechat_log_printf (" log_filename . . . . . : '%s'\n", buffer->log_filename);
|
||||
weechat_log_printf (" log_file . . . . . . . : 0x%X\n", buffer->log_file);
|
||||
weechat_log_printf (" has_input. . . . . . . : %d\n", buffer->has_input);
|
||||
weechat_log_printf (" input_buffer . . . . . : '%s'\n", buffer->input_buffer);
|
||||
weechat_log_printf (" input_buffer_color_mask: '%s'\n", buffer->input_buffer_color_mask);
|
||||
weechat_log_printf (" input_buffer_alloc . . : %d\n", buffer->input_buffer_alloc);
|
||||
weechat_log_printf (" input_buffer_size. . . : %d\n", buffer->input_buffer_size);
|
||||
weechat_log_printf (" input_buffer_length. . : %d\n", buffer->input_buffer_length);
|
||||
weechat_log_printf (" input_buffer_pos . . . : %d\n", buffer->input_buffer_pos);
|
||||
weechat_log_printf (" input_buffer_1st_disp. : %d\n", buffer->input_buffer_1st_display);
|
||||
weechat_log_printf (" history. . . . . . . . : 0x%X\n", buffer->history);
|
||||
weechat_log_printf (" last_history . . . . . : 0x%X\n", buffer->last_history);
|
||||
weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", buffer->ptr_history);
|
||||
weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", buffer->prev_buffer);
|
||||
weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", buffer->next_buffer);
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" => last 100 lines:\n");
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
#include "gui.h"
|
||||
#include "../common/command.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
t_gui_key *gui_keys = NULL;
|
||||
t_gui_key *last_gui_key = NULL;
|
||||
@@ -506,7 +510,8 @@ gui_key_pressed (char *key_str)
|
||||
{
|
||||
int first_key;
|
||||
t_gui_key *ptr_key;
|
||||
|
||||
char *buffer_before_key;
|
||||
|
||||
/* add key to buffer */
|
||||
first_key = (gui_key_buffer[0] == '\0');
|
||||
strcat (gui_key_buffer, key_str);
|
||||
@@ -525,6 +530,9 @@ gui_key_pressed (char *key_str)
|
||||
if (ascii_strcasecmp (ptr_key->key, gui_key_buffer) == 0)
|
||||
{
|
||||
/* exact combo found => execute function or command */
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_key_buffer[0] = '\0';
|
||||
if (ptr_key->command)
|
||||
user_command (SERVER(gui_current_window->buffer),
|
||||
@@ -532,6 +540,15 @@ gui_key_pressed (char *key_str)
|
||||
ptr_key->command, 0);
|
||||
else
|
||||
(void)(ptr_key->function)(gui_current_window);
|
||||
#ifdef PLUGINS
|
||||
(void) plugin_keyboard_handler_exec (
|
||||
(ptr_key->command) ?
|
||||
ptr_key->command : gui_key_function_search_by_ptr (ptr_key->function),
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+8
-15
@@ -26,18 +26,6 @@
|
||||
|
||||
#define INPUT_BUFFER_BLOCK_SIZE 256
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
#define COLOR_WIN_NICK_NUMBER 10
|
||||
|
||||
typedef enum t_weechat_color t_weechat_color;
|
||||
@@ -103,9 +91,11 @@ enum t_weechat_color
|
||||
COLOR_DCC_DONE,
|
||||
COLOR_DCC_FAILED,
|
||||
COLOR_DCC_ABORTED,
|
||||
NUM_COLORS
|
||||
GUI_NUM_COLORS
|
||||
};
|
||||
|
||||
#define GUI_NUM_IRC_COLORS 16
|
||||
|
||||
/* attributes in IRC messages for color & style (bold, ..) */
|
||||
|
||||
#define GUI_ATTR_BOLD_CHAR '\x02'
|
||||
@@ -252,6 +242,7 @@ struct t_gui_buffer
|
||||
/* inupt buffer */
|
||||
int has_input; /* = 1 if buffer has input (DCC has not)*/
|
||||
char *input_buffer; /* input buffer */
|
||||
char *input_buffer_color_mask; /* color mask for input buffer */
|
||||
int input_buffer_alloc; /* input buffer: allocated size in mem */
|
||||
int input_buffer_size; /* buffer size in bytes */
|
||||
int input_buffer_length; /* number of chars in buffer */
|
||||
@@ -402,7 +393,7 @@ extern int gui_key_grab_count;
|
||||
extern char *gui_input_clipboard;
|
||||
extern time_t gui_last_activity_time;
|
||||
|
||||
extern t_gui_color *gui_color[NUM_COLORS];
|
||||
extern t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
/* GUI independent functions: windows & buffers */
|
||||
|
||||
@@ -427,7 +418,9 @@ extern int gui_word_strlen (t_gui_window *, char *);
|
||||
extern int gui_word_real_pos (t_gui_window *, char *, int);
|
||||
extern void gui_printf_internal (t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_printf_raw_data (void *, int, char *);
|
||||
extern void gui_optimize_input_buffer_size (t_gui_buffer *);
|
||||
extern void gui_input_optimize_size (t_gui_buffer *);
|
||||
extern void gui_input_init_color_mask (t_gui_buffer *);
|
||||
extern void gui_input_move (t_gui_buffer *, char *, char *, int );
|
||||
extern void gui_exec_action_dcc (t_gui_window *, char *);
|
||||
extern void gui_exec_action_raw_data (t_gui_window *, char *);
|
||||
extern int gui_insert_string_input (t_gui_window *, char *, int);
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
#include "../common/hotlist.h"
|
||||
#include "../common/weeconfig.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
char *irc_last_command_received = NULL;
|
||||
|
||||
@@ -316,6 +316,22 @@ weechat_plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_keyboard_handler_add: add a keyboard handler
|
||||
*/
|
||||
|
||||
t_plugin_handler *
|
||||
weechat_plugin_keyboard_handler_add (t_weechat_plugin *plugin,
|
||||
t_plugin_handler_func *handler_func,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (plugin && handler_func)
|
||||
return plugin_keyboard_handler_add (plugin, handler_func,
|
||||
handler_args, handler_pointer);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_handler_remove: remove a WeeChat handler
|
||||
*/
|
||||
@@ -385,7 +401,7 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
time_t inactivity;
|
||||
char *inactivity_str;
|
||||
char *return_str;
|
||||
|
||||
if (!plugin || !info)
|
||||
return NULL;
|
||||
@@ -420,11 +436,39 @@ weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server)
|
||||
inactivity = 0;
|
||||
else
|
||||
inactivity = time (NULL) - gui_last_activity_time;
|
||||
inactivity_str = (char *) malloc (128);
|
||||
if (!inactivity_str)
|
||||
return_str = (char *) malloc (32);
|
||||
if (!return_str)
|
||||
return NULL;
|
||||
snprintf (inactivity_str, 128, "%ld", inactivity);
|
||||
return inactivity_str;
|
||||
snprintf (return_str, 32, "%ld", inactivity);
|
||||
return return_str;
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
return strdup (gui_current_window->buffer->input_buffer);
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input_mask") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
return strdup (gui_current_window->buffer->input_buffer_color_mask);
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
else if (ascii_strcasecmp (info, "input_pos") == 0)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
return_str = (char *) malloc (32);
|
||||
if (!return_str)
|
||||
return NULL;
|
||||
snprintf (return_str, 32, "%d",
|
||||
gui_current_window->buffer->input_buffer_pos);
|
||||
return return_str;
|
||||
}
|
||||
else
|
||||
return strdup ("");
|
||||
}
|
||||
|
||||
/* below are infos that need server to return value */
|
||||
@@ -1009,3 +1053,38 @@ weechat_plugin_free_nick_info (t_weechat_plugin *plugin, t_plugin_nick_info *nic
|
||||
nick_info = new_nick_info;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_input_color: add color in input buffer
|
||||
* if color < 0, input buffer is refresh
|
||||
* if start < 0 or length <= 0, color mask is reinit
|
||||
* otherwise, color is applied from start to start + length
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_plugin_input_color (t_weechat_plugin *plugin, int color, int start, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!plugin
|
||||
|| (!gui_current_window->buffer->has_input)
|
||||
|| (gui_current_window->buffer->input_buffer_size == 0))
|
||||
return;
|
||||
|
||||
if (color < 0)
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
else
|
||||
{
|
||||
if ((start < 0) || (length <= 0))
|
||||
gui_input_init_color_mask (gui_current_window->buffer);
|
||||
else
|
||||
{
|
||||
color %= GUI_NUM_IRC_COLORS;
|
||||
for (i = start; i < start + length; i++)
|
||||
{
|
||||
gui_current_window->buffer->input_buffer_color_mask[i] =
|
||||
'0' + color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +370,62 @@ plugin_timer_handler_add (t_weechat_plugin *plugin, int interval,
|
||||
return new_handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_keyboard_handler_add: add a timer handler
|
||||
* arguments:
|
||||
* 1. the plugin pointer
|
||||
* 2. the interval between two calls
|
||||
* 3. the handler function
|
||||
* 4. handler args: a string given to
|
||||
* handler when called (used by scripts)
|
||||
* 5. handler pointer: a pointer given to
|
||||
* handler when called (used by scripts)
|
||||
*/
|
||||
|
||||
t_plugin_handler *
|
||||
plugin_keyboard_handler_add (t_weechat_plugin *plugin,
|
||||
t_plugin_handler_func *handler_func,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
t_plugin_handler *new_handler;
|
||||
|
||||
new_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
|
||||
if (new_handler)
|
||||
{
|
||||
new_handler->type = HANDLER_KEYBOARD;
|
||||
new_handler->irc_command = NULL;
|
||||
new_handler->command = NULL;
|
||||
new_handler->description = NULL;
|
||||
new_handler->arguments = NULL;
|
||||
new_handler->arguments_description = NULL;
|
||||
new_handler->completion_template = NULL;
|
||||
new_handler->interval = 0;
|
||||
new_handler->remaining = 0;
|
||||
new_handler->handler = handler_func;
|
||||
new_handler->handler_args = (handler_args) ? strdup (handler_args) : NULL;
|
||||
new_handler->handler_pointer = handler_pointer;
|
||||
new_handler->running = 0;
|
||||
|
||||
/* add new handler to list */
|
||||
new_handler->prev_handler = plugin->last_handler;
|
||||
new_handler->next_handler = NULL;
|
||||
if (plugin->handlers)
|
||||
(plugin->last_handler)->next_handler = new_handler;
|
||||
else
|
||||
plugin->handlers = new_handler;
|
||||
plugin->last_handler = new_handler;
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s plugin %s: unable to add keyboard handler (not enough memory)\n"),
|
||||
WEECHAT_ERROR, plugin->name);
|
||||
return NULL;
|
||||
}
|
||||
return new_handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_msg_handler_exec: execute a message handler
|
||||
* return: code for informing WeeChat whether message
|
||||
@@ -382,6 +438,11 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code, final_return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = server;
|
||||
argv[1] = irc_command;
|
||||
argv[2] = irc_message;
|
||||
|
||||
final_return_code = PLUGIN_RC_OK;
|
||||
|
||||
@@ -398,9 +459,7 @@ plugin_msg_handler_exec (char *server, char *irc_command, char *irc_message)
|
||||
{
|
||||
ptr_handler->running = 1;
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
server,
|
||||
irc_command,
|
||||
irc_message,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
ptr_handler->running = 0;
|
||||
@@ -432,6 +491,11 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = server;
|
||||
argv[1] = command;
|
||||
argv[2] = arguments;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
@@ -446,9 +510,7 @@ plugin_cmd_handler_exec (char *server, char *command, char *arguments)
|
||||
{
|
||||
ptr_handler->running = 1;
|
||||
return_code = (int) (ptr_handler->handler) (ptr_plugin,
|
||||
server,
|
||||
command,
|
||||
arguments,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer);
|
||||
ptr_handler->running = 0;
|
||||
@@ -488,9 +550,7 @@ plugin_timer_handler_exec ()
|
||||
if (ptr_handler->remaining <= 0)
|
||||
{
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0, NULL,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
ptr_handler->remaining = ptr_handler->interval;
|
||||
@@ -504,6 +564,47 @@ plugin_timer_handler_exec ()
|
||||
return final_return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_keyboard_handler_exec: execute all keyboard handlers
|
||||
* return: PLUGIN_RC_OK if all ok
|
||||
* PLUGIN_RC_KO if at least one handler failed
|
||||
*/
|
||||
|
||||
int
|
||||
plugin_keyboard_handler_exec (char *key, char *input_before, char *input_after)
|
||||
{
|
||||
t_weechat_plugin *ptr_plugin;
|
||||
t_plugin_handler *ptr_handler;
|
||||
int return_code, final_return_code;
|
||||
char *argv[3] = { NULL, NULL, NULL };
|
||||
|
||||
argv[0] = key;
|
||||
argv[1] = input_before;
|
||||
argv[2] = input_after;
|
||||
|
||||
final_return_code = PLUGIN_RC_OK;
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
for (ptr_handler = ptr_plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if (ptr_handler->type == HANDLER_KEYBOARD)
|
||||
{
|
||||
return_code = ((int) (ptr_handler->handler) (ptr_plugin,
|
||||
3, argv,
|
||||
ptr_handler->handler_args,
|
||||
ptr_handler->handler_pointer));
|
||||
if (return_code == PLUGIN_RC_KO)
|
||||
final_return_code = PLUGIN_RC_KO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return final_return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* plugin_handler_remove: remove a handler for a plugin
|
||||
*/
|
||||
@@ -736,6 +837,7 @@ plugin_load (char *filename)
|
||||
new_plugin->msg_handler_add = &weechat_plugin_msg_handler_add;
|
||||
new_plugin->cmd_handler_add = &weechat_plugin_cmd_handler_add;
|
||||
new_plugin->timer_handler_add = &weechat_plugin_timer_handler_add;
|
||||
new_plugin->keyboard_handler_add = &weechat_plugin_keyboard_handler_add;
|
||||
new_plugin->handler_remove = &weechat_plugin_handler_remove;
|
||||
new_plugin->handler_remove_all = &weechat_plugin_handler_remove_all;
|
||||
new_plugin->print = &weechat_plugin_print;
|
||||
@@ -757,6 +859,7 @@ plugin_load (char *filename)
|
||||
new_plugin->free_channel_info = &weechat_plugin_free_channel_info;
|
||||
new_plugin->get_nick_info = &weechat_plugin_get_nick_info;
|
||||
new_plugin->free_nick_info = &weechat_plugin_free_nick_info;
|
||||
new_plugin->input_color = &weechat_plugin_input_color;
|
||||
|
||||
/* handlers */
|
||||
new_plugin->handlers = NULL;
|
||||
|
||||
@@ -48,9 +48,13 @@ extern t_plugin_handler *plugin_cmd_handler_add (t_weechat_plugin *, char *,
|
||||
extern t_plugin_handler *plugin_timer_handler_add (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern t_plugin_handler *plugin_keyboard_handler_add (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern int plugin_msg_handler_exec (char *, char *, char *);
|
||||
extern int plugin_cmd_handler_exec (char *, char *, char *);
|
||||
extern int plugin_timer_handler_exec ();
|
||||
extern int plugin_keyboard_handler_exec (char *, char *, char *);
|
||||
extern void plugin_handler_remove (t_weechat_plugin *,
|
||||
t_plugin_handler *);
|
||||
extern void plugin_handler_remove_all (t_weechat_plugin *);
|
||||
|
||||
@@ -54,7 +54,7 @@ lua_State *lua_current_interpreter = NULL;
|
||||
int
|
||||
weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
|
||||
lua_current_interpreter = script->interpreter;
|
||||
@@ -62,10 +62,19 @@ weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
lua_getglobal (lua_current_interpreter, function);
|
||||
lua_current_script = script;
|
||||
|
||||
lua_pushstring (lua_current_interpreter, server == NULL ? "" : server);
|
||||
lua_pushstring (lua_current_interpreter, arguments == NULL ? "" : arguments);
|
||||
if (arg1)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, (arg1) ? arg1 : "");
|
||||
if (arg2)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, (arg2) ? arg2 : "");
|
||||
if (arg3)
|
||||
lua_pushstring (lua_current_interpreter, (arg3) ? arg3 : "");
|
||||
}
|
||||
}
|
||||
|
||||
if ( lua_pcall(lua_current_interpreter, 2, 1, 0) != 0)
|
||||
if (lua_pcall (lua_current_interpreter,
|
||||
(arg1) ? ((arg2) ? ((arg3) ? 3 : 2) : 1) : 0, 1, 0) != 0)
|
||||
{
|
||||
plugin->print_server (plugin,
|
||||
"Lua error: unable to run function \"%s\"",
|
||||
@@ -80,19 +89,52 @@ weechat_lua_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_handler: general message and command handler for Lua
|
||||
* weechat_lua_cmd_msg_handler: general command/message handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_lua_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_timer_handler: general timer handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_keyboard_handler: general keyboard handler for Lua
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 2)
|
||||
return weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,6 +146,7 @@ weechat_lua_register (lua_State *L)
|
||||
{
|
||||
const char *name, *version, *shutdown_func, *description;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -179,6 +222,7 @@ weechat_lua_print (lua_State *L)
|
||||
{
|
||||
const char *message, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -199,24 +243,24 @@ weechat_lua_print (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"print\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"print\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->print (lua_plugin,
|
||||
@@ -237,6 +281,7 @@ weechat_lua_print_infobar (lua_State *L)
|
||||
{
|
||||
const char *message;
|
||||
int delay, n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -280,6 +325,7 @@ static int
|
||||
weechat_lua_remove_infobar (lua_State *L)
|
||||
{
|
||||
int n, how_many;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -314,6 +360,7 @@ weechat_lua_log (lua_State *L)
|
||||
{
|
||||
const char *message, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -334,24 +381,24 @@ weechat_lua_log (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"log\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
message = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"log\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->log (lua_plugin,
|
||||
@@ -372,6 +419,7 @@ weechat_lua_command (lua_State *L)
|
||||
{
|
||||
const char *command, *channel_name, *server_name;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -392,24 +440,24 @@ weechat_lua_command (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"command\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 3:
|
||||
server_name = lua_tostring (lua_current_interpreter, -3);
|
||||
channel_name = lua_tostring (lua_current_interpreter, -2);
|
||||
command = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"command\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_plugin->exec_command (lua_plugin,
|
||||
@@ -430,6 +478,7 @@ weechat_lua_add_message_handler (lua_State *L)
|
||||
{
|
||||
const char *irc_command, *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -460,7 +509,8 @@ weechat_lua_add_message_handler (lua_State *L)
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->msg_handler_add (lua_plugin, (char *) irc_command,
|
||||
weechat_lua_handler, (char *) function,
|
||||
weechat_lua_cmd_msg_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
@@ -481,6 +531,7 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
const char *command, *function, *description, *arguments, *arguments_description;
|
||||
const char *completion_template;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -504,24 +555,24 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 2:
|
||||
command = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 6:
|
||||
command = lua_tostring (lua_current_interpreter, -6);
|
||||
function = lua_tostring (lua_current_interpreter, -5);
|
||||
description = lua_tostring (lua_current_interpreter, -4);
|
||||
arguments = lua_tostring (lua_current_interpreter, -3);
|
||||
arguments_description = lua_tostring (lua_current_interpreter, -2);
|
||||
completion_template = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_command_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 2:
|
||||
command = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 6:
|
||||
command = lua_tostring (lua_current_interpreter, -6);
|
||||
function = lua_tostring (lua_current_interpreter, -5);
|
||||
description = lua_tostring (lua_current_interpreter, -4);
|
||||
arguments = lua_tostring (lua_current_interpreter, -3);
|
||||
arguments_description = lua_tostring (lua_current_interpreter, -2);
|
||||
completion_template = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_command_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!lua_plugin->cmd_handler_add (lua_plugin,
|
||||
@@ -530,7 +581,7 @@ weechat_lua_add_command_handler (lua_State *L)
|
||||
(char *) arguments,
|
||||
(char *) arguments_description,
|
||||
(char *) completion_template,
|
||||
weechat_lua_handler,
|
||||
weechat_lua_cmd_msg_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
@@ -552,6 +603,7 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
int interval;
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -582,7 +634,8 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->timer_handler_add (lua_plugin, interval,
|
||||
weechat_lua_handler, (char *) function,
|
||||
weechat_lua_timer_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
@@ -594,7 +647,57 @@ weechat_lua_add_timer_handler (lua_State *L)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_handler: remove a handler
|
||||
* weechat_lua_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_add_keyboard_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n != 1)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
if (!lua_plugin->keyboard_handler_add (lua_plugin,
|
||||
weechat_lua_keyboard_handler,
|
||||
(char *) function,
|
||||
(void *)lua_current_script))
|
||||
{
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_handler: remove a command/message handler
|
||||
*/
|
||||
|
||||
static int
|
||||
@@ -602,6 +705,7 @@ weechat_lua_remove_handler (lua_State *L)
|
||||
{
|
||||
const char *command, *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -647,6 +751,7 @@ weechat_lua_remove_timer_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -681,6 +786,50 @@ weechat_lua_remove_timer_handler (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_remove_keyboard_handler (lua_State *L)
|
||||
{
|
||||
const char *function;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n != 1)
|
||||
{
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
weechat_script_remove_keyboard_handler (lua_plugin, lua_current_script,
|
||||
(char *) function);
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_get_info: get various infos
|
||||
*/
|
||||
@@ -691,6 +840,7 @@ weechat_lua_get_info (lua_State *L)
|
||||
const char *arg, *server_name;
|
||||
char *info;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -710,19 +860,19 @@ weechat_lua_get_info (lua_State *L)
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
arg = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
arg = lua_tostring (lua_current_interpreter, -2);
|
||||
server_name = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"get_info\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
case 1:
|
||||
arg = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
case 2:
|
||||
arg = lua_tostring (lua_current_interpreter, -2);
|
||||
server_name = lua_tostring (lua_current_interpreter, -1);
|
||||
break;
|
||||
default:
|
||||
lua_plugin->print_server (lua_plugin,
|
||||
"Lua error: wrong parameters for "
|
||||
"\"get_info\" function");
|
||||
lua_pushnumber (lua_current_interpreter, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
info = lua_plugin->get_info (lua_plugin, (char *) arg, (char *) server_name);
|
||||
@@ -746,6 +896,7 @@ weechat_lua_get_dcc_info (lua_State *L)
|
||||
char timebuffer2[64];
|
||||
struct in_addr in;
|
||||
int i;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -767,7 +918,7 @@ weechat_lua_get_dcc_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(i=0, ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc, i++)
|
||||
for (i = 0, ptr_dcc = dcc_info; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc, i++)
|
||||
{
|
||||
strftime(timebuffer1, sizeof(timebuffer1), "%F %T",
|
||||
localtime(&ptr_dcc->start_time));
|
||||
@@ -860,6 +1011,7 @@ weechat_lua_get_config (lua_State *L)
|
||||
const char *option;
|
||||
char *return_value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -905,6 +1057,7 @@ weechat_lua_set_config (lua_State *L)
|
||||
{
|
||||
const char *option, *value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -952,6 +1105,7 @@ weechat_lua_get_plugin_config (lua_State *L)
|
||||
const char *option;
|
||||
char *return_value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -999,6 +1153,7 @@ weechat_lua_set_plugin_config (lua_State *L)
|
||||
{
|
||||
const char *option, *value;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1047,6 +1202,7 @@ weechat_lua_get_server_info (lua_State *L)
|
||||
{
|
||||
t_plugin_server_info *server_info, *ptr_server;
|
||||
char timebuffer[64];
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1067,7 +1223,7 @@ weechat_lua_get_server_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(ptr_server = server_info; ptr_server; ptr_server = ptr_server->next_server)
|
||||
for (ptr_server = server_info; ptr_server; ptr_server = ptr_server->next_server)
|
||||
{
|
||||
strftime(timebuffer, sizeof(timebuffer), "%F %T",
|
||||
localtime(&ptr_server->away_time));
|
||||
@@ -1201,6 +1357,7 @@ weechat_lua_get_channel_info (lua_State *L)
|
||||
t_plugin_channel_info *channel_info, *ptr_channel;
|
||||
const char *server;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1237,7 +1394,7 @@ weechat_lua_get_channel_info (lua_State *L)
|
||||
|
||||
lua_newtable (lua_current_interpreter);
|
||||
|
||||
for(ptr_channel = channel_info; ptr_channel; ptr_channel = ptr_channel->next_channel)
|
||||
for (ptr_channel = channel_info; ptr_channel; ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
lua_pushstring (lua_current_interpreter, ptr_channel->name);
|
||||
lua_newtable (lua_current_interpreter);
|
||||
@@ -1284,6 +1441,7 @@ weechat_lua_get_nick_info (lua_State *L)
|
||||
t_plugin_nick_info *nick_info, *ptr_nick;
|
||||
const char *server, *channel;
|
||||
int n;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
@@ -1349,6 +1507,7 @@ weechat_lua_constant_plugin_rc_ok (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK);
|
||||
return 1;
|
||||
}
|
||||
@@ -1358,6 +1517,7 @@ weechat_lua_constant_plugin_rc_ko (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_KO);
|
||||
return 1;
|
||||
}
|
||||
@@ -1367,6 +1527,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_weechat (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_WEECHAT);
|
||||
return 1;
|
||||
}
|
||||
@@ -1376,6 +1537,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_plugins (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_PLUGINS);
|
||||
return 1;
|
||||
}
|
||||
@@ -1385,6 +1547,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_all (lua_State *L)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) L;
|
||||
|
||||
lua_pushnumber (lua_current_interpreter, PLUGIN_RC_OK_IGNORE_ALL);
|
||||
return 1;
|
||||
}
|
||||
@@ -1404,8 +1567,10 @@ const struct luaL_reg weechat_lua_funcs[] = {
|
||||
{ "add_message_handler", weechat_lua_add_message_handler},
|
||||
{ "add_command_handler", weechat_lua_add_command_handler},
|
||||
{ "add_timer_handler", weechat_lua_add_timer_handler},
|
||||
{ "add_keyboard_handler", weechat_lua_add_keyboard_handler},
|
||||
{ "remove_handler", weechat_lua_remove_handler},
|
||||
{ "remove_timer_handler", weechat_lua_remove_timer_handler},
|
||||
{ "remove_keyboard_handler", weechat_lua_remove_keyboard_handler},
|
||||
{ "get_info", weechat_lua_get_info},
|
||||
{ "get_dcc_info", weechat_lua_get_dcc_info},
|
||||
{ "get_config", weechat_lua_get_config},
|
||||
@@ -1536,7 +1701,7 @@ weechat_lua_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_lua_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_lua_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
lua_close (script->interpreter);
|
||||
|
||||
@@ -1590,8 +1755,8 @@ weechat_lua_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
char **argv, *path_script;
|
||||
@@ -1599,13 +1764,14 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1687,6 +1853,24 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Lua keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Lua keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Lua(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1730,7 +1914,7 @@ weechat_lua_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -103,11 +103,11 @@ char *weechat_perl_code =
|
||||
int
|
||||
weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
char empty_server[1] = { '\0' };
|
||||
char empty_arg[1] = { '\0' };
|
||||
char *func;
|
||||
char *argv[3];
|
||||
char *argv[4];
|
||||
unsigned int count;
|
||||
int return_code;
|
||||
SV *sv;
|
||||
@@ -116,11 +116,11 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
dSP;
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
int size = strlen(script->interpreter) + strlen(function) + 3;
|
||||
int size = strlen (script->interpreter) + strlen(function) + 3;
|
||||
func = (char *) malloc ( size * sizeof(char));
|
||||
if (func == NULL)
|
||||
if (!func)
|
||||
return PLUGIN_RC_KO;
|
||||
snprintf(func, size, "%s::%s", (char *) script->interpreter, function);
|
||||
snprintf (func, size, "%s::%s", (char *) script->interpreter, function);
|
||||
#else
|
||||
func = function;
|
||||
PERL_SET_CONTEXT (script->interpreter);
|
||||
@@ -129,12 +129,25 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(sp);
|
||||
if (!server)
|
||||
argv[0] = empty_server;
|
||||
if (arg1)
|
||||
{
|
||||
argv[0] = (arg1) ? arg1 : empty_arg;
|
||||
if (arg2)
|
||||
{
|
||||
argv[1] = (arg2) ? arg2 : empty_arg;
|
||||
if (arg3)
|
||||
{
|
||||
argv[2] = (arg3) ? arg3 : empty_arg;
|
||||
argv[3] = NULL;
|
||||
}
|
||||
else
|
||||
argv[2] = NULL;
|
||||
}
|
||||
else
|
||||
argv[1] = NULL;
|
||||
}
|
||||
else
|
||||
argv[0] = server;
|
||||
argv[1] = arguments;
|
||||
argv[2] = NULL;
|
||||
argv[0] = NULL;
|
||||
|
||||
perl_current_script = script;
|
||||
|
||||
@@ -166,26 +179,59 @@ weechat_perl_exec (t_weechat_plugin *plugin,
|
||||
LEAVE;
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
free(func);
|
||||
free (func);
|
||||
#endif
|
||||
|
||||
return return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_handler: general message and command handler for Perl
|
||||
* weechat_perl_cmd_msg_handler: general command/message handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_perl_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_timer_handler: general timer handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_keyboard_handler: general keyboard handler for Perl
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -456,7 +502,7 @@ static XS (XS_weechat_command)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_message_handler: add handler for messages (privmsg, ...)
|
||||
* weechat::add_message_handler: add a handler for messages (privmsg, ...)
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_message_handler)
|
||||
@@ -488,7 +534,7 @@ static XS (XS_weechat_add_message_handler)
|
||||
function = SvPV (ST (1), integer);
|
||||
|
||||
if (perl_plugin->msg_handler_add (perl_plugin, irc_command,
|
||||
weechat_perl_handler, function,
|
||||
weechat_perl_cmd_msg_handler, function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
@@ -496,7 +542,7 @@ static XS (XS_weechat_add_message_handler)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_command_handler: add command handler (define/redefine commands)
|
||||
* weechat::add_command_handler: add a command handler (define/redefine commands)
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_command_handler)
|
||||
@@ -538,7 +584,7 @@ static XS (XS_weechat_add_command_handler)
|
||||
arguments,
|
||||
arguments_description,
|
||||
completion_template,
|
||||
weechat_perl_handler,
|
||||
weechat_perl_cmd_msg_handler,
|
||||
function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
@@ -547,7 +593,7 @@ static XS (XS_weechat_add_command_handler)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_timer_handler: add timer handler
|
||||
* weechat::add_timer_handler: add a timer handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_timer_handler)
|
||||
@@ -579,16 +625,54 @@ static XS (XS_weechat_add_timer_handler)
|
||||
interval = SvIV (ST (0));
|
||||
function = SvPV (ST (1), integer);
|
||||
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl add timer: interval = %d", interval);
|
||||
if (perl_plugin->timer_handler_add (perl_plugin, interval,
|
||||
weechat_perl_handler, function,
|
||||
weechat_perl_timer_handler, function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_add_keyboard_handler)
|
||||
{
|
||||
char *function;
|
||||
unsigned int integer;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
function = SvPV (ST (0), integer);
|
||||
|
||||
if (perl_plugin->keyboard_handler_add (perl_plugin,
|
||||
weechat_perl_keyboard_handler,
|
||||
function,
|
||||
(void *)perl_current_script))
|
||||
XSRETURN_YES;
|
||||
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::remove_handler: remove a message/command handler
|
||||
*/
|
||||
@@ -664,6 +748,43 @@ static XS (XS_weechat_remove_timer_handler)
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_remove_keyboard_handler)
|
||||
{
|
||||
char *function;
|
||||
unsigned int integer;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
function = SvPV (ST (0), integer);
|
||||
|
||||
weechat_script_remove_keyboard_handler (perl_plugin, perl_current_script,
|
||||
function);
|
||||
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::get_info: get various infos
|
||||
*/
|
||||
@@ -1170,6 +1291,43 @@ static XS (XS_weechat_get_nick_info)
|
||||
XSRETURN (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::color_input: add color in input buffer
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_input_color)
|
||||
{
|
||||
int color, start, length;
|
||||
dXSARGS;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: unable to colorize input, "
|
||||
"script not initialized");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
perl_plugin->print_server (perl_plugin,
|
||||
"Perl error: wrong parameters for "
|
||||
"\"color_input\" function");
|
||||
XSRETURN_NO;
|
||||
}
|
||||
|
||||
color = SvIV (ST (0));
|
||||
start = SvIV (ST (1));
|
||||
length = SvIV (ST (2));
|
||||
|
||||
perl_plugin->input_color (perl_plugin, color, start, length);
|
||||
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_xs_init: initialize subroutines
|
||||
*/
|
||||
@@ -1191,8 +1349,10 @@ weechat_perl_xs_init (pTHX)
|
||||
newXS ("weechat::add_message_handler", XS_weechat_add_message_handler, "weechat");
|
||||
newXS ("weechat::add_command_handler", XS_weechat_add_command_handler, "weechat");
|
||||
newXS ("weechat::add_timer_handler", XS_weechat_add_timer_handler, "weechat");
|
||||
newXS ("weechat::add_keyboard_handler", XS_weechat_add_keyboard_handler, "weechat");
|
||||
newXS ("weechat::remove_handler", XS_weechat_remove_handler, "weechat");
|
||||
newXS ("weechat::remove_timer_handler", XS_weechat_remove_timer_handler, "weechat");
|
||||
newXS ("weechat::remove_keyboard_handler", XS_weechat_remove_keyboard_handler, "weechat");
|
||||
newXS ("weechat::get_info", XS_weechat_get_info, "weechat");
|
||||
newXS ("weechat::get_dcc_info", XS_weechat_get_dcc_info, "weechat");
|
||||
newXS ("weechat::get_config", XS_weechat_get_config, "weechat");
|
||||
@@ -1202,6 +1362,7 @@ weechat_perl_xs_init (pTHX)
|
||||
newXS ("weechat::get_server_info", XS_weechat_get_server_info, "weechat");
|
||||
newXS ("weechat::get_channel_info", XS_weechat_get_channel_info, "weechat");
|
||||
newXS ("weechat::get_nick_info", XS_weechat_get_nick_info, "weechat");
|
||||
newXS ("weechat::input_color", XS_weechat_input_color, "weechat");
|
||||
|
||||
/* interface constants */
|
||||
stash = gv_stashpv ("weechat", TRUE);
|
||||
@@ -1237,7 +1398,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
|
||||
snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, packnum);
|
||||
packnum++;
|
||||
tempscript.interpreter = "WeechatPerlScriptLoader";
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, pkgname);
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, pkgname, "");
|
||||
#else
|
||||
perl_current_interpreter = perl_alloc();
|
||||
|
||||
@@ -1256,7 +1417,7 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
|
||||
perl_parse (perl_current_interpreter, weechat_perl_xs_init, 3, perl_args, NULL);
|
||||
|
||||
eval_pv (weechat_perl_code, TRUE);
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, "");
|
||||
eval = weechat_perl_exec (plugin, &tempscript, "weechat_perl_load_eval_file", filename, "", "");
|
||||
|
||||
free (perl_current_script_filename);
|
||||
|
||||
@@ -1338,7 +1499,7 @@ weechat_perl_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
#endif
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_perl_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_perl_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
#ifndef MULTIPLICITY
|
||||
if (script->interpreter)
|
||||
@@ -1398,7 +1559,7 @@ weechat_perl_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1406,14 +1567,15 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_script *ptr_script;
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1497,6 +1659,22 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Perl keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Perl keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Perl(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (plugin->ascii_strcasecmp (plugin, argv[0], "autoload") == 0)
|
||||
@@ -1538,7 +1716,7 @@ weechat_perl_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -50,7 +50,7 @@ PyThreadState *python_mainThreadState = NULL;
|
||||
int
|
||||
weechat_python_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
PyObject *evMain;
|
||||
PyObject *evDict;
|
||||
@@ -75,8 +75,21 @@ weechat_python_exec (t_weechat_plugin *plugin,
|
||||
ret = -1;
|
||||
|
||||
python_current_script = script;
|
||||
|
||||
rc = PyObject_CallFunction(evFunc, "ss", server == NULL ? "" : server, arguments == NULL ? "" : arguments);
|
||||
|
||||
if (arg1)
|
||||
{
|
||||
if (arg2)
|
||||
{
|
||||
if (arg3)
|
||||
rc = PyObject_CallFunction (evFunc, "sss", arg1, arg2, arg3);
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "ss", arg1, arg2);
|
||||
}
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "s", arg1);
|
||||
}
|
||||
else
|
||||
rc = PyObject_CallFunction (evFunc, "");
|
||||
|
||||
if (rc)
|
||||
{
|
||||
@@ -94,19 +107,52 @@ weechat_python_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_handler: general message and command handler for Python
|
||||
* weechat_python_cmd_msg_handler: general command/message handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_python_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_timer_handler: general timer handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_keyboard_handler: general keyboard handler for Python
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -392,7 +438,8 @@ weechat_python_add_message_handler (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (python_plugin->msg_handler_add (python_plugin, irc_command,
|
||||
weechat_python_handler, function,
|
||||
weechat_python_cmd_msg_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
@@ -443,7 +490,7 @@ weechat_python_add_command_handler (PyObject *self, PyObject *args)
|
||||
arguments,
|
||||
arguments_description,
|
||||
completion_template,
|
||||
weechat_python_handler,
|
||||
weechat_python_cmd_msg_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
@@ -484,13 +531,53 @@ weechat_python_add_timer_handler (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
if (python_plugin->timer_handler_add (python_plugin, interval,
|
||||
weechat_python_handler, function,
|
||||
weechat_python_timer_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_add_keyboard_handler (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &function))
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
if (python_plugin->keyboard_handler_add (python_plugin,
|
||||
weechat_python_keyboard_handler,
|
||||
function,
|
||||
(void *)python_current_script))
|
||||
return Py_BuildValue ("i", 1);
|
||||
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_remove_handler: remove a handler
|
||||
*/
|
||||
@@ -564,6 +651,42 @@ weechat_python_remove_timer_handler (PyObject *self, PyObject *args)
|
||||
return Py_BuildValue ("i", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_remove_keyboard_handler (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &function))
|
||||
{
|
||||
python_plugin->print_server (python_plugin,
|
||||
"Python error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
return Py_BuildValue ("i", 0);
|
||||
}
|
||||
|
||||
weechat_script_remove_keyboard_handler (python_plugin, python_current_script,
|
||||
function);
|
||||
|
||||
return Py_BuildValue ("i", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_get_info: get various infos
|
||||
*/
|
||||
@@ -1132,8 +1255,10 @@ PyMethodDef weechat_python_funcs[] = {
|
||||
{ "add_message_handler", weechat_python_add_message_handler, METH_VARARGS, "" },
|
||||
{ "add_command_handler", weechat_python_add_command_handler, METH_VARARGS, "" },
|
||||
{ "add_timer_handler", weechat_python_add_timer_handler, METH_VARARGS, "" },
|
||||
{ "add_keyboard_handler", weechat_python_add_keyboard_handler, METH_VARARGS, "" },
|
||||
{ "remove_handler", weechat_python_remove_handler, METH_VARARGS, "" },
|
||||
{ "remove_timer_handler", weechat_python_remove_timer_handler, METH_VARARGS, "" },
|
||||
{ "remove_keyboard_handler", weechat_python_remove_keyboard_handler, METH_VARARGS, "" },
|
||||
{ "get_info", weechat_python_get_info, METH_VARARGS, "" },
|
||||
{ "get_dcc_info", weechat_python_get_dcc_info, METH_VARARGS, "" },
|
||||
{ "get_config", weechat_python_get_config, METH_VARARGS, "" },
|
||||
@@ -1307,7 +1432,7 @@ weechat_python_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_python_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_python_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
PyThreadState_Swap (script->interpreter);
|
||||
Py_EndInterpreter (script->interpreter);
|
||||
@@ -1362,7 +1487,7 @@ weechat_python_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1371,13 +1496,14 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1459,6 +1585,24 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Python keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Python keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Python(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1502,7 +1646,7 @@ weechat_python_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -104,7 +104,7 @@ rb_protect_funcall(VALUE recv, ID mid, int *state, int argc, ...)
|
||||
int
|
||||
weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function, char *server, char *arguments)
|
||||
char *function, char *arg1, char *arg2, char *arg3)
|
||||
{
|
||||
VALUE ruby_retcode, err;
|
||||
int ruby_error;
|
||||
@@ -112,11 +112,32 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
(void) plugin;
|
||||
|
||||
ruby_current_script = script;
|
||||
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 2,
|
||||
rb_str_new2((server == NULL) ? "" : server),
|
||||
rb_str_new2((arguments == NULL) ? "" : arguments));
|
||||
|
||||
if (arg1)
|
||||
{
|
||||
if (arg2)
|
||||
{
|
||||
if (arg3)
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 3,
|
||||
rb_str_new2(arg1),
|
||||
rb_str_new2(arg2),
|
||||
rb_str_new2(arg3));
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 2,
|
||||
rb_str_new2(arg1),
|
||||
rb_str_new2(arg2));
|
||||
}
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 1,
|
||||
rb_str_new2(arg1));
|
||||
}
|
||||
else
|
||||
ruby_retcode = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
|
||||
&ruby_error, 0);
|
||||
|
||||
if (ruby_error)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
@@ -137,19 +158,52 @@ weechat_ruby_exec (t_weechat_plugin *plugin,
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_handler: general message and command handler for Ruby
|
||||
* weechat_ruby_cmd_msg_handler: general command/message handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_handler (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
char *handler_args, void *handler_pointer)
|
||||
weechat_ruby_cmd_msg_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 3)
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[2], NULL);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_timer_handler: general timer handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_timer_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) command;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, server, arguments);
|
||||
handler_args, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_keyboard_handler: general keyboard handler for Ruby
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_keyboard_handler (t_weechat_plugin *plugin,
|
||||
int argc, char **argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
if (argc >= 2)
|
||||
return weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
|
||||
handler_args, argv[0], argv[1], argv[2]);
|
||||
else
|
||||
return PLUGIN_RC_KO;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -482,7 +536,7 @@ weechat_ruby_command (int argc, VALUE *argv, VALUE class)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_message_handler: add handler for messages
|
||||
* weechat_ruby_add_message_handler: add a handler for messages (privmsg, ...)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
@@ -519,7 +573,8 @@ weechat_ruby_add_message_handler (VALUE class, VALUE message, VALUE function)
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->msg_handler_add (ruby_plugin, c_message,
|
||||
weechat_ruby_handler, c_function,
|
||||
weechat_ruby_cmd_msg_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
@@ -527,7 +582,7 @@ weechat_ruby_add_message_handler (VALUE class, VALUE message, VALUE function)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_command_handler: define/redefines commands
|
||||
* weechat_ruby_add_command_handler: add a command handler (define/redefine commands)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
@@ -608,7 +663,7 @@ weechat_ruby_add_command_handler (int argc, VALUE *argv, VALUE class)
|
||||
c_arguments,
|
||||
c_arguments_description,
|
||||
c_completion_template,
|
||||
weechat_ruby_handler,
|
||||
weechat_ruby_cmd_msg_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
@@ -655,13 +710,57 @@ weechat_ruby_add_timer_handler (VALUE class, VALUE interval, VALUE function)
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->timer_handler_add (ruby_plugin, c_interval,
|
||||
weechat_ruby_handler, c_function,
|
||||
weechat_ruby_timer_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_add_keyboard_handler: add a keyboard handler
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_add_keyboard_handler (VALUE class, VALUE function)
|
||||
{
|
||||
char *c_function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: unable to add keyboard handler, "
|
||||
"script not initialized");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (function))
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: wrong parameters for "
|
||||
"\"add_keyboard_handler\" function");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
if (ruby_plugin->keyboard_handler_add (ruby_plugin,
|
||||
weechat_ruby_keyboard_handler,
|
||||
c_function,
|
||||
(void *)ruby_current_script))
|
||||
return INT2FIX (1);
|
||||
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_remove_handler: remove a handler
|
||||
*/
|
||||
@@ -745,6 +844,46 @@ weechat_ruby_remove_timer_handler (VALUE class, VALUE function)
|
||||
return INT2FIX (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_remove_keyboard_handler: remove a keyboard handler
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_remove_keyboard_handler (VALUE class, VALUE function)
|
||||
{
|
||||
char *c_function;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: unable to remove keyboard handler, "
|
||||
"script not initialized");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (function))
|
||||
{
|
||||
ruby_plugin->print_server (ruby_plugin,
|
||||
"Ruby error: wrong parameters for "
|
||||
"\"remove_keyboard_handler\" function");
|
||||
return INT2FIX (0);
|
||||
}
|
||||
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
weechat_script_remove_keyboard_handler (ruby_plugin, ruby_current_script,
|
||||
c_function);
|
||||
|
||||
return INT2FIX (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_get_info: get various infos
|
||||
*/
|
||||
@@ -1485,7 +1624,7 @@ weechat_ruby_unload (t_weechat_plugin *plugin, t_plugin_script *script)
|
||||
script->name);
|
||||
|
||||
if (script->shutdown_func[0])
|
||||
weechat_ruby_exec (plugin, script, script->shutdown_func, "", "");
|
||||
weechat_ruby_exec (plugin, script, script->shutdown_func, "", "", "");
|
||||
|
||||
if (script->interpreter)
|
||||
rb_gc_unregister_address (script->interpreter);
|
||||
@@ -1541,7 +1680,7 @@ weechat_ruby_unload_all (t_weechat_plugin *plugin)
|
||||
|
||||
int
|
||||
weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
char *server, char *command, char *arguments,
|
||||
int cmd_argc, char **cmd_argv,
|
||||
char *handler_args, void *handler_pointer)
|
||||
{
|
||||
int argc, handler_found;
|
||||
@@ -1550,13 +1689,14 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
t_plugin_handler *ptr_handler;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) server;
|
||||
(void) command;
|
||||
(void) handler_args;
|
||||
(void) handler_pointer;
|
||||
|
||||
if (arguments)
|
||||
argv = plugin->explode_string (plugin, arguments, " ", 0, &argc);
|
||||
if (cmd_argc < 3)
|
||||
return PLUGIN_RC_KO;
|
||||
|
||||
if (cmd_argv[2])
|
||||
argv = plugin->explode_string (plugin, cmd_argv[2], " ", 0, &argc);
|
||||
else
|
||||
{
|
||||
argv = NULL;
|
||||
@@ -1638,6 +1778,24 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
|
||||
/* list Ruby keyboard handlers */
|
||||
plugin->print_server (plugin, "");
|
||||
plugin->print_server (plugin, "Ruby keyboard handlers:");
|
||||
handler_found = 0;
|
||||
for (ptr_handler = plugin->handlers;
|
||||
ptr_handler; ptr_handler = ptr_handler->next_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& (ptr_handler->handler_args))
|
||||
{
|
||||
handler_found = 1;
|
||||
plugin->print_server (plugin, " Ruby(%s)",
|
||||
ptr_handler->handler_args);
|
||||
}
|
||||
}
|
||||
if (!handler_found)
|
||||
plugin->print_server (plugin, " (none)");
|
||||
break;
|
||||
@@ -1681,7 +1839,7 @@ weechat_ruby_cmd (t_weechat_plugin *plugin,
|
||||
if (argv)
|
||||
plugin->free_exploded_string (plugin, argv);
|
||||
|
||||
return 1;
|
||||
return PLUGIN_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1758,8 +1916,10 @@ weechat_plugin_init (t_weechat_plugin *plugin)
|
||||
rb_define_module_function (mWeechat, "add_message_handler", weechat_ruby_add_message_handler, 2);
|
||||
rb_define_module_function (mWeechat, "add_command_handler", weechat_ruby_add_command_handler, -1);
|
||||
rb_define_module_function (mWeechat, "add_timer_handler", weechat_ruby_add_timer_handler, 2);
|
||||
rb_define_module_function (mWeechat, "add_keyboard_handler", weechat_ruby_add_keyboard_handler, 1);
|
||||
rb_define_module_function (mWeechat, "remove_handler", weechat_ruby_remove_handler, 2);
|
||||
rb_define_module_function (mWeechat, "remove_timer_handler", weechat_ruby_remove_timer_handler, 1);
|
||||
rb_define_module_function (mWeechat, "remove_keyboard_handler", weechat_ruby_remove_keyboard_handler, 1);
|
||||
rb_define_module_function (mWeechat, "get_info", weechat_ruby_get_info, -1);
|
||||
rb_define_module_function (mWeechat, "get_dcc_info", weechat_ruby_get_dcc_info, 0);
|
||||
rb_define_module_function (mWeechat, "get_config", weechat_ruby_get_config, 1);
|
||||
|
||||
@@ -317,7 +317,36 @@ weechat_script_remove_timer_handler (t_weechat_plugin *plugin,
|
||||
ptr_handler = plugin->handlers;
|
||||
while (ptr_handler)
|
||||
{
|
||||
if (((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
if ((ptr_handler->type == HANDLER_TIMER)
|
||||
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
|
||||
{
|
||||
next_handler = ptr_handler->next_handler;
|
||||
plugin->handler_remove (plugin, ptr_handler);
|
||||
ptr_handler = next_handler;
|
||||
}
|
||||
else
|
||||
ptr_handler = ptr_handler->next_handler;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_script_remove_keyboard_handler: remove a keyboard handler for a script
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
|
||||
t_plugin_script *script,
|
||||
char *function)
|
||||
{
|
||||
t_plugin_handler *ptr_handler, *next_handler;
|
||||
|
||||
/* search and remove keyboard handlers */
|
||||
ptr_handler = plugin->handlers;
|
||||
while (ptr_handler)
|
||||
{
|
||||
if ((ptr_handler->type == HANDLER_KEYBOARD)
|
||||
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
|
||||
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
|
||||
{
|
||||
next_handler = ptr_handler->next_handler;
|
||||
|
||||
@@ -56,6 +56,9 @@ extern void weechat_script_remove_handler (t_weechat_plugin *,
|
||||
extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
extern char *weechat_script_get_plugin_config (t_weechat_plugin *,
|
||||
t_plugin_script *,
|
||||
char *);
|
||||
|
||||
@@ -125,7 +125,7 @@ struct t_plugin_nick_info
|
||||
|
||||
typedef struct t_weechat_plugin t_weechat_plugin;
|
||||
|
||||
typedef int (t_plugin_handler_func) (t_weechat_plugin *, char *, char *, char *, char *, void *);
|
||||
typedef int (t_plugin_handler_func) (t_weechat_plugin *, int, char **, char *, void *);
|
||||
|
||||
/* handlers */
|
||||
|
||||
@@ -135,7 +135,8 @@ enum t_handler_type
|
||||
{
|
||||
HANDLER_MESSAGE = 0, /* IRC message handler */
|
||||
HANDLER_COMMAND, /* command handler */
|
||||
HANDLER_TIMER /* timer handler */
|
||||
HANDLER_TIMER, /* timer handler */
|
||||
HANDLER_KEYBOARD /* keyboard handler */
|
||||
};
|
||||
|
||||
typedef struct t_plugin_handler t_plugin_handler;
|
||||
@@ -219,6 +220,9 @@ struct t_weechat_plugin
|
||||
t_plugin_handler *(*timer_handler_add) (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
t_plugin_handler *(*keyboard_handler_add) (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
void (*handler_remove) (t_weechat_plugin *, t_plugin_handler *);
|
||||
void (*handler_remove_all) (t_weechat_plugin *);
|
||||
|
||||
@@ -239,6 +243,8 @@ struct t_weechat_plugin
|
||||
|
||||
void (*log) (t_weechat_plugin *, char *, char *, char *, ...);
|
||||
|
||||
void (*input_color) (t_weechat_plugin *, int, int, int);
|
||||
|
||||
/* WeeChat developers: ALWAYS add new functions at the end */
|
||||
};
|
||||
|
||||
@@ -272,6 +278,9 @@ extern t_plugin_handler *weechat_plugin_cmd_handler_add (t_weechat_plugin *, cha
|
||||
extern t_plugin_handler *weechat_plugin_timer_handler_add (t_weechat_plugin *, int,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern t_plugin_handler *weechat_plugin_keyboard_handler_add (t_weechat_plugin *,
|
||||
t_plugin_handler_func *,
|
||||
char *, void *);
|
||||
extern void weechat_plugin_handler_remove (t_weechat_plugin *, t_plugin_handler *);
|
||||
extern void weechat_plugin_handler_remove_all (t_weechat_plugin *);
|
||||
|
||||
@@ -290,5 +299,6 @@ extern t_plugin_channel_info *weechat_plugin_get_channel_info (t_weechat_plugin
|
||||
extern void weechat_plugin_free_channel_info (t_weechat_plugin *, t_plugin_channel_info *);
|
||||
extern t_plugin_nick_info *weechat_plugin_get_nick_info (t_weechat_plugin *, char *, char *);
|
||||
extern void weechat_plugin_free_nick_info (t_weechat_plugin *, t_plugin_nick_info *);
|
||||
extern void weechat_plugin_input_color (t_weechat_plugin *, int, int, int);
|
||||
|
||||
#endif /* weechat-plugin.h */
|
||||
|
||||
Reference in New Issue
Block a user