summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.asciidoc2
-rw-r--r--doc/en/weechat_plugin_api.en.txt16
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt16
-rw-r--r--doc/it/weechat_plugin_api.it.txt19
-rw-r--r--doc/ja/weechat_plugin_api.ja.txt18
-rw-r--r--src/gui/gui-buffer.c67
-rw-r--r--src/gui/gui-buffer.h2
7 files changed, 98 insertions, 42 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc
index b2c15fe6e..b3f699407 100644
--- a/ChangeLog.asciidoc
+++ b/ChangeLog.asciidoc
@@ -47,6 +47,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* core: add signals "key_combo_{default|search|cursor}"
* core: display a warning in case of inconsistency between the options
weechat.look.save_{config|layout}_on_exit
+* api: add support of case insensitive search and search by buffer full name
+ in function buffer_search (bug #34318)
* api: add option "signal" in function hook_set to send a signal to the child
process
* api: add support of escaped strings with format `${esc:xxx}` or `${\xxx}` in
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 44edaa35e..45e33ef03 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -9972,6 +9972,8 @@ weechat.prnt(weechat.current_buffer(), "Text on current buffer")
==== weechat_buffer_search
+_Updated in 0.4.4._
+
Search a buffer by plugin and/or name.
Prototype:
@@ -9984,20 +9986,24 @@ struct t_gui_buffer *weechat_buffer_search (const char *plugin,
Arguments:
-* 'plugin': name of plugin
+* 'plugin': name of plugin, following special value is allowed:
+** `==`: the name used is the buffer full name (for example:
+ `irc.freenode.#weechat` instead of `freenode.#weechat`)
+ _(WeeChat ≥ 0.4.4)_
* 'name': name of buffer, if it is NULL or empty string, the current buffer is
- returned (buffer displayed by current window)
+ returned (buffer displayed by current window); if the name starts with
+ `(?i)`, the search is case insensitive _(WeeChat ≥ 0.4.4)_
Return value:
* pointer to buffer found, NULL if not found
-C example:
+C examples:
[source,C]
----
-struct t_gui_buffer *my_buffer = weechat_buffer_search ("my_plugin",
- "my_buffer");
+struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
+struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 0.4.4 */
----
Script (Python):
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 624b23cf3..4cb6eb10b 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -10164,6 +10164,8 @@ weechat.prnt(weechat.current_buffer(), "Texte sur le tampon courant")
==== weechat_buffer_search
+_Mis à jour dans la 0.4.4._
+
Rechercher un tampon par l'extension et/ou le nom.
Prototype :
@@ -10176,20 +10178,24 @@ struct t_gui_buffer *weechat_buffer_search (const char *plugin,
Paramètres :
-* 'plugin' : nom de l'extension
+* 'plugin' : nom de l'extension, la valeur spéciale suivante est autorisée :
+** `==` : le nom utilisé est le nom complet du tampon (par exemple :
+ `irc.freenode.#weechat` au lieu de `freenode.#weechat`)
+ _(WeeChat ≥ 0.4.4)_
* 'name' : nom du tampon, si c'est NULL ou une chaîne vide, le tampon courant
- est retourné (tampon affiché par la fenêtre courante)
+ est retourné (tampon affiché par la fenêtre courante); si le nom commence par
+ `(?i)`, la recherche est insensible à la casse _(WeeChat ≥ 0.4.4)_
Valeur de retour :
* pointeur vers le tampon trouvé, NULL s'il n'a pas été trouvé
-Exemple en C :
+Exemples en C :
[source,C]
----
-struct t_gui_buffer *my_buffer = weechat_buffer_search ("mon_extension",
- "mon_tampon");
+struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
+struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 0.4.4 */
----
Script (Python) :
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index ff87f88ac..fb42c79b3 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -10219,6 +10219,9 @@ weechat.prnt(weechat.current_buffer(), "Testo sul buffer corrente")
==== weechat_buffer_search
+// TRANSLATION MISSING
+_Updated in 0.4.4._
+
Cerca un buffer tramite plugin e/o nome.
Prototipo:
@@ -10231,9 +10234,15 @@ struct t_gui_buffer *weechat_buffer_search (const char *plugin,
Argomenti:
-* 'plugin': nome del plugin
-* 'name': nome del buffer, se NULL o la stringa è vuota, viene
- restituito il buffer corrente (buffer visualizzato dalla finestra corrente)
+// TRANSLATION MISSING
+* 'plugin': name of plugin, following special value is allowed:
+** `==`: the name used is the buffer full name (for example:
+ `irc.freenode.#weechat` instead of `freenode.#weechat`)
+ _(WeeChat ≥ 0.4.4)_
+// TRANSLATION MISSING
+* 'name': name of buffer, if it is NULL or empty string, the current buffer is
+ returned (buffer displayed by current window); if the name starts with
+ `(?i)`, the search is case insensitive _(WeeChat ≥ 0.4.4)_
Valore restituito:
@@ -10243,8 +10252,8 @@ Esempio in C:
[source,C]
----
-struct t_gui_buffer *my_buffer = weechat_buffer_search ("my_plugin",
- "my_buffer");
+struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
+struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 0.4.4 */
----
Script (Python):
diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt
index bc95ca4f3..7dc2513b5 100644
--- a/doc/ja/weechat_plugin_api.ja.txt
+++ b/doc/ja/weechat_plugin_api.ja.txt
@@ -9990,6 +9990,8 @@ weechat.prnt(weechat.current_buffer(), "Text on current buffer")
==== weechat_buffer_search
+_バージョン 0.4.4 で更新。_
+
プラグインおよび名前でバッファを検索。
プロトタイプ:
@@ -10002,9 +10004,15 @@ struct t_gui_buffer *weechat_buffer_search (const char *plugin,
引数:
-* 'plugin': プラグインの名前
-* 'name': バッファの名前、NULL または空文字列の場合、現在のバッファ
- (現在のウィンドウに表示されているバッファ) を返す
+// TRANSLATION MISSING
+* 'plugin': name of plugin, following special value is allowed:
+** `==`: the name used is the buffer full name (for example:
+ `irc.freenode.#weechat` instead of `freenode.#weechat`)
+ _(WeeChat ≥ 0.4.4)_
+// TRANSLATION MISSING
+* 'name': name of buffer, if it is NULL or empty string, the current buffer is
+ returned (buffer displayed by current window); if the name starts with
+ `(?i)`, the search is case insensitive _(WeeChat ≥ 0.4.4)_
戻り値:
@@ -10014,8 +10022,8 @@ C 言語での使用例:
[source,C]
----
-struct t_gui_buffer *my_buffer = weechat_buffer_search ("my_plugin",
- "my_buffer");
+struct t_gui_buffer *buffer1 = weechat_buffer_search ("irc", "freenode.#weechat");
+struct t_gui_buffer *buffer2 = weechat_buffer_search ("==", "irc.freenode.#test"); /* WeeChat ≥ 0.4.4 */
----
スクリプト (Python) での使用例:
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 53b214346..65ab5cd3c 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -2036,33 +2036,32 @@ gui_buffer_search_main ()
}
/*
- * Searches for a buffer by plugin and name.
+ * Searches for a buffer by full name (example: "irc.freenode.#weechat").
*/
struct t_gui_buffer *
-gui_buffer_search_by_name (const char *plugin, const char *name)
+gui_buffer_search_by_full_name (const char *full_name)
{
struct t_gui_buffer *ptr_buffer;
- int plugin_match;
+ int case_sensitive;
- if (!name || !name[0])
- return gui_current_window->buffer;
+ case_sensitive = 1;
+ if (strncmp (full_name, "(?i)", 4) == 0)
+ {
+ case_sensitive = 0;
+ full_name += 4;
+ }
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->name)
+ if (ptr_buffer->full_name
+ && ((case_sensitive
+ && strcmp (ptr_buffer->full_name, full_name) == 0)
+ || (!case_sensitive
+ && string_strcasecmp (ptr_buffer->full_name, full_name) == 0)))
{
- plugin_match = 1;
- if (plugin && plugin[0])
- {
- if (strcmp (plugin, gui_buffer_get_plugin_name (ptr_buffer)) != 0)
- plugin_match = 0;
- }
- if (plugin_match && (strcmp (ptr_buffer->name, name) == 0))
- {
- return ptr_buffer;
- }
+ return ptr_buffer;
}
}
@@ -2071,21 +2070,47 @@ gui_buffer_search_by_name (const char *plugin, const char *name)
}
/*
- * Searches for a buffer by full name (example: "irc.freenode.#weechat").
+ * Searches for a buffer by plugin and name.
*/
struct t_gui_buffer *
-gui_buffer_search_by_full_name (const char *full_name)
+gui_buffer_search_by_name (const char *plugin, const char *name)
{
struct t_gui_buffer *ptr_buffer;
+ int plugin_match, case_sensitive;
+
+ if (!name || !name[0])
+ return gui_current_window->buffer;
+
+ if (plugin && (strcmp (plugin, "==") == 0))
+ return gui_buffer_search_by_full_name (name);
+
+ case_sensitive = 1;
+ if (strncmp (name, "(?i)", 4) == 0)
+ {
+ case_sensitive = 0;
+ name += 4;
+ }
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->full_name
- && (strcmp (ptr_buffer->full_name, full_name) == 0))
+ if (ptr_buffer->name)
{
- return ptr_buffer;
+ plugin_match = 1;
+ if (plugin && plugin[0])
+ {
+ if (strcmp (plugin, gui_buffer_get_plugin_name (ptr_buffer)) != 0)
+ plugin_match = 0;
+ }
+ if (plugin_match
+ && ((case_sensitive
+ && strcmp (ptr_buffer->name, name) == 0)
+ || (!case_sensitive
+ && string_strcasecmp (ptr_buffer->name, name) == 0)))
+ {
+ return ptr_buffer;
+ }
}
}
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 7f9056edb..e3552aa73 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -280,9 +280,9 @@ extern void gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer,
int value);
extern int gui_buffer_is_main (const char *plugin_name, const char *name);
extern struct t_gui_buffer *gui_buffer_search_main ();
+extern struct t_gui_buffer *gui_buffer_search_by_full_name (const char *full_name);
extern struct t_gui_buffer *gui_buffer_search_by_name (const char *plugin,
const char *name);
-extern struct t_gui_buffer *gui_buffer_search_by_full_name (const char *full_name);
extern struct t_gui_buffer *gui_buffer_search_by_partial_name (const char *plugin,
const char *name);
extern struct t_gui_buffer *gui_buffer_search_by_number (int number);