summaryrefslogtreecommitdiff
path: root/src/common/history.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-12-06 18:20:59 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-12-06 18:20:59 +0000
commit0ef010d21121365ca901881de40d5daf6bf4f07a (patch)
tree55dcbfebd572e165ed3cf16838015c2ce0519101 /src/common/history.c
parent6c7a71976b61c6a703d09d1de9db1f4b2496e738 (diff)
downloadweechat-0ef010d21121365ca901881de40d5daf6bf4f07a.zip
added /upgrade command, added ETA for DCC files
Diffstat (limited to 'src/common/history.c')
-rw-r--r--src/common/history.c88
1 files changed, 48 insertions, 40 deletions
diff --git a/src/common/history.c b/src/common/history.c
index 4f1113eec..266ab0a06 100644
--- a/src/common/history.c
+++ b/src/common/history.c
@@ -66,55 +66,18 @@ history_hide_password (char *string)
}
/*
- * history_add: add a text/command to history
+ * history_buffer_add: add a text/command to buffer's history
*/
void
-history_add (void *buffer, char *string)
+history_buffer_add (void *buffer, char *string)
{
t_history *new_history, *ptr_history;
-
- if ( !history_global
- || ( history_global
- && ascii_strcasecmp (history_global->text, string) != 0))
- {
- /* add history to global history */
- new_history = (t_history *)malloc (sizeof (t_history));
- if (new_history)
- {
- new_history->text = strdup (string);
- if (cfg_log_hide_nickserv_pwd)
- history_hide_password (new_history->text);
-
- if (history_global)
- history_global->prev_history = new_history;
- else
- history_global_last = new_history;
- new_history->next_history = history_global;
- new_history->prev_history = NULL;
- history_global = new_history;
- num_history_global++;
-
- /* remove one command if necessary */
- if ((cfg_history_max_commands > 0)
- && (num_history_global > cfg_history_max_commands))
- {
- ptr_history = history_global_last->prev_history;
- history_global_last->prev_history->next_history = NULL;
- if (history_global_last->text)
- free (history_global_last->text);
- free (history_global_last);
- history_global_last = ptr_history;
- num_history_global--;
- }
- }
- }
if ( !((t_gui_buffer *)(buffer))->history
|| ( ((t_gui_buffer *)(buffer))->history
&& ascii_strcasecmp (((t_gui_buffer *)(buffer))->history->text, string) != 0))
{
- /* add history to local history */
new_history = (t_history *)malloc (sizeof (t_history));
if (new_history)
{
@@ -129,7 +92,7 @@ history_add (void *buffer, char *string)
new_history->next_history = ((t_gui_buffer *)(buffer))->history;
new_history->prev_history = NULL;
((t_gui_buffer *)buffer)->history = new_history;
- ((t_gui_buffer *)(buffer))->num_history++;
+ ((t_gui_buffer *)buffer)->num_history++;
/* remove one command if necessary */
if ((cfg_history_max_commands > 0)
@@ -148,6 +111,51 @@ history_add (void *buffer, char *string)
}
/*
+ * history_global_add: add a text/command to buffer's history
+ */
+
+void
+history_global_add (char *string)
+{
+ t_history *new_history, *ptr_history;
+
+ if (!history_global
+ || (history_global
+ && ascii_strcasecmp (history_global->text, string) != 0))
+ {
+ new_history = (t_history *)malloc (sizeof (t_history));
+ if (new_history)
+ {
+ new_history->text = strdup (string);
+ if (cfg_log_hide_nickserv_pwd)
+ history_hide_password (new_history->text);
+
+ if (history_global)
+ history_global->prev_history = new_history;
+ else
+ history_global_last = new_history;
+ new_history->next_history = history_global;
+ new_history->prev_history = NULL;
+ history_global = new_history;
+ num_history_global++;
+
+ /* remove one command if necessary */
+ if ((cfg_history_max_commands > 0)
+ && (num_history_global > cfg_history_max_commands))
+ {
+ ptr_history = history_global_last->prev_history;
+ history_global_last->prev_history->next_history = NULL;
+ if (history_global_last->text)
+ free (history_global_last->text);
+ free (history_global_last);
+ history_global_last = ptr_history;
+ num_history_global--;
+ }
+ }
+ }
+}
+
+/*
* history_global_free: free global history
*/