summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--doc/de/autogen/plugin_api/hdata.txt6
-rw-r--r--doc/docgen.py6
-rw-r--r--doc/en/autogen/plugin_api/hdata.txt6
-rw-r--r--doc/en/weechat_plugin_api.en.txt16
-rw-r--r--doc/fr/autogen/plugin_api/hdata.txt6
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt17
-rw-r--r--doc/it/autogen/plugin_api/hdata.txt6
-rw-r--r--doc/it/weechat_plugin_api.it.txt18
-rw-r--r--doc/ja/autogen/plugin_api/hdata.txt6
-rw-r--r--src/core/wee-config-file.c6
-rw-r--r--src/core/wee-hdata.c11
-rw-r--r--src/core/wee-hdata.h3
-rw-r--r--src/core/wee-upgrade.c2
-rw-r--r--src/gui/gui-bar-item.c2
-rw-r--r--src/gui/gui-bar-window.c2
-rw-r--r--src/gui/gui-bar.c2
-rw-r--r--src/gui/gui-buffer.c6
-rw-r--r--src/gui/gui-completion.c4
-rw-r--r--src/gui/gui-filter.c2
-rw-r--r--src/gui/gui-history.c128
-rw-r--r--src/gui/gui-history.h6
-rw-r--r--src/gui/gui-hotlist.c2
-rw-r--r--src/gui/gui-input.c10
-rw-r--r--src/gui/gui-key.c2
-rw-r--r--src/gui/gui-line.c6
-rw-r--r--src/gui/gui-nicklist.c4
-rw-r--r--src/gui/gui-window.c6
-rw-r--r--src/plugins/irc/irc-channel.c4
-rw-r--r--src/plugins/irc/irc-ignore.c2
-rw-r--r--src/plugins/irc/irc-nick.c2
-rw-r--r--src/plugins/irc/irc-notify.c2
-rw-r--r--src/plugins/irc/irc-redirect.c4
-rw-r--r--src/plugins/irc/irc-server.c2
-rw-r--r--src/plugins/plugin-api.c2
-rw-r--r--src/plugins/plugin-script.c2
-rw-r--r--src/plugins/plugin.c2
-rw-r--r--src/plugins/script/script-repo.c2
-rw-r--r--src/plugins/weechat-plugin.h12
39 files changed, 213 insertions, 118 deletions
diff --git a/ChangeLog b/ChangeLog
index 7369d139b..6f0bade30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.0-dev, 2012-12-07
+v0.4.0-dev, 2012-12-08
Version 0.4.0 (under dev!)
@@ -30,6 +30,8 @@ Version 0.4.0 (under dev!)
(problem with nick displayed in first line of screen) (bug #37556)
* core: fix wrapping of words with wide chars (the break was made before the
correct position)
+* api: allow creation of structure with hdata_update (allowed for hdata
+ "history")
* api: use hashtable "options" for command arguments in function
hook_process_hashtable (optional, default is a split of string with command)
* api: do not call shell to execute command in hook_process (fix security
diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt
index f6a441e0d..56aba5055 100644
--- a/doc/de/autogen/plugin_api/hdata.txt
+++ b/doc/de/autogen/plugin_api/hdata.txt
@@ -561,8 +561,10 @@
'text' (string) +
'next_history' (pointer, hdata: "history") +
'prev_history' (pointer, hdata: "history") |
- |
- -
+ `__create` +
+ `__delete` |
+ 'gui_history' +
+ 'last_gui_history'
| weechat | hotlist | Hotliste |
'priority' (integer) +
diff --git a/doc/docgen.py b/doc/docgen.py
index 569346a43..72e024a31 100644
--- a/doc/docgen.py
+++ b/doc/docgen.py
@@ -231,10 +231,14 @@ def get_hdata():
if variables_update:
variables_update += ' +\n'
variables_update += ' %s' % item['text']
+ if weechat.hdata_update(ptr_hdata, '', { '__create_allowed' : '' }):
+ if variables_update:
+ variables_update += ' +\n'
+ variables_update += ' `__create`'
if weechat.hdata_update(ptr_hdata, '', { '__delete_allowed' : '' }):
if variables_update:
variables_update += ' +\n'
- variables_update += ' \'__delete\''
+ variables_update += ' `__delete`'
hdata[plugin][hdata_name]['vars'] = '\n%s' % variables
hdata[plugin][hdata_name]['vars_update'] = '\n%s' % variables_update
diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt
index 464880912..9f161265b 100644
--- a/doc/en/autogen/plugin_api/hdata.txt
+++ b/doc/en/autogen/plugin_api/hdata.txt
@@ -561,8 +561,10 @@
'text' (string) +
'next_history' (pointer, hdata: "history") +
'prev_history' (pointer, hdata: "history") |
- |
- -
+ `__create` +
+ `__delete` |
+ 'gui_history' +
+ 'last_gui_history'
| weechat | hotlist | hotlist |
'priority' (integer) +
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 5c0bc297e..4b0a663e1 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -12912,7 +12912,7 @@ something in memory pointed by hdata variables.
weechat_hdata_new
^^^^^^^^^^^^^^^^^
-_New in version 0.3.6, updated in 0.3.9._
+_New in version 0.3.6, updated in 0.3.9 and 0.4.0._
Create a new hdata.
@@ -12932,7 +12932,7 @@ Prototype:
[source,C]
----------------------------------------
struct t_hdata *weechat_hdata_new (const char *hdata_name, const char *var_prev, const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
@@ -12947,6 +12947,8 @@ Arguments:
element in list (may be NULL if no such variable is available)
* 'var_next': name of variable in structure which is a pointer to next
element in list (may be NULL if no such variable is available)
+* 'create_allowed': 1 if create of structure is allowed, otherwise 0
+ (_new in version 0.4.0_)
* 'delete_allowed': 1 if delete of structure is allowed, otherwise 0
(_new in version 0.3.9_)
* 'callback_update': callback to update data in hdata, can be NULL if no update
@@ -12967,7 +12969,7 @@ C example:
[source,C]
----------------------------------------
-struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, &callback_update, NULL);
+struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, 0, &callback_update, NULL);
----------------------------------------
[NOTE]
@@ -14079,11 +14081,13 @@ Arguments:
* 'hashtable': variables to update: keys are name of variables, values are new
values for variables (keys and values are string), some special keys are
allowed:
-** key '__delete_allowed' (with any value): return 1 if delete is allowed for
+** key `__create_allowed` (with any value): return 1 if create is allowed for
+ structure, otherwise 0 (_new in version 0.4.0_)
+** key `__delete_allowed` (with any value): return 1 if delete is allowed for
structure, otherwise 0
-** key '__update_allowed', value is name of a variable: return 1 if update is
+** key `__update_allowed`, value is name of a variable: return 1 if update is
allowed for this variable, otherwise 0
-** key '__delete' (with any value): delete structure (if allowed)
+** key `__delete` (with any value): delete structure (if allowed)
Return value:
diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt
index 16ca00f49..e03882865 100644
--- a/doc/fr/autogen/plugin_api/hdata.txt
+++ b/doc/fr/autogen/plugin_api/hdata.txt
@@ -561,8 +561,10 @@
'text' (string) +
'next_history' (pointer, hdata: "history") +
'prev_history' (pointer, hdata: "history") |
- |
- -
+ `__create` +
+ `__delete` |
+ 'gui_history' +
+ 'last_gui_history'
| weechat | hotlist | hotlist |
'priority' (integer) +
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 7a86eb66d..e1a5df460 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -13130,7 +13130,7 @@ les variables du hdata.
weechat_hdata_new
^^^^^^^^^^^^^^^^^
-_Nouveau dans la version 0.3.6, mis à jour dans la 0.3.9._
+_Nouveau dans la version 0.3.6, mis à jour dans la 0.3.9 et 0.4.0._
Créé un "hdata".
@@ -13152,7 +13152,7 @@ Prototype :
[source,C]
----------------------------------------
struct t_hdata *weechat_hdata_new (const char *hdata_name, const char *var_prev, const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
@@ -13169,6 +13169,8 @@ Paramètres :
* 'var_next' : nom de la variable dans la structure qui est un pointeur vers
l'élément suivant dans la liste (peut être NULL si une telle variable
n'existe pas)
+* 'create_allowed' : 1 si la création de structure est autorisée, sinon 0
+ (_nouveau dans la version 0.4.0_)
* 'delete_allowed' : 1 si la suppression de structure est autorisée, sinon 0
(_nouveau dans la version 0.3.9_)
* 'callback_update' : fonction appelée pour mettre à jour des données dans le
@@ -13190,7 +13192,7 @@ Exemple en C :
[source,C]
----------------------------------------
-struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, &callback_update, NULL);
+struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, 0, &callback_update, NULL);
----------------------------------------
[NOTE]
@@ -14324,11 +14326,14 @@ Paramètres :
variables, les valeurs sont les nouvelles valeurs pour les variables (clés et
valeurs sont des chaînes de caractères), quelqes clés spéciales sont
acceptées :
-** clé '__delete_allowed' (avec n'importe quelle valeur) : retourne 1 si la
+** clé `__create_allowed` (avec n'importe quelle valeur) : retourne 1 si la
+ création est autorisée pour la strucrure, sinon 0
+ (_nouveau dans la version 0.4.0_)
+** clé `__delete_allowed` (avec n'importe quelle valeur) : retourne 1 si la
suppression est autorisée pour la structure, sinon 0
-** clé '__update_allowed', la valeur est le nom d'une variable : retourne 1 si
+** clé `__update_allowed`, la valeur est le nom d'une variable : retourne 1 si
la mise à jour est autorisée pour la variable, sinon 0
-** clé '__delete' (avec n'importe quelle valeur) : supprime la structure
+** clé `__delete` (avec n'importe quelle valeur) : supprime la structure
(si autorisé)
Valeur de retour :
diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt
index 6fac22ed9..2a130e3ba 100644
--- a/doc/it/autogen/plugin_api/hdata.txt
+++ b/doc/it/autogen/plugin_api/hdata.txt
@@ -561,8 +561,10 @@
'text' (string) +
'next_history' (pointer, hdata: "history") +
'prev_history' (pointer, hdata: "history") |
- |
- -
+ `__create` +
+ `__delete` |
+ 'gui_history' +
+ 'last_gui_history'
| weechat | hotlist | hotlist |
'priority' (integer) +
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index add2debc7..6415725ca 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -13069,7 +13069,7 @@ weechat_hdata_new
^^^^^^^^^^^^^^^^^
// TRANSLATION MISSING
-_Novità nella versione 0.3.6, updated in 0.3.9._
+_Novità nella versione 0.3.6, updated in 0.3.9 and 0.4.0._
Crea un nuovo hdata.
@@ -13090,7 +13090,7 @@ Prototipo:
[source,C]
----------------------------------------
struct t_hdata *weechat_hdata_new (const char *hdata_name, const char *var_prev, const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
@@ -13106,6 +13106,9 @@ Argomenti:
* 'var_next': nome della variabile nella struttura che è puntatore all'elemento
successivo nella lista (può essere NULL se non è disponibile tale variabile)
// TRANSLATION MISSING
+* 'create_allowed': 1 if create of structure is allowed, otherwise 0
+ (_novità nella versione 0.4.0_)
+// TRANSLATION MISSING
* 'delete_allowed': 1 if delete of structure is allowed, otherwise 0
(_novità nella versione 0.3.9_)
// TRANSLATION MISSING
@@ -13127,7 +13130,7 @@ Valore restituito:
Esempio in C:
source,C]
----------------------------------------
-struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, &callback_update, NULL);
+struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, 0, &callback_update, NULL);
----------------------------------------
[NOTE]
@@ -14264,11 +14267,14 @@ Argomenti:
* 'hashtable': variables to update: keys are name of variables, values are new
values for variables (keys and values are string), some special keys are
allowed:
-** key '__delete_allowed' (with any value): return 1 if delete is allowed for
+// TRANSLATION MISSING
+** key `__create_allowed` (with any value): return 1 if create is allowed for
+ structure, otherwise 0 (_new in version 0.4.0_)
+** key `__delete_allowed` (with any value): return 1 if delete is allowed for
structure, otherwise 0
-** key '__update_allowed', value is name of a variable: return 1 if update is
+** key `__update_allowed`, value is name of a variable: return 1 if update is
allowed for this variable, otherwise 0
-** key '__delete' (with any value): delete structure (if allowed)
+** key `__delete` (with any value): delete structure (if allowed)
Valore restituito:
diff --git a/doc/ja/autogen/plugin_api/hdata.txt b/doc/ja/autogen/plugin_api/hdata.txt
index 430ccadf1..1e36c8260 100644
--- a/doc/ja/autogen/plugin_api/hdata.txt
+++ b/doc/ja/autogen/plugin_api/hdata.txt
@@ -561,8 +561,10 @@
'text' (string) +
'next_history' (pointer, hdata: "history") +
'prev_history' (pointer, hdata: "history") |
- |
- -
+ `__create` +
+ `__delete` |
+ 'gui_history' +
+ 'last_gui_history'
| weechat | hotlist | ホットリスト |
'priority' (integer) +
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index db34d95ee..505e14a8c 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -2607,7 +2607,7 @@ config_file_hdata_config_file_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_config", "next_config",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_config_file, plugin, POINTER, 0, NULL, "plugin");
@@ -2639,7 +2639,7 @@ config_file_hdata_config_section_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_section", "next_section",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_config_section, config_file, POINTER, 0, NULL, "config_file");
@@ -2677,7 +2677,7 @@ config_file_hdata_config_option_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_option", "next_option",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_config_option, config_file, POINTER, 0, NULL, "config_file");
diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c
index 827573cc5..0ccad400d 100644
--- a/src/core/wee-hdata.c
+++ b/src/core/wee-hdata.c
@@ -75,7 +75,7 @@ hdata_free_var (struct t_hashtable *hashtable,
struct t_hdata *
hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
const char *var_prev, const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
@@ -107,6 +107,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
NULL,
NULL);
hashtable_set (weechat_hdata, hdata_name, new_hdata);
+ new_hdata->create_allowed = create_allowed;
new_hdata->delete_allowed = delete_allowed;
new_hdata->callback_update = callback_update;
new_hdata->callback_update_data = callback_update_data;
@@ -816,6 +817,10 @@ hdata_update (struct t_hdata *hdata, void *pointer,
if (!hdata || !hashtable || !hdata->callback_update)
return 0;
+ /* check if create of structure is allowed */
+ if (hashtable_has_key (hashtable, "__create_allowed"))
+ return (int)hdata->create_allowed;
+
/* check if delete of structure is allowed */
if (hashtable_has_key (hashtable, "__delete_allowed"))
return (int)hdata->delete_allowed;
@@ -832,9 +837,6 @@ hdata_update (struct t_hdata *hdata, void *pointer,
return (var->update_allowed) ? 1 : 0;
}
- if (!pointer)
- return 0;
-
/* update data */
hdata->update_pending = 1;
rc = (hdata->callback_update) (hdata->callback_update_data,
@@ -1003,6 +1005,7 @@ hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable,
log_printf (" hash_list. . . . . . . : 0x%lx (hashtable: '%s')",
ptr_hdata->hash_list,
hashtable_get_string (ptr_hdata->hash_list, "keys_values"));
+ log_printf (" create_allowed . . . . : %d", (int)ptr_hdata->create_allowed);
log_printf (" delete_allowed . . . . : %d", (int)ptr_hdata->delete_allowed);
log_printf (" callback_update. . . . : 0x%lx", ptr_hdata->callback_update);
log_printf (" callback_update_data . : 0x%lx", ptr_hdata->callback_update_data);
diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h
index 3139af4ef..f67637e8f 100644
--- a/src/core/wee-hdata.h
+++ b/src/core/wee-hdata.h
@@ -48,6 +48,7 @@ struct t_hdata
struct t_hashtable *hash_list; /* hashtable with pointers on lists */
/* (used to search objects) */
+ char create_allowed; /* create allowed? */
char delete_allowed; /* delete allowed? */
int (*callback_update) /* update callback */
(void *data,
@@ -67,7 +68,7 @@ extern char *hdata_type_string[];
extern struct t_hdata *hdata_new (struct t_weechat_plugin *plugin,
const char *hdata_name, const char *var_prev,
const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index fabf86045..ed8109334 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -356,7 +356,7 @@ upgrade_weechat_save ()
return 0;
rc = 1;
- rc &= upgrade_weechat_save_history (upgrade_file, last_history_global);
+ rc &= upgrade_weechat_save_history (upgrade_file, last_gui_history);
rc &= upgrade_weechat_save_buffers (upgrade_file);
rc &= upgrade_weechat_save_misc (upgrade_file);
rc &= upgrade_weechat_save_hotlist (upgrade_file);
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index f4efc03b0..25a584344 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -1900,7 +1900,7 @@ gui_bar_item_hdata_bar_item_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_item", "next_item",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_bar_item, plugin, POINTER, 0, NULL, "plugin");
diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c
index 66ac6f6e5..29406b49f 100644
--- a/src/gui/gui-bar-window.c
+++ b/src/gui/gui-bar-window.c
@@ -1405,7 +1405,7 @@ gui_bar_window_hdata_bar_window_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_bar_window", "next_bar_window",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_bar_window, bar, POINTER, 0, NULL, "bar");
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index 66c839416..32fb6f33a 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -2253,7 +2253,7 @@ gui_bar_hdata_bar_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_bar", "next_bar",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_bar, name, STRING, 0, NULL, NULL);
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 05cb8aa77..db9879506 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -3151,7 +3151,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_buffer", "next_buffer",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_buffer, plugin, POINTER, 0, NULL, "plugin");
@@ -3240,7 +3240,7 @@ gui_buffer_hdata_input_undo_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_undo", "next_undo",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_input_undo, data, STRING, 0, NULL, NULL);
@@ -3264,7 +3264,7 @@ gui_buffer_hdata_buffer_visited_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_buffer", "next_buffer",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_buffer_visited, buffer, POINTER, 0, NULL, "buffer");
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 74581da13..e83c00f3b 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -1215,7 +1215,7 @@ gui_completion_hdata_completion_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL,
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_completion, buffer, POINTER, 0, NULL, "buffer");
@@ -1255,7 +1255,7 @@ gui_completion_hdata_completion_partial_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_item", "next_item",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_completion_partial, word, STRING, 0, NULL, NULL);
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index 8df37a261..01a45c833 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -450,7 +450,7 @@ gui_filter_hdata_filter_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_filter", "next_filter",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_filter, enabled, INTEGER, 0, NULL, NULL);
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index c9071ccee..01d82284a 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -27,11 +27,13 @@
#endif
#include <stdlib.h>
+#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "../core/weechat.h"
#include "../core/wee-config.h"
+#include "../core/wee-hashtable.h"
#include "../core/wee-hdata.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
@@ -41,10 +43,10 @@
#include "gui-buffer.h"
-struct t_gui_history *history_global = NULL;
-struct t_gui_history *last_history_global = NULL;
-struct t_gui_history *history_global_ptr = NULL;
-int num_history_global = 0;
+struct t_gui_history *gui_history = NULL;
+struct t_gui_history *last_gui_history = NULL;
+struct t_gui_history *gui_history_ptr = NULL;
+int num_gui_history = 0;
/*
@@ -106,36 +108,36 @@ gui_history_global_add (const char *string)
if (!string)
return;
- if (!history_global
- || (history_global
- && (strcmp (history_global->text, string) != 0)))
+ if (!gui_history
+ || (gui_history
+ && (strcmp (gui_history->text, string) != 0)))
{
new_history = malloc (sizeof (*new_history));
if (new_history)
{
new_history->text = strdup (string);
- if (history_global)
- history_global->prev_history = new_history;
+ if (gui_history)
+ gui_history->prev_history = new_history;
else
- last_history_global = new_history;
- new_history->next_history = history_global;
+ last_gui_history = new_history;
+ new_history->next_history = gui_history;
new_history->prev_history = NULL;
- history_global = new_history;
- num_history_global++;
+ gui_history = new_history;
+ num_gui_history++;
/* remove one command if necessary */
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
- && (num_history_global > CONFIG_INTEGER(config_history_max_commands)))
+ && (num_gui_history > CONFIG_INTEGER(config_history_max_commands)))
{
- ptr_history = last_history_global->prev_history;
- if (history_global_ptr == last_history_global)
- history_global_ptr = ptr_history;
- (last_history_global->prev_history)->next_history = NULL;
- if (last_history_global->text)
- free (last_history_global->text);
- free (last_history_global);
- last_history_global = ptr_history;
- num_history_global--;
+ ptr_history = last_gui_history->prev_history;
+ if (gui_history_ptr == last_gui_history)
+ gui_history_ptr = ptr_history;
+ (last_gui_history->prev_history)->next_history = NULL;
+ if (last_gui_history->text)
+ free (last_gui_history->text);
+ free (last_gui_history);
+ last_gui_history = ptr_history;
+ num_gui_history--;
}
}
}
@@ -177,18 +179,18 @@ gui_history_global_free ()
{
struct t_gui_history *ptr_history;
- while (history_global)
+ while (gui_history)
{
- ptr_history = history_global->next_history;
- if (history_global->text)
- free (history_global->text);
- free (history_global);
- history_global = ptr_history;
+ ptr_history = gui_history->next_history;
+ if (gui_history->text)
+ free (gui_history->text);
+ free (gui_history);
+ gui_history = ptr_history;
}
- history_global = NULL;
- last_history_global = NULL;
- history_global_ptr = NULL;
- num_history_global = 0;
+ gui_history = NULL;
+ last_gui_history = NULL;
+ gui_history_ptr = NULL;
+ num_gui_history = 0;
}
@@ -216,6 +218,62 @@ gui_history_buffer_free (struct t_gui_buffer *buffer)
}
/*
+ * gui_history_hdata_history_update_cb: callback for updating history
+ */
+
+int
+gui_history_hdata_history_update_cb (void *data,
+ struct t_hdata *hdata,
+ void *pointer,
+ struct t_hashtable *hashtable)
+{
+ struct t_gui_history *ptr_history;
+ struct t_gui_buffer *ptr_buffer;
+ const char *text, *buffer;
+ long unsigned int value;
+ int rc;
+
+ /* make C compiler happy */
+ (void) data;
+
+ rc = 0;
+
+ text = hashtable_get (hashtable, "text");
+ if (!text)
+ return rc;
+
+ if (pointer)
+ {
+ /* update history */
+ ptr_history = (struct t_gui_history *)pointer;
+ if (ptr_history->text)
+ free (ptr_history->text);
+ ptr_history->text = strdup (text);
+ }
+ else
+ {
+ /* create new entry in history */
+ ptr_buffer = NULL;
+ if (hashtable_has_key (hashtable, "buffer"))
+ {
+ buffer = hashtable_get (hashtable, "buffer");
+ if (buffer)
+ {
+ rc = sscanf (buffer, "%lx", &value);
+ if ((rc != EOF) && (rc != 0))
+ ptr_buffer = (struct t_gui_buffer *)value;
+ }
+ }
+ if (ptr_buffer)
+ gui_history_add (ptr_buffer, text);
+ else
+ gui_history_global_add (text);
+ }
+
+ return rc;
+}
+
+/*
* gui_history_hdata_history_cb: return hdata for history
*/
@@ -228,12 +286,14 @@ gui_history_hdata_history_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_history", "next_history",
- 0, NULL, NULL);
+ 1, 1, &gui_history_hdata_history_update_cb, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_history, text, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_history, prev_history, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_gui_history, next_history, POINTER, 0, NULL, hdata_name);
+ HDATA_LIST(gui_history);
+ HDATA_LIST(last_gui_history);
}
return hdata;
}
diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h
index 79bce5230..7a4447cec 100644
--- a/src/gui/gui-history.h
+++ b/src/gui/gui-history.h
@@ -29,9 +29,9 @@ struct t_gui_history
struct t_gui_history *prev_history;/* link to previous text/command */
};
-extern struct t_gui_history *history_global;
-extern struct t_gui_history *last_history_global;
-extern struct t_gui_history *history_global_ptr;
+extern struct t_gui_history *gui_history;
+extern struct t_gui_history *last_gui_history;
+extern struct t_gui_history *gui_history_ptr;
extern void gui_history_buffer_add (struct t_gui_buffer *buffer,
const char *string);
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 7ebc9750e..1837897ea 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -475,7 +475,7 @@ gui_hotlist_hdata_hotlist_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_hotlist", "next_hotlist",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_hotlist, priority, INTEGER, 0, NULL, NULL);
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index a4dc2ef69..735d335bb 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -391,7 +391,7 @@ gui_input_return (struct t_gui_buffer *buffer)
gui_completion_stop (window->buffer->completion, 1);
gui_buffer_undo_free_all (window->buffer);
window->buffer->ptr_history = NULL;
- history_global_ptr = NULL;
+ gui_history_ptr = NULL;
gui_input_optimize_size (window->buffer);
gui_input_text_changed_modifier_and_signal (window->buffer, 0);
input_data (window->buffer, command);
@@ -1215,8 +1215,8 @@ gui_input_history_global_previous (struct t_gui_buffer *buffer)
if (window)
{
gui_input_history_previous (window,
- history_global,
- &history_global_ptr);
+ gui_history,
+ &gui_history_ptr);
}
}
@@ -1234,8 +1234,8 @@ gui_input_history_global_next (struct t_gui_buffer *buffer)
if (window)
{
gui_input_history_next (window,
- history_global,
- &history_global_ptr);
+ gui_history,
+ &gui_history_ptr);
}
}
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 16e87677a..4a415b5ea 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -1751,7 +1751,7 @@ gui_key_hdata_key_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_key", "next_key",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_key, key, STRING, 0, NULL, NULL);
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index c9a32a532..19fed22ac 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -1351,7 +1351,7 @@ gui_line_hdata_lines_cb (void *data, const char *hdata_name)
/* make C compiler happy */
(void) data;
- hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, NULL, NULL);
+ hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_lines, first_line, POINTER, 0, NULL, "line");
@@ -1379,7 +1379,7 @@ gui_line_hdata_line_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_line", "next_line",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_line, data, POINTER, 0, NULL, "line_data");
@@ -1486,7 +1486,7 @@ gui_line_hdata_line_data_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, NULL, NULL,
- 0, &gui_line_hdata_line_data_update_cb, NULL);
+ 0, 0, &gui_line_hdata_line_data_update_cb, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_line_data, buffer, POINTER, 0, NULL, "buffer");
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index d160aae02..ba6e32c0c 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -972,7 +972,7 @@ gui_nicklist_hdata_nick_group_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_group", "next_group",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_nick_group, name, STRING, 0, NULL, NULL);
@@ -1003,7 +1003,7 @@ gui_nicklist_hdata_nick_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_nick", "next_nick",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_nick, group, POINTER, 0, NULL, "nick_group");
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index d763ce6e2..31ee5cc9a 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -1610,7 +1610,7 @@ gui_window_hdata_window_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_window", "next_window",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_window, number, INTEGER, 0, NULL, NULL);
@@ -1657,7 +1657,7 @@ gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_scroll", "next_scroll",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_window_scroll, buffer, POINTER, 0, NULL, "buffer");
@@ -1686,7 +1686,7 @@ gui_window_hdata_window_tree_cb (void *data, const char *hdata_name)
/* make C compiler happy */
(void) data;
- hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, NULL, NULL);
+ hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_gui_window_tree, parent_node, POINTER, 0, NULL, hdata_name);
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index d47d7c048..3b58896ce 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -895,7 +895,7 @@ irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_channel, type, INTEGER, 0, NULL, NULL);
@@ -940,7 +940,7 @@ irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_channel_speaking, nick, STRING, 0, NULL, NULL);
diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c
index 7748f7d05..b13a3c23e 100644
--- a/src/plugins/irc/irc-ignore.c
+++ b/src/plugins/irc/irc-ignore.c
@@ -319,7 +319,7 @@ irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_ignore, number, INTEGER, 0, NULL, NULL);
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 0ceddf3ba..2ea99207d 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -1032,7 +1032,7 @@ irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_nick, name, STRING, 0, NULL, NULL);
diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c
index 12547461d..d51ead139 100644
--- a/src/plugins/irc/irc-notify.c
+++ b/src/plugins/irc/irc-notify.c
@@ -964,7 +964,7 @@ irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_notify, server, POINTER, 0, NULL, "irc_server");
diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c
index 4c0341cc6..c938a5b57 100644
--- a/src/plugins/irc/irc-redirect.c
+++ b/src/plugins/irc/irc-redirect.c
@@ -976,7 +976,7 @@ irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, name, STRING, 0, NULL, NULL);
@@ -1006,7 +1006,7 @@ irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_redirect, server, POINTER, 0, NULL, "irc_server");
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index b4dc4d7ee..4e625f276 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -4440,7 +4440,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_server", "next_server",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_irc_server, name, STRING, 0, NULL, NULL);
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 90b9bca0f..ede44e2e4 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -641,7 +641,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (ptr_infolist)
{
for (ptr_history = (pointer) ?
- ((struct t_gui_buffer *)pointer)->history : history_global;
+ ((struct t_gui_buffer *)pointer)->history : gui_history;
ptr_history; ptr_history = ptr_history->next_history)
{
if (!gui_history_add_to_infolist (ptr_infolist, ptr_history))
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c
index bc2babc49..fa5348869 100644
--- a/src/plugins/plugin-script.c
+++ b/src/plugins/plugin-script.c
@@ -1203,7 +1203,7 @@ plugin_script_hdata_script (struct t_weechat_plugin *weechat_plugin,
struct t_hdata *hdata;
hdata = weechat_hdata_new (hdata_name, "prev_script", "next_script",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_plugin_script, filename, STRING, 0, NULL, NULL);
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index dfec3a14c..0f0fa7faa 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -1220,7 +1220,7 @@ plugin_hdata_plugin_cb (void *data, const char *hdata_name)
(void) data;
hdata = hdata_new (NULL, hdata_name, "prev_plugin", "next_plugin",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
HDATA_VAR(struct t_weechat_plugin, filename, STRING, 0, NULL, NULL);
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 3039ab2b5..fd3ae7ee0 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -1470,7 +1470,7 @@ script_repo_hdata_script_cb (void *data, const char *hdata_name)
(void) data;
hdata = weechat_hdata_new (hdata_name, "prev_script", "next_script",
- 0, NULL, NULL);
+ 0, 0, NULL, NULL);
if (hdata)
{
WEECHAT_HDATA_VAR(struct t_script_repo, name, STRING, 0, NULL, NULL);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 8b55e560c..189d0dd8a 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -50,7 +50,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20121102-01"
+#define WEECHAT_PLUGIN_API_VERSION "20121208-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -843,7 +843,7 @@ struct t_weechat_plugin
struct t_hdata *(*hdata_new) (struct t_weechat_plugin *plugin,
const char *hdata_name, const char *var_prev,
const char *var_next,
- int delete_allowed,
+ int create_allowed, int delete_allowed,
int (*callback_update)(void *data,
struct t_hdata *hdata,
void *pointer,
@@ -1623,11 +1623,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* hdata */
#define weechat_hdata_new(__hdata_name, __var_prev, __var_next, \
- __delete_allowed, __callback_update, \
- __callback_update_data) \
+ __create_allowed, __delete_allowed, \
+ __callback_update, __callback_update_data) \
weechat_plugin->hdata_new(weechat_plugin, __hdata_name, __var_prev, \
- __var_next, __delete_allowed, \
- __callback_update, \
+ __var_next, __create_allowed, \
+ __delete_allowed, __callback_update, \
__callback_update_data)
#define weechat_hdata_new_var(__hdata, __name, __offset, __type, \
__update_allowed, __array_size, \