mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 10:43:13 +02:00
Improved main loop (less CPU usage), better precision for timers, use of one list by hook type (for fast search in hooks)
This commit is contained in:
@@ -81,6 +81,26 @@ demo_printf_command_cb (void *data, void *buffer, int argc, char **argv,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* demo_infobar_command_cb: demo command for infobar
|
||||
*/
|
||||
|
||||
int
|
||||
demo_infobar_command_cb (void *data, void *buffer, int argc, char **argv,
|
||||
char **argv_eol)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv;
|
||||
|
||||
weechat_infobar_printf (10, NULL,
|
||||
(argc > 1) ?
|
||||
argv_eol[1] : _("test infobar"));
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* demo_buffer_input_data_cb: callback for input data on buffer
|
||||
*/
|
||||
@@ -286,6 +306,14 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
|
||||
"",
|
||||
&demo_printf_command_cb, NULL);
|
||||
|
||||
weechat_hook_command ("demo_infobar",
|
||||
_("demo command: print a message in infobar for 10 "
|
||||
"seconds"),
|
||||
_("[text]"),
|
||||
_("text: write this text on infobar"),
|
||||
"",
|
||||
&demo_infobar_command_cb, NULL);
|
||||
|
||||
weechat_hook_command ("demo_buffer",
|
||||
_("open a new buffer"),
|
||||
_("category name"),
|
||||
|
||||
@@ -1255,9 +1255,15 @@ plugin_api_infobar_printf (struct t_weechat_plugin *plugin, int time_displayed,
|
||||
va_end (argptr);
|
||||
|
||||
buf2 = string_iconv_to_internal (plugin->charset, buf);
|
||||
num_color = gui_color_search_config (color_name);
|
||||
if (num_color < 0)
|
||||
if (color_name && color_name[0])
|
||||
{
|
||||
num_color = gui_color_search_config (color_name);
|
||||
if (num_color < 0)
|
||||
num_color = GUI_COLOR_INFOBAR;
|
||||
}
|
||||
else
|
||||
num_color = GUI_COLOR_INFOBAR;
|
||||
|
||||
gui_infobar_printf (time_displayed,
|
||||
num_color,
|
||||
"%s",
|
||||
@@ -1314,10 +1320,12 @@ plugin_api_hook_command (struct t_weechat_plugin *plugin, char *command,
|
||||
|
||||
struct t_hook *
|
||||
plugin_api_hook_timer (struct t_weechat_plugin *plugin, long interval,
|
||||
int max_calls, int (*callback)(void *), void *data)
|
||||
int align_second, int max_calls,
|
||||
int (*callback)(void *), void *data)
|
||||
{
|
||||
if (plugin && (interval > 0) && callback)
|
||||
return hook_timer (plugin, interval, max_calls, callback, data);
|
||||
return hook_timer (plugin, interval, align_second, max_calls,
|
||||
callback, data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ extern struct t_hook *plugin_api_hook_command (struct t_weechat_plugin *,
|
||||
int (*)(void *, void *, int, char **, char **),
|
||||
void *);
|
||||
extern struct t_hook *plugin_api_hook_timer (struct t_weechat_plugin *,
|
||||
long, int,
|
||||
long, int, int,
|
||||
int (*)(void *), void *);
|
||||
extern struct t_hook *plugin_api_hook_fd (struct t_weechat_plugin *,
|
||||
int, int, int, int,
|
||||
|
||||
@@ -160,7 +160,7 @@ struct t_weechat_plugin
|
||||
char *, char *, char *,
|
||||
int (*)(void *, void *, int, char **, char **),
|
||||
void *);
|
||||
struct t_hook *(*hook_timer) (struct t_weechat_plugin *, long, int,
|
||||
struct t_hook *(*hook_timer) (struct t_weechat_plugin *, long, int, int,
|
||||
int (*)(void *), void *);
|
||||
struct t_hook *(*hook_fd) (struct t_weechat_plugin *, int, int, int, int,
|
||||
int (*)(void *), void *);
|
||||
@@ -407,8 +407,10 @@ struct t_weechat_plugin
|
||||
weechat_plugin->hook_command(weechat_plugin, __command, __description, \
|
||||
__args, __args_desc, __completion, \
|
||||
__callback, __data)
|
||||
#define weechat_hook_timer(__interval, __max_calls, __callback, __data) \
|
||||
weechat_plugin->hook_timer(weechat_plugin, __interval, __max_calls, \
|
||||
#define weechat_hook_timer(__interval, __align_second, __max_calls, \
|
||||
__callback, __data) \
|
||||
weechat_plugin->hook_timer(weechat_plugin, __interval, \
|
||||
__align_second, __max_calls, \
|
||||
__callback, __data)
|
||||
#define weechat_hook_fd(__fd, __flag_read, __flag_write, \
|
||||
__flag_exception, __callback, __data) \
|
||||
|
||||
Reference in New Issue
Block a user