int completion_list_add_nicks_cb (void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_gui_nick_group *ptr_group; struct t_gui_nick *ptr_nick; int count_before; /* make C compiler happy */ (void) data; (void) completion_item; (void) buffer; count_before = weelist_size (completion->completion_list); hook_completion_exec (completion->buffer->plugin, "nick", completion->buffer, completion); if (weelist_size (completion->completion_list) == count_before) { /* * no plugin overrides nick completion => use default nick * completion, with nicks of nicklist, in order of nicklist */ ptr_group = NULL; ptr_nick = NULL; gui_nicklist_get_next_item (completion->buffer, &ptr_group, &ptr_nick); while (ptr_group || ptr_nick) { if (ptr_nick && ptr_nick->visible) { gui_completion_list_add (completion, ptr_nick->name, 1, WEECHAT_LIST_POS_END); } gui_nicklist_get_next_item (completion->buffer, &ptr_group, &ptr_nick); } } return WEECHAT_RC_OK; }
int gui_color_assign_by_diff (int *color, const char *color_name, int diff) { int index, list_size; struct t_weelist_item *ptr_item; const char *name; index = weelist_search_pos (gui_color_list_with_alias, color_name); if (index < 0) index = 0; list_size = weelist_size (gui_color_list_with_alias); diff = diff % (list_size + 1); if (diff > 0) { index = (index + diff) % (list_size + 1); while (index > list_size - 1) { index -= list_size; } } else { index = (index + list_size + diff) % list_size; while (index < 0) { index += list_size; } } ptr_item = weelist_get (gui_color_list_with_alias, index); if (!ptr_item) return 0; name = weelist_string (ptr_item); if (name) return gui_color_assign (color, name); return 0; }