diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 12:11:31 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 12:11:31 +0100 |
commit | 97ea89c44fc29f8256cf976ab07bc0a196ea645a (patch) | |
tree | 41bf05a4e1519d6555d6cc61316893dc969e8ed9 /src/gui | |
parent | 614b4dfc25e533cb73ca0d4bb5ef699a329e5076 (diff) | |
download | weechat-97ea89c44fc29f8256cf976ab07bc0a196ea645a.zip |
Allow search of nicklist group with name not including leading digits (for nicklist sort)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-nicklist.c | 42 | ||||
-rw-r--r-- | src/gui/gui-nicklist.h | 2 |
2 files changed, 34 insertions, 10 deletions
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index f1d95454c..0aa3c0410 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -144,15 +144,17 @@ gui_nicklist_insert_group_sorted (struct t_gui_nick_group **groups, } /* - * gui_nicklist_search_group: search a group in buffer nicklist + * gui_nicklist_search_group_internal: search a group in buffer nicklist */ struct t_gui_nick_group * -gui_nicklist_search_group (struct t_gui_buffer *buffer, - struct t_gui_nick_group *from_group, - const char *name) +gui_nicklist_search_group_internal (struct t_gui_buffer *buffer, + struct t_gui_nick_group *from_group, + const char *name, + int skip_digits) { struct t_gui_nick_group *ptr_group; + const char *ptr_name; if (!buffer) return NULL; @@ -165,7 +167,10 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer, if (from_group->childs) { - ptr_group = gui_nicklist_search_group (buffer, from_group->childs, name); + ptr_group = gui_nicklist_search_group_internal (buffer, + from_group->childs, + name, + skip_digits); if (ptr_group) return ptr_group; } @@ -173,7 +178,9 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer, ptr_group = from_group; while (ptr_group) { - if (strcmp (ptr_group->name, name) == 0) + ptr_name = (skip_digits) ? + gui_nicklist_get_group_start(ptr_group->name) : ptr_group->name; + if (strcmp (ptr_name, name) == 0) return ptr_group; ptr_group = ptr_group->next_group; } @@ -183,6 +190,23 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer, } /* + * gui_nicklist_search_group: search a group in buffer nicklist + */ + +struct t_gui_nick_group * +gui_nicklist_search_group (struct t_gui_buffer *buffer, + struct t_gui_nick_group *from_group, + const char *name) +{ + const char *ptr_name; + + ptr_name = gui_nicklist_get_group_start (name); + + return gui_nicklist_search_group_internal (buffer, from_group, name, + (ptr_name == name) ? 1 : 0); +} + +/* * gui_nicklist_add_group: add a group to nicklist for a buffer */ @@ -583,7 +607,7 @@ gui_nicklist_get_next_item (struct t_gui_buffer *buffer, * after '|', otherwise it's beginning of name */ -char * +const char * gui_nicklist_get_group_start (const char *name) { const char *ptr_name; @@ -596,9 +620,9 @@ gui_nicklist_get_group_start (const char *name) ptr_name++; } if ((ptr_name[0] == '|') && (ptr_name != name)) - return (char *)ptr_name + 1; + return ptr_name + 1; else - return (char *)name; + return name; } /* diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h index 6029800b6..0acc4791a 100644 --- a/src/gui/gui-nicklist.h +++ b/src/gui/gui-nicklist.h @@ -78,7 +78,7 @@ extern void gui_nicklist_remove_all (struct t_gui_buffer *buffer); extern void gui_nicklist_get_next_item (struct t_gui_buffer *buffer, struct t_gui_nick_group **group, struct t_gui_nick **nick); -extern char *gui_nicklist_get_group_start (const char *name); +extern const char *gui_nicklist_get_group_start (const char *name); extern void gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer, struct t_gui_nick_group *group); |