diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-12 18:22:11 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-10-12 18:22:11 +0200 |
commit | 0e68117b37f2ac79c8cf0777f367b367609825ac (patch) | |
tree | 4b279e39d951691cd2599ae688e252203d72ff31 /src/gui | |
parent | 6e695ebe65f1dd6304b0a2b8b25c5b285d60a251 (diff) | |
download | weechat-0e68117b37f2ac79c8cf0777f367b367609825ac.zip |
Add new option weechat.look.hotlist_unique_numbers (task #10691)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-bar-item.c | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index e861d520d..1d1f00c1f 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -979,9 +979,9 @@ char * gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, struct t_gui_window *window) { - char buf[1024], format[32]; + char buf[1024], format[32], *buffer_without_name_displayed; struct t_gui_hotlist *ptr_hotlist; - int names_count, display_name; + int numbers_count, names_count, display_name; /* make C compiler happy */ (void) data; @@ -995,6 +995,15 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, strcat (buf, _("Act: ")); + buffer_without_name_displayed = NULL; + if (CONFIG_BOOLEAN(config_look_hotlist_unique_numbers) && last_gui_buffer) + { + buffer_without_name_displayed = malloc (last_gui_buffer->number); + if (buffer_without_name_displayed) + memset (buffer_without_name_displayed, 0, last_gui_buffer->number); + } + + numbers_count = 0; names_count = 0; for (ptr_hotlist = gui_hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) @@ -1022,37 +1031,52 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, break; } - sprintf (buf + strlen (buf), "%d", ptr_hotlist->buffer->number); + display_name = ((CONFIG_BOOLEAN(config_look_hotlist_names_merged_buffers) + && (gui_buffer_count_merged_buffers (ptr_hotlist->buffer->number) > 1)) + || (display_name + && (CONFIG_INTEGER(config_look_hotlist_names_count) != 0) + && (names_count < CONFIG_INTEGER(config_look_hotlist_names_count)))); - if ((CONFIG_BOOLEAN(config_look_hotlist_names_merged_buffers) - && (gui_buffer_count_merged_buffers (ptr_hotlist->buffer->number) > 1)) - || (display_name - && (CONFIG_INTEGER(config_look_hotlist_names_count) != 0) - && (names_count < CONFIG_INTEGER(config_look_hotlist_names_count)))) + if (display_name || !buffer_without_name_displayed + || (buffer_without_name_displayed[ptr_hotlist->buffer->number - 1] == 0)) { - names_count++; + if (numbers_count > 0) + strcat (buf, ","); - strcat (buf, GUI_COLOR_CUSTOM_BAR_DELIM); - strcat (buf, ":"); - strcat (buf, GUI_COLOR_CUSTOM_BAR_FG); - if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0) - snprintf (format, sizeof (format) - 1, "%%s"); + numbers_count++; + sprintf (buf + strlen (buf), "%d", ptr_hotlist->buffer->number); + + if (display_name) + { + names_count++; + + strcat (buf, GUI_COLOR_CUSTOM_BAR_DELIM); + strcat (buf, ":"); + strcat (buf, GUI_COLOR_CUSTOM_BAR_FG); + if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0) + snprintf (format, sizeof (format) - 1, "%%s"); + else + snprintf (format, sizeof (format) - 1, + "%%.%ds", + CONFIG_INTEGER(config_look_hotlist_names_length)); + sprintf (buf + strlen (buf), format, + (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ? + ptr_hotlist->buffer->short_name : ptr_hotlist->buffer->name); + } else - snprintf (format, sizeof (format) - 1, - "%%.%ds", - CONFIG_INTEGER(config_look_hotlist_names_length)); - sprintf (buf + strlen (buf), format, - (CONFIG_BOOLEAN(config_look_hotlist_short_names)) ? - ptr_hotlist->buffer->short_name : ptr_hotlist->buffer->name); + { + if (buffer_without_name_displayed) + buffer_without_name_displayed[ptr_hotlist->buffer->number - 1] = 1; + } + + if (strlen (buf) > sizeof (buf) - 32) + break; } - - if (ptr_hotlist->next_hotlist) - strcat (buf, ","); - - if (strlen (buf) > sizeof (buf) - 32) - break; } + if (buffer_without_name_displayed) + free (buffer_without_name_displayed); + return strdup (buf); } |