diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index f01b17221..41e360403 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -6128,6 +6128,11 @@ Arguments: empty string | "1" to display bar, "0" to hide it +| weechat | history_add | + - | + input buffer (from user) added to command history (buffer and global) | + string added to command history + | weechat | input_text_content | string with buffer pointer ("0x123..") | input buffer (from user) | diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index bfd8e61f2..47cfa379b 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -6210,6 +6210,12 @@ Paramètres : chaîne vide | "1" pour afficher la barre, "0" pour la cacher +| weechat | history_add | + - | + chaîne saisie par l'utilisateur ajoutée à l'historique des commandes (tampon + et global) | + chaîne ajoutée à l'historique des commandes + | weechat | input_text_content | chaîne avec un pointeur vers le tampon ("0x123..") | chaîne saisie par l'utilisateur | diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index ea1c88f5d..895524571 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -6193,6 +6193,11 @@ Argomenti: stringa vuota | "1" per visualizzare la barra, "0" per nasconderla +| weechat | history_add | + - | + input buffer (from user) added to command history (buffer and global) | + string added to command history + | weechat | input_text_content | stringa con puntatore al buffer ("0x123..") | input buffer (dall'utente) | diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index 7ef286e30..88dcf82ed 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -28,6 +28,7 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-hook.h" #include "../core/wee-infolist.h" #include "../core/wee-string.h" #include "gui-history.h" @@ -60,9 +61,6 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string) if (new_history) { new_history->text = strdup (string); - /*if (config_log_hide_nickserv_pwd) - irc_display_hide_password (new_history->text, 1);*/ - if (buffer->history) buffer->history->prev_history = new_history; else @@ -71,7 +69,7 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string) new_history->prev_history = NULL; buffer->history = new_history; buffer->num_history++; - + /* remove one command if necessary */ if ((CONFIG_INTEGER(config_history_max_commands) > 0) && (buffer->num_history > CONFIG_INTEGER(config_history_max_commands))) @@ -91,7 +89,7 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string) } /* - * history_global_add: add a text/command to buffer's history + * history_global_add: add a text/command to global history */ void @@ -110,9 +108,6 @@ gui_history_global_add (const char *string) if (new_history) { new_history->text = strdup (string); - /*if (config_log_hide_nickserv_pwd) - irc_display_hide_password (new_history->text, 1);*/ - if (history_global) history_global->prev_history = new_history; else @@ -121,7 +116,7 @@ gui_history_global_add (const char *string) new_history->prev_history = NULL; history_global = new_history; num_history_global++; - + /* remove one command if necessary */ if ((CONFIG_INTEGER(config_history_max_commands) > 0) && (num_history_global > CONFIG_INTEGER(config_history_max_commands))) @@ -140,6 +135,31 @@ gui_history_global_add (const char *string) } } +/* + * gui_history_add: add a text/command to buffer's history + global history + */ + +void +gui_history_add (struct t_gui_buffer *buffer, const char *string) +{ + char *string2; + + string2 = hook_modifier_exec (NULL, "history_add", NULL, string); + + /* + * if message was NOT dropped by modifier, then we add it to buffer and + * global history + */ + if (!string2 || string2[0]) + { + gui_history_buffer_add (buffer, (string2) ? string2 : string); + gui_history_global_add ((string2) ? string2 : string); + } + + if (string2) + free (string2); +} + /* * gui_history_global_free: free global history */ diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h index be2291713..3c54afa8a 100644 --- a/src/gui/gui-history.h +++ b/src/gui/gui-history.h @@ -36,6 +36,7 @@ extern struct t_gui_history *history_global_ptr; extern void gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string); extern void gui_history_global_add (const char *string); +extern void gui_history_add (struct t_gui_buffer *buffer, const char *string); extern void gui_history_global_free (); extern void gui_history_buffer_free (struct t_gui_buffer *buffer); extern int gui_history_add_to_infolist (struct t_infolist *infolist, diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 73f933bb4..c080c3e3c 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -294,9 +294,8 @@ gui_input_return (struct t_gui_window *window) command = strdup (window->buffer->input_buffer); if (command) { - gui_history_buffer_add (window->buffer, - window->buffer->input_buffer); - gui_history_global_add (window->buffer->input_buffer); + gui_history_add (window->buffer, + window->buffer->input_buffer); window->buffer->input_buffer[0] = '\0'; window->buffer->input_buffer_size = 0; window->buffer->input_buffer_length = 0; @@ -922,8 +921,8 @@ gui_input_history_previous (struct t_gui_window *window) if (window->buffer->input_buffer_size > 0) { window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0'; - gui_history_buffer_add (window->buffer, window->buffer->input_buffer); - gui_history_global_add (window->buffer->input_buffer); + gui_history_add (window->buffer, + window->buffer->input_buffer); } } else @@ -1002,8 +1001,8 @@ gui_input_history_next (struct t_gui_window *window) if (window->buffer->input_buffer_size > 0) { window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0'; - gui_history_buffer_add (window->buffer, window->buffer->input_buffer); - gui_history_global_add (window->buffer->input_buffer); + gui_history_add (window->buffer, + window->buffer->input_buffer); window->buffer->input_buffer[0] = '\0'; window->buffer->input_buffer_size = 0; window->buffer->input_buffer_length = 0;