1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

api: allow search by group and nick id in functions nicklist_search_group and nicklist_search_nick (issue #2081)

This commit is contained in:
Sébastien Helleu
2024-04-29 19:22:57 +02:00
parent 6c706caa50
commit ded599b272
9 changed files with 307 additions and 83 deletions
+1
View File
@@ -30,6 +30,7 @@ New features::
* core: add option `-s` in command `/command` to execute multiple commands separated by semicolons
* core: allow case insensitive search of partial buffer name with `(?i)name` in command `/buffer`
* core: use function util_strftimeval in evaluation of expression `date:xxx`
* api: allow search by group and nick id in functions nicklist_search_group and nicklist_search_nick (issue #2081)
* api: allow search by buffer id in function buffer_search (issue #2081)
* api: add modifier "color_decode" to decode WeeChat colors with a replacement string
* api: use whole replacement string instead of first char in function string_remove_color
+24 -12
View File
@@ -15501,7 +15501,9 @@ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
==== nicklist_search_group
Search a group in a nicklist.
_Updated in 4.3.0._
Search a group in a nicklist by name or unique identifier (`id`).
Prototype:
@@ -15517,7 +15519,8 @@ Arguments:
* _buffer_: buffer pointer
* _from_group_: search from this group only, if NULL, then search in whole
nicklist
* _name_: group name to search
* _name_: group name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Return value:
@@ -15527,8 +15530,10 @@ C example:
[source,c]
----
struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group1 = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group2 = weechat_nicklist_search_group (my_buffer,
NULL, "==id:1714382231198764");
----
Script (Python):
@@ -15538,8 +15543,9 @@ Script (Python):
# prototype
def nicklist_search_group(buffer: str, from_group: str, name: str) -> str: ...
# example
group = weechat.nicklist_search_group(my_buffer, "", "test_group")
# examples
group1 = weechat.nicklist_search_group(my_buffer, "", "test_group")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
----
==== nicklist_add_nick
@@ -15616,7 +15622,9 @@ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "
==== nicklist_search_nick
Search a nick in a nicklist.
_Updated in 4.3.0._
Search a nick in a nicklist by name or unique identifier (`id`).
Prototype:
@@ -15632,7 +15640,8 @@ Arguments:
* _buffer_: buffer pointer
* _from_group_: search from this group only, if NULL, then search in whole
nicklist
* _name_: nick name to search
* _name_: nick name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Return value:
@@ -15642,8 +15651,10 @@ C example:
[source,c]
----
struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick1 = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick2 = weechat_nicklist_search_nick (my_buffer,
NULL, "==id:1714382252187496");
----
Script (Python):
@@ -15653,8 +15664,9 @@ Script (Python):
# prototype
def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str: ...
# example
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
# examples
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
----
==== nicklist_remove_group
+24 -12
View File
@@ -15842,7 +15842,9 @@ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "groupe_test",
==== nicklist_search_group
Rechercher un groupe dans la liste des pseudos.
_Mis à jour dans la 4.3.0._
Rechercher un groupe dans la liste des pseudos par nom ou identifiant unique (`id`).
Prototype :
@@ -15858,7 +15860,8 @@ Paramètres :
* _buffer_ : pointeur vers le tampon
* _from_group_ : recherche depuis ce groupe seulement, si NULL, alors recherche
dans toute la liste des pseudos
* _name_ : nom du groupes à rechercher
* _name_ : nom du groupe à rechercher ; avec WeeChat ≥ 4.3.0, un identifiant
unique peut être donné avec le format : `==id:xxx` (où `xxx` est l'identifiant)
Valeur de retour :
@@ -15868,8 +15871,10 @@ Exemple en C :
[source,c]
----
struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
NULL, "groupe_test");
struct t_gui_nick_group *ptr_group1 = weechat_nicklist_search_group (my_buffer,
NULL, "groupe_test");
struct t_gui_nick_group *ptr_group2 = weechat_nicklist_search_group (my_buffer,
NULL, "==id:1714382231198764");
----
Script (Python) :
@@ -15879,8 +15884,9 @@ Script (Python) :
# prototype
def nicklist_search_group(buffer: str, from_group: str, name: str) -> str: ...
# exemple
group = weechat.nicklist_search_group(my_buffer, "", "groupe_test")
# exemples
group1 = weechat.nicklist_search_group(my_buffer, "", "groupe_test")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
----
==== nicklist_add_nick
@@ -15957,7 +15963,9 @@ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "
==== nicklist_search_nick
Rechercher un pseudo dans la liste des pseudos.
_Mis à jour dans la 4.3.0._
Rechercher un pseudo dans la liste des pseudos par nom ou identifiant unique (`id`).
Prototype :
@@ -15973,7 +15981,8 @@ Paramètres :
* _buffer_ : pointeur vers le tampon
* _from_group_ : recherche depuis ce groupe seulement, si NULL, alors recherche
dans toute la liste des pseudos
* _name_ : nom du pseudo à rechercher
* _name_ : nom du pseudo à rechercher ; avec WeeChat ≥ 4.3.0, un identifiant
unique peut être donné avec le format : `==id:xxx` (où `xxx` est l'identifiant)
Valeur de retour :
@@ -15983,8 +15992,10 @@ Exemple en C :
[source,c]
----
struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick1 = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick2 = weechat_nicklist_search_nick (my_buffer,
NULL, "==id:1714382252187496");
----
Script (Python) :
@@ -15994,8 +16005,9 @@ Script (Python) :
# prototype
def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str: ...
# exemple
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
# exemples
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
----
==== nicklist_remove_group
+28 -10
View File
@@ -16250,7 +16250,11 @@ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
==== nicklist_search_group
Cerca un gruppo in una lista nick.
// TRANSLATION MISSING
_Updated in 4.3.0._
// TRANSLATION MISSING
Search a group in a nicklist by name or unique identifier (`id`).
Prototipo:
@@ -16266,7 +16270,9 @@ Argomenti:
* _buffer_: puntatore al buffer
* _from_group_: ricerca solo da questo gruppo, se NULL, allora la cerca in
tutta la lista nick
* _name_: nome gruppo da cercare
// TRANSLATION MISSING
* _name_: group name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Valore restituito:
@@ -16276,8 +16282,10 @@ Esempio in C:
[source,c]
----
struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group1 = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group2 = weechat_nicklist_search_group (my_buffer,
NULL, "==id:1714382231198764");
----
Script (Python):
@@ -16288,7 +16296,8 @@ Script (Python):
def nicklist_search_group(buffer: str, from_group: str, name: str) -> str: ...
# esempio
group = weechat.nicklist_search_group(my_buffer, "", "test_group")
group1 = weechat.nicklist_search_group(my_buffer, "", "test_group")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
----
==== nicklist_add_nick
@@ -16365,7 +16374,11 @@ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "
==== nicklist_search_nick
Cerca un nick nella lista nick.
// TRANSLATION MISSING
_Updated in 4.3.0._
// TRANSLATION MISSING
Search a nick in a nicklist by name or unique identifier (`id`).
Prototipo:
@@ -16381,7 +16394,9 @@ Argomenti:
* _buffer_: puntatore al buffer
* _from_group_: cerca solo da questo gruppo, se NULL, allora cerca
nell'intera lista nick
* _name_: nick da cercare
// TRANSLATION MISSING
* _name_: nick name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Valore restituito:
@@ -16391,8 +16406,10 @@ Esempio in C:
[source,c]
----
struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick1 = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick2 = weechat_nicklist_search_nick (my_buffer,
NULL, "==id:1714382252187496");
----
Script (Python):
@@ -16403,7 +16420,8 @@ Script (Python):
def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str: ...
# esempio
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
----
==== nicklist_remove_group
+26 -10
View File
@@ -15744,7 +15744,10 @@ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
==== nicklist_search_group
ニックネームリストからグループを検索。
_WeeChat バージョン 4.3.0 で更新。_
// TRANSLATION MISSING
Search a group in a nicklist by name or unique identifier (`id`).
プロトタイプ:
@@ -15760,7 +15763,9 @@ struct t_gui_nick_group *weechat_nicklist_search_group (struct t_gui_buffer *buf
* _buffer_: バッファへのポインタ
* _from_group_:
このグループのみを検索、全てのニックネームリストから検索する場合は NULL
* _name_: 検索するグループ名
// TRANSLATION MISSING
* _name_: group name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
戻り値:
@@ -15770,8 +15775,10 @@ C 言語での使用例:
[source,c]
----
struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group1 = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group2 = weechat_nicklist_search_group (my_buffer,
NULL, "==id:1714382231198764");
----
スクリプト (Python) での使用例:
@@ -15782,7 +15789,8 @@ struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
def nicklist_search_group(buffer: str, from_group: str, name: str) -> str: ...
# 例
group = weechat.nicklist_search_group(my_buffer, "", "test_group")
group1 = weechat.nicklist_search_group(my_buffer, "", "test_group")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
----
==== nicklist_add_nick
@@ -15859,7 +15867,10 @@ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "
==== nicklist_search_nick
ニックネームリストからニックネームを検索。
_WeeChat バージョン 4.3.0 で更新。_
// TRANSLATION MISSING
Search a nick in a nicklist by name or unique identifier (`id`).
プロトタイプ:
@@ -15875,7 +15886,9 @@ struct t_gui_nick *weechat_nicklist_search_nick (struct t_gui_buffer *buffer,
* _buffer_: バッファへのポインタ
* _from_group_:
このグループのみを検索、全てのニックネームリストから検索する場合は NULL
* _name_: 検索するニックネーム
// TRANSLATION MISSING
* _name_: nick name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
戻り値:
@@ -15885,8 +15898,10 @@ C 言語での使用例:
[source,c]
----
struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick1 = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick2 = weechat_nicklist_search_nick (my_buffer,
NULL, "==id:1714382252187496");
----
スクリプト (Python) での使用例:
@@ -15897,7 +15912,8 @@ struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str: ...
# 例
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
----
==== nicklist_remove_group
+26 -10
View File
@@ -15085,7 +15085,10 @@ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
==== nicklist_search_group
Тражи групу у листи надимака.
_Ажурирано у верзији 4.3.0._
// TRANSLATION MISSING
Search a group in a nicklist by name or unique identifier (`id`).
Прототип:
@@ -15100,7 +15103,9 @@ struct t_gui_nick_group *weechat_nicklist_search_group (struct t_gui_buffer *buf
* _buffer_: показивач на бафер
* _from_group_: тражи само од ове групе, ако је NULL, онда се претражује цела листа надимака
* _name_: име групе која се тражи
// TRANSLATION MISSING
* _name_: group name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Повратна вредност:
@@ -15110,8 +15115,10 @@ C пример:
[source,c]
----
struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group1 = weechat_nicklist_search_group (my_buffer,
NULL, "test_group");
struct t_gui_nick_group *ptr_group2 = weechat_nicklist_search_group (my_buffer,
NULL, "==id:1714382231198764");
----
Скрипта (Python):
@@ -15122,7 +15129,8 @@ struct t_gui_nick_group *ptr_group = weechat_nicklist_search_group (my_buffer,
def nicklist_search_group(buffer: str, from_group: str, name: str) -> str: ...
# пример
group = weechat.nicklist_search_group(my_buffer, "", "test_group")
group1 = weechat.nicklist_search_group(my_buffer, "", "test_group")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
----
==== nicklist_add_nick
@@ -15199,7 +15207,10 @@ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "
==== nicklist_search_nick
Тражи надимак у листи надимака.
_Ажурирано у верзији 4.3.0._
// TRANSLATION MISSING
Search a nick in a nicklist by name or unique identifier (`id`).
Прототип:
@@ -15214,7 +15225,9 @@ struct t_gui_nick *weechat_nicklist_search_nick (struct t_gui_buffer *buffer,
* _buffer_: показивач на бафер
* _from_group_: тражи само од ове групе, ако је NULL, онда се претражује цела листа надимака
* _name_: име надимка који се тражи
// TRANSLATION MISSING
* _name_: nick name to search; with WeeChat ≥ 4.3.0, a unique identifier can
be given with the format: `==id:xxx` (where `xxx` is the identifier)
Повратна вредност:
@@ -15224,8 +15237,10 @@ C пример:
[source,c]
----
struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick1 = weechat_nicklist_search_nick (my_buffer,
NULL, "test_nick");
struct t_gui_nick *ptr_nick2 = weechat_nicklist_search_nick (my_buffer,
NULL, "==id:1714382252187496");
----
Скрипта (Python):
@@ -15236,7 +15251,8 @@ struct t_gui_nick *ptr_nick = weechat_nicklist_search_nick (my_buffer,
def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str: ...
# пример
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
----
==== nicklist_remove_group
+130 -24
View File
@@ -182,23 +182,59 @@ gui_nicklist_insert_group_sorted (struct t_gui_nick_group **groups,
}
/*
* Searches for a group in nicklist (this function must not be called directly).
* Searches for a group in nicklist by id (this function must not be called
* directly).
*
* Returns pointer to group found, NULL if not found.
*/
struct t_gui_nick_group *
gui_nicklist_search_group_internal (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
const char *name,
int skip_digits)
gui_nicklist_search_group_id (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
long long id)
{
struct t_gui_nick_group *ptr_group, *ptr_group_found;
if (!from_group)
from_group = buffer->nicklist_root;
if (!from_group)
return NULL;
if (from_group->id == id)
return from_group;
if (from_group->children)
{
for (ptr_group = from_group->children; ptr_group;
ptr_group = ptr_group->next_group)
{
ptr_group_found = gui_nicklist_search_group_id (buffer, ptr_group, id);
if (ptr_group_found)
return ptr_group_found;
}
}
/* group not found */
return NULL;
}
/*
* Searches for a group in nicklist by name (this function must not be called
* directly).
*
* Returns pointer to group found, NULL if not found.
*/
struct t_gui_nick_group *
gui_nicklist_search_group_name (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, *ptr_group_found;
const char *ptr_name;
if (!buffer || !name)
return NULL;
if (!from_group)
from_group = buffer->nicklist_root;
@@ -215,7 +251,7 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer,
for (ptr_group = from_group->children; ptr_group;
ptr_group = ptr_group->next_group)
{
ptr_group_found = gui_nicklist_search_group_internal (
ptr_group_found = gui_nicklist_search_group_name (
buffer,
ptr_group,
name,
@@ -241,14 +277,26 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
const char *name)
{
const char *ptr_name;
char *error;
long long id;
if (!buffer || !name)
if ((!buffer && !from_group)
|| !name
|| (!from_group && !buffer->nicklist_root))
{
return NULL;
}
if (strncmp (name, "==id:", 5) == 0)
{
id = strtoll (name + 5, &error, 10);
if (error && !error[0])
return gui_nicklist_search_group_id (buffer, from_group, id);
}
ptr_name = gui_nicklist_get_group_start (name);
return gui_nicklist_search_group_internal (buffer, from_group, name,
(ptr_name == name) ? 1 : 0);
return gui_nicklist_search_group_name (buffer, from_group, name,
(ptr_name == name) ? 1 : 0);
}
/*
@@ -431,27 +479,54 @@ gui_nicklist_insert_nick_sorted (struct t_gui_nick_group *group,
}
/*
* Searches for a nick in nicklist.
* Searches for a nick in nicklist by id (this function must not be called
* directly).
*
* Returns pointer to nick found, NULL if not found.
*/
struct t_gui_nick *
gui_nicklist_search_nick (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
const char *name)
gui_nicklist_search_nick_id (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
long long id)
{
struct t_gui_nick *ptr_nick;
struct t_gui_nick_group *ptr_group;
if (!buffer && !from_group)
return NULL;
for (ptr_nick = (from_group) ? from_group->nicks : buffer->nicklist_root->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (ptr_nick->id == id)
return ptr_nick;
}
if (!name)
return NULL;
/* search nick in child groups */
for (ptr_group = (from_group) ? from_group->children : buffer->nicklist_root->children;
ptr_group; ptr_group = ptr_group->next_group)
{
ptr_nick = gui_nicklist_search_nick_id (buffer, ptr_group, id);
if (ptr_nick)
return ptr_nick;
}
if (!from_group && !buffer->nicklist_root)
return NULL;
/* nick not found */
return NULL;
}
/*
* Searches for a nick in nicklist by name (this function must not be called
* directly).
*
* Returns pointer to nick found, NULL if not found.
*/
struct t_gui_nick *
gui_nicklist_search_nick_name (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
const char *name)
{
struct t_gui_nick *ptr_nick;
struct t_gui_nick_group *ptr_group;
for (ptr_nick = (from_group) ? from_group->nicks : buffer->nicklist_root->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
@@ -476,7 +551,7 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
for (ptr_group = (from_group) ? from_group->children : buffer->nicklist_root->children;
ptr_group; ptr_group = ptr_group->next_group)
{
ptr_nick = gui_nicklist_search_nick (buffer, ptr_group, name);
ptr_nick = gui_nicklist_search_nick_name (buffer, ptr_group, name);
if (ptr_nick)
return ptr_nick;
}
@@ -485,6 +560,37 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
return NULL;
}
/*
* Searches for a nick in nicklist.
*
* Returns pointer to nick found, NULL if not found.
*/
struct t_gui_nick *
gui_nicklist_search_nick (struct t_gui_buffer *buffer,
struct t_gui_nick_group *from_group,
const char *name)
{
long long id;
char *error;
if ((!buffer && !from_group)
|| !name
|| (!from_group && !buffer->nicklist_root))
{
return NULL;
}
if (strncmp (name, "==id:", 5) == 0)
{
id = strtoll (name + 5, &error, 10);
if (error && !error[0])
return gui_nicklist_search_nick_id (buffer, from_group, id);
}
return gui_nicklist_search_nick_name (buffer, from_group, name);
}
/*
* Adds a nick to nicklist with identifier (internal use).
*
+6 -4
View File
@@ -2001,8 +2001,9 @@ def nicklist_search_group(buffer: str, from_group: str, name: str) -> str:
"""`nicklist_search_group in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_nicklist_search_group>`_
::
# example
group = weechat.nicklist_search_group(my_buffer, "", "test_group")
# examples
group1 = weechat.nicklist_search_group(my_buffer, "", "test_group")
group2 = weechat.nicklist_search_group(my_buffer, "", "==id:1714382231198764")
"""
...
@@ -2025,8 +2026,9 @@ def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str:
"""`nicklist_search_nick in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_nicklist_search_nick>`_
::
# example
nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
# examples
nick1 = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
nick2 = weechat.nicklist_search_nick(my_buffer, "", "==id:1714382252187496")
"""
...
+42 -1
View File
@@ -87,7 +87,8 @@ TEST(GuiNicklist, GenerateId)
* gui_nicklist_insert_group_sorted
* gui_nicklist_add_group_with_id
* gui_nicklist_add_group
* gui_nicklist_search_group_internal
* gui_nicklist_search_group_id
* gui_nicklist_search_group_name
* gui_nicklist_search_group
* gui_nicklist_remove_group
* gui_nicklist_remove_all
@@ -97,6 +98,7 @@ TEST(GuiNicklist, AddGroup)
{
struct t_gui_buffer *buffer;
struct t_gui_nick_group *group1, *group2, *subgroup1, *subgroup2, *subgroup3;
char str_search_id[128];
buffer = gui_buffer_new (NULL, TEST_BUFFER_NAME,
NULL, NULL, NULL,
@@ -195,8 +197,14 @@ TEST(GuiNicklist, AddGroup)
POINTERS_EQUAL(group1, gui_nicklist_search_group (buffer, NULL, "group1"));
POINTERS_EQUAL(group1, gui_nicklist_search_group (buffer, buffer->nicklist_root, "group1"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", group1->id);
POINTERS_EQUAL(group1, gui_nicklist_search_group (buffer, NULL, str_search_id));
POINTERS_EQUAL(group1, gui_nicklist_search_group (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(group2, gui_nicklist_search_group (buffer, NULL, "group2"));
POINTERS_EQUAL(group2, gui_nicklist_search_group (buffer, buffer->nicklist_root, "group2"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", group2->id);
POINTERS_EQUAL(group2, gui_nicklist_search_group (buffer, NULL, str_search_id));
POINTERS_EQUAL(group2, gui_nicklist_search_group (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, NULL, "subgroup1"));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, NULL, "1|subgroup1"));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, buffer->nicklist_root, "subgroup1"));
@@ -205,14 +213,29 @@ TEST(GuiNicklist, AddGroup)
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, "1|subgroup1"));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, group2, "subgroup1"));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, group2, "1|subgroup1"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", subgroup1->id);
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, NULL, str_search_id));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, str_search_id));
POINTERS_EQUAL(subgroup1, gui_nicklist_search_group (buffer, group2, str_search_id));
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, NULL, "subgroup2"));
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, buffer->nicklist_root, "subgroup2"));
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, "subgroup2"));
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, group2, "subgroup2"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", subgroup2->id);
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, NULL, str_search_id));
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, str_search_id));
POINTERS_EQUAL(subgroup2, gui_nicklist_search_group (buffer, group2, str_search_id));
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, NULL, "subgroup3"));
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, buffer->nicklist_root, "subgroup3"));
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, "subgroup3"));
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, group2, "subgroup3"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", subgroup3->id);
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, NULL, str_search_id));
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_group (buffer, group1, str_search_id));
POINTERS_EQUAL(subgroup3, gui_nicklist_search_group (buffer, group2, str_search_id));
/* test remove of NULL buffer/group */
gui_nicklist_remove_group (NULL, NULL);
@@ -247,6 +270,8 @@ TEST(GuiNicklist, AddGroup)
* gui_nicklist_insert_nick_sorted
* gui_nicklist_add_nick_with_id
* gui_nicklist_add_nick
* gui_nicklist_search_nick_id
* gui_nicklist_search_nick_name
* gui_nicklist_search_nick
* gui_nicklist_remove_nick
* gui_nicklist_remove_all
@@ -257,6 +282,7 @@ TEST(GuiNicklist, AddNick)
struct t_gui_buffer *buffer;
struct t_gui_nick_group *group1, *group2;
struct t_gui_nick *nick_root, *nick1, *nick2, *nick3;
char str_search_id[128];
buffer = gui_buffer_new (NULL, TEST_BUFFER_NAME,
NULL, NULL, NULL,
@@ -348,14 +374,29 @@ TEST(GuiNicklist, AddNick)
POINTERS_EQUAL(nick1, gui_nicklist_search_nick (buffer, buffer->nicklist_root, "nick1"));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, "nick1"));
POINTERS_EQUAL(nick1, gui_nicklist_search_nick (buffer, group2, "nick1"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", nick1->id);
POINTERS_EQUAL(nick1, gui_nicklist_search_nick (buffer, NULL, str_search_id));
POINTERS_EQUAL(nick1, gui_nicklist_search_nick (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, str_search_id));
POINTERS_EQUAL(nick1, gui_nicklist_search_nick (buffer, group2, str_search_id));
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, NULL, "nick2"));
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, buffer->nicklist_root, "nick2"));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, "nick2"));
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, group2, "nick2"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", nick2->id);
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, NULL, str_search_id));
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, str_search_id));
POINTERS_EQUAL(nick2, gui_nicklist_search_nick (buffer, group2, str_search_id));
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, NULL, "nick3"));
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, buffer->nicklist_root, "nick3"));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, "nick3"));
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, group2, "nick3"));
snprintf (str_search_id, sizeof (str_search_id), "==id:%lld", nick3->id);
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, NULL, str_search_id));
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, buffer->nicklist_root, str_search_id));
POINTERS_EQUAL(NULL, gui_nicklist_search_nick (buffer, group1, str_search_id));
POINTERS_EQUAL(nick3, gui_nicklist_search_nick (buffer, group2, str_search_id));
/* test remove of NULL buffer/group */
gui_nicklist_remove_nick (NULL, NULL);