summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-04-08 15:27:47 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-04-08 15:27:47 +0200
commitd52f051ec1a06223cb50ea63d6828754294e5661 (patch)
treef2816cf3449f9e41fa2d66cf0dd24990799d0228 /src/gui
parent45c0cc7e7e3de9cdfc6293df9ea6edbe3968f1d4 (diff)
downloadweechat-d52f051ec1a06223cb50ea63d6828754294e5661.zip
Add modifier "history_add" (text added to buffer or global history)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-history.c38
-rw-r--r--src/gui/gui-history.h1
-rw-r--r--src/gui/gui-input.c13
3 files changed, 36 insertions, 16 deletions
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)))
@@ -141,6 +136,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;