Skip to content

Commit

Permalink
Add config_look_hotlist_names_and_numbers option
Browse files Browse the repository at this point in the history
Allowing this to be disabled means that buffer numbers in the hotlist
can be turned off if the names are also shown, reducing clutter.
  • Loading branch information
alyssais committed Jun 21, 2018
1 parent 3319832 commit 55767f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/core/wee-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ struct t_config_option *config_look_hotlist_names_length;
struct t_config_option *config_look_hotlist_names_level;
struct t_config_option *config_look_hotlist_names_merged_buffers;
struct t_config_option *config_look_hotlist_prefix;
struct t_config_option *config_look_hotlist_names_and_numbers;
struct t_config_option *config_look_hotlist_remove;
struct t_config_option *config_look_hotlist_short_names;
struct t_config_option *config_look_hotlist_sort;
Expand Down Expand Up @@ -2906,6 +2907,15 @@ config_weechat_init_options ()
NULL, NULL, NULL,
&config_change_buffer_content, NULL, NULL,
NULL, NULL, NULL);
config_look_hotlist_names_and_numbers = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_names_and_numbers", "boolean",
N_("if set, buffer numbers are displayed in the hotlist even when "
"the name is also displayed"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL,
&config_change_buffer_content, NULL, NULL,
NULL, NULL, NULL);
config_look_hotlist_names_count = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_names_count", "integer",
Expand Down
1 change: 1 addition & 0 deletions src/core/wee-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ extern struct t_config_option *config_look_hotlist_add_conditions;
extern struct t_config_option *config_look_hotlist_buffer_separator;
extern struct t_config_option *config_look_hotlist_count_max;
extern struct t_config_option *config_look_hotlist_count_min_msg;
extern struct t_config_option *config_look_hotlist_names_and_numbers;
extern struct t_config_option *config_look_hotlist_names_count;
extern struct t_config_option *config_look_hotlist_names_length;
extern struct t_config_option *config_look_hotlist_names_level;
Expand Down
22 changes: 14 additions & 8 deletions src/gui/gui-bar-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
char str_hotlist[4096], *buffer_without_name_displayed, *buffer_name;
const char *hotlist_suffix, *ptr_buffer_name;
struct t_gui_hotlist *ptr_hotlist;
int numbers_count, names_count, display_name, count_max;
int entries_count, names_count, display_name, count_max;
int priority, priority_min, priority_min_displayed, private;

/* make C compiler happy */
Expand All @@ -1371,7 +1371,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
memset (buffer_without_name_displayed, 0, last_gui_buffer->number);
}

numbers_count = 0;
entries_count = 0;
names_count = 0;
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
Expand Down Expand Up @@ -1404,7 +1404,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
if (display_name || !buffer_without_name_displayed
|| (buffer_without_name_displayed[ptr_hotlist->buffer->number - 1] == 0))
{
if ((numbers_count > 0)
if ((entries_count > 0)
&& (CONFIG_STRING(config_look_hotlist_buffer_separator))
&& (CONFIG_STRING(config_look_hotlist_buffer_separator)[0]))
{
Expand Down Expand Up @@ -1438,16 +1438,22 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
*/
break;
}
snprintf (str_hotlist + strlen (str_hotlist), 16,
"%d", ptr_hotlist->buffer->number);
numbers_count++;
if (CONFIG_BOOLEAN(config_look_hotlist_names_and_numbers) || !display_name)
{
snprintf (str_hotlist + strlen (str_hotlist), 16,
"%d", ptr_hotlist->buffer->number);
}
entries_count++;

if (display_name)
{
names_count++;

strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_DELIM);
strcat (str_hotlist, ":");
if (CONFIG_BOOLEAN(config_look_hotlist_names_and_numbers))
{
strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_DELIM);
strcat (str_hotlist, ":");
}
strcat (str_hotlist, GUI_COLOR_CUSTOM_BAR_FG);
ptr_buffer_name = (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ?
gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name;
Expand Down

0 comments on commit 55767f5

Please sign in to comment.