mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
buflist: add pointers to IRC server and channel
New pointers in evaluated formats: - irc_server: IRC server - irc_channel: IRC channel
This commit is contained in:
@@ -52,13 +52,18 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *ptr_buffer, *ptr_current_buffer;
|
||||
struct t_gui_nick *ptr_gui_nick;
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
struct t_hdata *hdata_irc_server, *hdata_irc_channel;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
char **buflist, *str_buflist, *condition;
|
||||
char str_condition[512];
|
||||
char str_format_number[32], str_format_number_empty[32];
|
||||
char str_nick_prefix[32], str_color_nick_prefix[32];
|
||||
char str_number[32], *line, **hotlist, *str_hotlist;
|
||||
char str_hotlist_count[32];
|
||||
const char *ptr_format, *ptr_format_current, *ptr_format_indent;
|
||||
const char *ptr_name, *ptr_type, *ptr_nick, *ptr_nick_prefix;
|
||||
const char *ptr_name, *ptr_type, *ptr_server_name, *ptr_channel_name;
|
||||
const char *ptr_nick, *ptr_nick_prefix;
|
||||
const char *ptr_hotlist_format, *ptr_hotlist_priority;
|
||||
const char *hotlist_priority_none = "none";
|
||||
const char *hotlist_priority[4] = { "low", "message", "private",
|
||||
@@ -79,6 +84,9 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
|
||||
|
||||
prev_number = -1;
|
||||
|
||||
hdata_irc_server = NULL;
|
||||
hdata_irc_channel = NULL;
|
||||
|
||||
buflist = weechat_string_dyn_alloc (256);
|
||||
|
||||
ptr_format = weechat_config_string (buflist_config_format_buffer);
|
||||
@@ -113,6 +121,58 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (buflist_hashtable_pointers,
|
||||
"buffer", ptr_buffer);
|
||||
|
||||
/* set IRC server/channel pointers */
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
if (strcmp (weechat_buffer_get_string (ptr_buffer, "plugin"), "irc") == 0)
|
||||
{
|
||||
ptr_server_name = weechat_buffer_get_string (ptr_buffer, "localvar_server");
|
||||
if (ptr_server_name && ptr_server_name[0])
|
||||
{
|
||||
if (!hdata_irc_server)
|
||||
hdata_irc_server = weechat_hdata_get ("irc_server");
|
||||
if (hdata_irc_server)
|
||||
{
|
||||
snprintf (str_condition, sizeof (str_condition),
|
||||
"${irc_server.name} == %s",
|
||||
ptr_server_name);
|
||||
ptr_server = weechat_hdata_get_list (hdata_irc_server,
|
||||
"irc_servers");
|
||||
ptr_server = weechat_hdata_search (hdata_irc_server,
|
||||
ptr_server,
|
||||
str_condition,
|
||||
1);
|
||||
if (ptr_server)
|
||||
{
|
||||
ptr_channel_name = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_channel");
|
||||
if (ptr_channel_name && ptr_channel_name[0])
|
||||
{
|
||||
if (!hdata_irc_channel)
|
||||
hdata_irc_channel = weechat_hdata_get ("irc_channel");
|
||||
if (hdata_irc_channel)
|
||||
{
|
||||
snprintf (str_condition, sizeof (str_condition),
|
||||
"${irc_channel.name} == %s",
|
||||
ptr_channel_name);
|
||||
ptr_channel = weechat_hdata_pointer (hdata_irc_server,
|
||||
ptr_server,
|
||||
"channels");
|
||||
ptr_channel = weechat_hdata_search (hdata_irc_channel,
|
||||
ptr_channel,
|
||||
str_condition,
|
||||
1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
weechat_hashtable_set (buflist_hashtable_pointers,
|
||||
"irc_server", ptr_server);
|
||||
weechat_hashtable_set (buflist_hashtable_pointers,
|
||||
"irc_channel", ptr_channel);
|
||||
|
||||
/* check condition: if false, the buffer is not displayed */
|
||||
condition = weechat_string_eval_expression (
|
||||
weechat_config_string (buflist_config_look_display_conditions),
|
||||
|
||||
@@ -88,6 +88,10 @@ buflist_command_init ()
|
||||
" - ${buffer.full_name}\n"
|
||||
" - ${buffer.short_name}\n"
|
||||
" - ${buffer.nicklist_nicks_count}\n"
|
||||
" - irc_server: IRC server data, defined only on an IRC buffer "
|
||||
"(see hdata \"irc_server\" in API doc)\n"
|
||||
" - irc_channel: IRC channel data, defined only on an IRC channel "
|
||||
"buffer (see hdata \"irc_channel\" in API doc)\n"
|
||||
" - extra variables added by buflist for convenience:\n"
|
||||
" - ${format_buffer}: the evaluated value of option "
|
||||
"buflist.format.buffer; this can be used in option "
|
||||
|
||||
Reference in New Issue
Block a user