Add modifier "history_add" (text added to buffer or global history)

v2.8-utf8proc
Sebastien Helleu 2010-04-08 15:27:47 +02:00
parent 45c0cc7e7e
commit d52f051ec1
6 changed files with 52 additions and 16 deletions

View File

@ -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) |

View File

@ -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 |

View File

@ -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) |

View File

@ -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
*/

View File

@ -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,

View File

@ -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;