summaryrefslogtreecommitdiff
path: root/src/plugins/buflist
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/buflist')
-rw-r--r--src/plugins/buflist/buflist-bar-item.c90
-rw-r--r--src/plugins/buflist/buflist-command.c15
-rw-r--r--src/plugins/buflist/buflist-config.c65
-rw-r--r--src/plugins/buflist/buflist-config.h2
4 files changed, 129 insertions, 43 deletions
diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c
index 25b11a5d4..036b42f0b 100644
--- a/src/plugins/buflist/buflist-bar-item.c
+++ b/src/plugins/buflist/buflist-bar-item.c
@@ -52,17 +52,23 @@ 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];
- char str_number[32], str_indent_name[4], *line, **hotlist, *str_hotlist;
+ 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_name, *ptr_type;
+ const char *ptr_format, *ptr_format_current, *ptr_format_indent;
+ 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",
"highlight" };
+ const char indent_empty[1] = { '\0' };
const char *ptr_lag;
int is_channel, is_private;
int i, j, length_max_number, current_buffer, number, prev_number, priority;
@@ -78,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);
@@ -112,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),
@@ -163,15 +224,15 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
prev_number = number;
/* buffer name */
- str_indent_name[0] = '\0';
ptr_type = weechat_buffer_get_string (ptr_buffer, "localvar_type");
is_channel = (ptr_type && (strcmp (ptr_type, "channel") == 0));
is_private = (ptr_type && (strcmp (ptr_type, "private") == 0));
- if (is_channel || is_private)
- snprintf (str_indent_name, sizeof (str_indent_name), " ");
+ ptr_format_indent = (is_channel || is_private) ?
+ weechat_config_string (buflist_config_format_indent) : indent_empty;
/* nick prefix */
str_nick_prefix[0] = '\0';
+ str_color_nick_prefix[0] = '\0';
if (is_channel
&& weechat_config_boolean (buflist_config_look_nick_prefix))
{
@@ -190,12 +251,15 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
ptr_buffer, ptr_gui_nick, "prefix");
if (ptr_nick_prefix && (ptr_nick_prefix[0] != ' '))
{
- snprintf (str_nick_prefix, sizeof (str_nick_prefix),
- "%s%s",
+ snprintf (str_color_nick_prefix,
+ sizeof (str_color_nick_prefix),
+ "%s",
weechat_color (
weechat_nicklist_nick_get_string (
ptr_buffer, ptr_gui_nick,
- "prefix_color")),
+ "prefix_color")));
+ snprintf (str_nick_prefix, sizeof (str_nick_prefix),
+ "%s",
ptr_nick_prefix);
}
}
@@ -203,6 +267,12 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
}
weechat_hashtable_set (buflist_hashtable_extra_vars,
"nick_prefix", str_nick_prefix);
+ weechat_hashtable_set (buflist_hashtable_extra_vars,
+ "color_nick_prefix", str_color_nick_prefix);
+ weechat_hashtable_set (buflist_hashtable_extra_vars,
+ "format_nick_prefix",
+ weechat_config_string (
+ buflist_config_format_nick_prefix));
/* set extra variables */
weechat_hashtable_set (buflist_hashtable_extra_vars,
@@ -216,7 +286,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
weechat_config_string (
buflist_config_format_number));
weechat_hashtable_set (buflist_hashtable_extra_vars,
- "indent", str_indent_name);
+ "indent", ptr_format_indent);
weechat_hashtable_set (buflist_hashtable_extra_vars,
"name", ptr_name);
diff --git a/src/plugins/buflist/buflist-command.c b/src/plugins/buflist/buflist-command.c
index 2c61252c9..18bbb101c 100644
--- a/src/plugins/buflist/buflist-command.c
+++ b/src/plugins/buflist/buflist-command.c
@@ -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 "
@@ -98,9 +102,14 @@ buflist_command_init ()
" - ${number}: indented number, for example \" 1\" if there "
"are between 10 and 99 buffers\n"
" - ${indent}: indentation for name (channel and private "
- "buffers are indented)\n"
- " - ${nick_prefix}: nick prefix for a channel (set only "
- "if the option buflist.look.nick_prefix is enabled)\n"
+ "buffers are indented) (evaluation of "
+ "option buflist.format.indent)\n"
+ " - ${format_nick_prefix}: colored nick prefix for a channel "
+ "(evaluation of option buflist.format.nick_prefix)\n"
+ " - ${color_nick_prefix}: color of nick prefix for a channel "
+ "(set only if the option buflist.look.nick_prefix is enabled)\n"
+ " - ${nick_prefix}: nick prefix for a channel "
+ "(set only if the option buflist.look.nick_prefix is enabled)\n"
" - ${name}: the short name (if set), with a fallback on the "
"name\n"
" - ${color_hotlist}: the color depending on the highest "
diff --git a/src/plugins/buflist/buflist-config.c b/src/plugins/buflist/buflist-config.c
index d974b198a..9398b4d0e 100644
--- a/src/plugins/buflist/buflist-config.c
+++ b/src/plugins/buflist/buflist-config.c
@@ -49,7 +49,9 @@ struct t_config_option *buflist_config_format_hotlist;
struct t_config_option *buflist_config_format_hotlist_level[4];
struct t_config_option *buflist_config_format_hotlist_level_none;
struct t_config_option *buflist_config_format_hotlist_separator;
+struct t_config_option *buflist_config_format_indent;
struct t_config_option *buflist_config_format_lag;
+struct t_config_option *buflist_config_format_nick_prefix;
struct t_config_option *buflist_config_format_number;
struct t_hook **buflist_config_signals_refresh = NULL;
@@ -299,12 +301,13 @@ buflist_config_init ()
buflist_config_file, ptr_section,
"display_conditions", "string",
N_("conditions to display a buffer "
- "(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${buffer.hidden}==0",
- NULL, 0,
+ "(note: content is evaluated, see /help buflist); for example "
+ "to hide server buffers if they are merged with core buffer: "
+ "\"${buffer.hidden}==0 && ((${type}!=server && "
+ "${buffer.full_name}!=core.weechat) || ${buffer.active}==1)\""),
+ NULL, 0, 0, "${buffer.hidden}==0", NULL, 0,
NULL, NULL, NULL,
- &buflist_config_change_signals_refresh, NULL, NULL,
+ &buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
buflist_config_look_mouse_jump_visited_buffer = weechat_config_new_option (
buflist_config_file, ptr_section,
@@ -368,9 +371,7 @@ buflist_config_init ()
N_("comma-separated list of fields to sort buffers; each field is "
"a hdata variable of buffer; char \"-\" can be used before field "
"to reverse order"),
- NULL, 0, 0,
- "number,-active",
- NULL, 0,
+ NULL, 0, 0, "number,-active", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_sort, NULL, NULL,
NULL, NULL, NULL);
@@ -395,7 +396,7 @@ buflist_config_init ()
N_("format of each line with a buffer "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
- "${format_number}${indent}${nick_prefix}${color_hotlist}${name}",
+ "${format_number}${indent}${format_nick_prefix}${color_hotlist}${name}",
NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
@@ -405,9 +406,7 @@ buflist_config_init ()
"buffer_current", "string",
N_("format for the line with current buffer "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:lightgreen,blue}${format_buffer}",
- NULL, 0,
+ NULL, 0, 0, "${color:,blue}${format_buffer}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -427,9 +426,7 @@ buflist_config_init ()
"hotlist_low", "string",
N_("format for a buffer with hotlist level \"low\" "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:white}",
- NULL, 0,
+ NULL, 0, 0, "${color:white}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -438,9 +435,7 @@ buflist_config_init ()
"hotlist_message", "string",
N_("format for a buffer with hotlist level \"message\" "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:brown}",
- NULL, 0,
+ NULL, 0, 0, "${color:brown}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -449,9 +444,7 @@ buflist_config_init ()
"hotlist_private", "string",
N_("format for a buffer with hotlist level \"private\" "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:green}",
- NULL, 0,
+ NULL, 0, 0, "${color:green}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -460,9 +453,7 @@ buflist_config_init ()
"hotlist_highlight", "string",
N_("format for a buffer with hotlist level \"highlight\" "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:magenta}",
- NULL, 0,
+ NULL, 0, 0, "${color:magenta}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -471,9 +462,7 @@ buflist_config_init ()
"hotlist_none", "string",
N_("format for a buffer not in hotlist "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:default}",
- NULL, 0,
+ NULL, 0, 0, "${color:default}", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -482,9 +471,16 @@ buflist_config_init ()
"hotlist_separator", "string",
N_("separator for counts in hotlist "
"(note: content is evaluated, see /help buflist)"),
- NULL, 0, 0,
- "${color:default},",
- NULL, 0,
+ NULL, 0, 0, "${color:default},", NULL, 0,
+ NULL, NULL, NULL,
+ &buflist_config_change_buflist, NULL, NULL,
+ NULL, NULL, NULL);
+ buflist_config_format_indent = weechat_config_new_option (
+ buflist_config_file, ptr_section,
+ "indent", "string",
+ N_("string displayed to indent channel and private buffers "
+ "(note: content is evaluated, see /help buflist)"),
+ NULL, 0, 0, " ", NULL, 0,
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
@@ -499,6 +495,15 @@ buflist_config_init ()
NULL, NULL, NULL,
&buflist_config_change_buflist, NULL, NULL,
NULL, NULL, NULL);
+ buflist_config_format_nick_prefix = weechat_config_new_option (
+ buflist_config_file, ptr_section,
+ "nick_prefix", "string",
+ N_("format for nick prefix on a channel "
+ "(note: content is evaluated, see /help buflist)"),
+ NULL, 0, 0, "${color_nick_prefix}${nick_prefix}", NULL, 0,
+ NULL, NULL, NULL,
+ &buflist_config_change_buflist, NULL, NULL,
+ NULL, NULL, NULL);
buflist_config_format_number = weechat_config_new_option (
buflist_config_file, ptr_section,
"number", "string",
diff --git a/src/plugins/buflist/buflist-config.h b/src/plugins/buflist/buflist-config.h
index f78dcce29..f80524c32 100644
--- a/src/plugins/buflist/buflist-config.h
+++ b/src/plugins/buflist/buflist-config.h
@@ -47,7 +47,9 @@ extern struct t_config_option *buflist_config_format_hotlist;
extern struct t_config_option *buflist_config_format_hotlist_level[4];
extern struct t_config_option *buflist_config_format_hotlist_level_none;
extern struct t_config_option *buflist_config_format_hotlist_separator;
+extern struct t_config_option *buflist_config_format_indent;
extern struct t_config_option *buflist_config_format_lag;
+extern struct t_config_option *buflist_config_format_nick_prefix;
extern struct t_config_option *buflist_config_format_number;
extern char **buflist_config_sort_fields;