summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2014-03-25 10:55:12 +0100
committerSebastien Helleu <flashcode@flashtux.org>2014-03-25 10:55:12 +0100
commit92ec36eced36b0832ce90c417ae1bddbf4a7d2e4 (patch)
treedc9a420531d5309a180b80e2f1e2ddbc53a6c0ca
parent8deb0d3612327ba4ca2d0d4f8ae6dc2797915fe8 (diff)
downloadweechat-92ec36eced36b0832ce90c417ae1bddbf4a7d2e4.zip
core: add buffer property "clear"
-rw-r--r--doc/en/weechat_plugin_api.en.txt16
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt17
-rw-r--r--doc/it/weechat_plugin_api.it.txt19
-rw-r--r--doc/ja/weechat_plugin_api.ja.txt21
-rw-r--r--src/core/wee-command.c4
-rw-r--r--src/gui/gui-buffer.c36
-rw-r--r--src/gui/gui-buffer.h2
7 files changed, 96 insertions, 19 deletions
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index b93ac9143..83f97bda6 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -10268,6 +10268,9 @@ Arguments:
0 if buffer is merged and not selected
** 'print_hooks_enabled': 1 if print hooks are enabled, otherwise 0
** 'day_change': 1 if messages for the day change are displayed, otherwise 0
+ _(WeeChat ≥ 0.4.3)_
+** 'clear': 1 if buffer can be cleared with command `/buffer clear`, otherwise 0
+ _(WeeChat ≥ 0.4.4)_
** 'lines_hidden': 1 if at least one line is hidden on buffer (filtered), or 0
if all lines are displayed
** 'prefix_max_length': max length for prefix in this buffer
@@ -10476,7 +10479,8 @@ Properties:
| type | "formatted" or "free" |
Set type for buffer: "formatted" (for printing chat messages), or "free" (for
- free content)
+ free content); when the value is "free", the property 'clear' is forced to "0"
+ _(WeeChat ≥ 0.4.4)_
| notify | "0", "1", "2", "3" |
Set notify level for buffer: "0" = never add to hotlist, "1" = add for
@@ -10486,10 +10490,18 @@ Properties:
| print_hooks_enabled | "0" or "1" |
"0" to disable print hooks, "1" to enable them (default for a new buffer)
-| day_change | "0" or "1" |
+| day_change +
+ _(WeeChat ≥ 0.4.3)_ | "0" or "1" |
"0" to hide messages for the day change, "1" to see them
(default for a new buffer)
+| clear +
+ _(WeeChat ≥ 0.4.4)_ | "0" or "1" |
+ "0" to prevent user from clearing buffer with the command `/buffer clear`,
+ "1" to let user clear the buffer (default for a new buffer)
+ (note: even when it is set to "0", the buffer can still be cleared with
+ the function <<_weechat_buffer_clear,weechat_buffer_clear>>)
+
| title | any string |
Set new title for buffer
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 5bae50bf5..3e74bd935 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -10464,6 +10464,9 @@ Paramètres :
actif, 0 si le tampon est mélangé et n'est pas sélectionné
** 'print_hooks_enabled' : 1 si les hooks "print" sont activés, sinon 0
** 'day_change' : 1 si les messages de changement de jour sont affichés, sinon 0
+ _(WeeChat ≥ 0.4.3)_
+** 'clear' : 1 si le tampon peut être effacé avec la commande `/buffer clear`,
+ sinon 0 _(WeeChat ≥ 0.4.4)_
** 'lines_hidden' : 1 si au moins une ligne est cachée dans le tampon
(filtrée), ou 0 si toutes les lignes sont affichées
** 'prefix_max_length' : longueur maximale du préfixe dans ce tampon
@@ -10679,7 +10682,8 @@ Propriétés :
| type | "formatted" ou "free" |
Définit le type de tampon : "formatted" (pour afficher les messages d'une
- discussion), ou "free" (pour du contenu libre)
+ discussion), ou "free" (pour du contenu libre); lorsque la valeur est "free",
+ la propriété 'clear' est forcée à "0" _(WeeChat ≥ 0.4.4)_
| notify | "0", "1", "2", "3" |
Définit le niveau de notification du tampon : "0" = ne jamais ajouter à la
@@ -10690,10 +10694,19 @@ Propriétés :
"0" pour désactiver les hooks "print", "1" pour les activer
(par défaut pour un nouveau tampon)
-| day_change | "0" ou "1" |
+| day_change +
+ _(WeeChat ≥ 0.4.3)_ | "0" ou "1" |
"0" pour cacher les messages de changement de jour, "1" pour les voir
(par défaut pour un nouveau tampon)
+| clear +
+ _(WeeChat ≥ 0.4.4)_ | "0" ou "1" |
+ "0" pour empêcher l'utilisateur d'effacer le tampon avec la commande
+ `/buffer clear`, "1" pour autoriser l'utilisateur à effacer le tampon (par
+ défaut pour un nouveau tampon) (note : même lorsque la valeur est "0", le
+ tampon peut toujours être effacé avec la fonction
+ <<_weechat_buffer_clear,weechat_buffer_clear>>)
+
| title | toute chaîne |
Change le titre du tampon
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index 2846eccf0..23d11910f 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -10530,6 +10530,10 @@ Argomenti:
altrimenti 0
// TRANSLATION MISSING
** 'day_change': 1 if messages for the day change are displayed, otherwise 0
+ _(WeeChat ≥ 0.4.3)_
+// TRANSLATION MISSING
+** 'clear': 1 if buffer can be cleared with command `/buffer clear`, otherwise 0
+ _(WeeChat ≥ 0.4.4)_
** 'lines_hidden': 1 se almeno una riga è nascosta sul buffer (filtrata),
oppure 0 se vengono visualizzate tutte le righe
** 'prefix_max_length': lunghezza massima del prefisso in questo buffer
@@ -10750,9 +10754,11 @@ Properties:
| short_name | qualsiasi stringa |
Imposta nuovo nome breve per il buffer
+// TRANSLATION MISSING
| type | "formatted" oppure "free" |
Imposta tipo per il: "formatted" (per stampare i messaggi di chat),
- oppure "free" (per contenuto libero)
+ oppure "free" (per contenuto libero); when the value is "free", the property
+ 'clear' is forced to "0" _(WeeChat ≥ 0.4.4)_
| notify | "0", "1", "2", "3" |
Imposta il livello di notifica per il buffer: "0" = non aggiungere alla hotlist,
@@ -10764,10 +10770,19 @@ Properties:
"0" to disable print hooks, "1" to enable them (default for a new buffer)
// TRANSLATION MISSING
-| day_change | "0" oppure "1" |
+| day_change +
+ _(WeeChat ≥ 0.4.3)_ | "0" oppure "1" |
"0" to hide messages for the day change, "1" to see them
(default for a new buffer)
+// TRANSLATION MISSING
+| clear +
+ _(WeeChat ≥ 0.4.4)_ | "0" or "1" |
+ "0" to prevent user from clearing buffer with the command `/buffer clear`,
+ "1" to let user clear the buffer (default for a new buffer)
+ (note: even when it is set to "0", the buffer can still be cleared with
+ the function <<_weechat_buffer_clear,weechat_buffer_clear>>)
+
| title | qualsiasi stringa |
Imposta nuovo titolo per il buffer
diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt
index 1db81fcfc..d825e1bdd 100644
--- a/doc/ja/weechat_plugin_api.ja.txt
+++ b/doc/ja/weechat_plugin_api.ja.txt
@@ -10259,7 +10259,12 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer,
** 'active': バッファがマージされて選択されている場合は 2、バッファが選択されている場合は
1、バッファがマージされ選択されていない場合は 0
** 'print_hooks_enabled': プリントフックが有効化されている場合は 1、そうでない場合は 0
+// TRANSLATION MISSING
** 'day_change': 日付変更メッセージを表示する場合は 1、そうでない場合は 0
+ _(WeeChat ≥ 0.4.3)_
+// TRANSLATION MISSING
+** 'clear': 1 if buffer can be cleared with command `/buffer clear`, otherwise 0
+ _(WeeChat ≥ 0.4.4)_
** 'lines_hidden': バッファに非表示 (フィルタされた) メッセージが 1
行以上含まれる場合は 1、すべてのメッセージが表示冴えている場合は 0
** 'prefix_max_length': バッファプレフィックスの最大長
@@ -10466,9 +10471,11 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
| short_name | 任意の文字列 |
指定したバッファの新しい短縮名を設定
+// TRANSLATION MISSING
| type | "formatted" または "free" |
バッファのタイプを設定: "formatted" (チャットメッセージ用)、または
- "free" (自由内容用)
+ "free" (自由内容用); when the value is "free", the property 'clear' is forced
+ to "0" _(WeeChat ≥ 0.4.4)_
| notify | "0", "1", "2", "3" |
バッファの通知レベルを設定: "0" = ホットリストに追加しない、"1" =
@@ -10478,10 +10485,20 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
| print_hooks_enabled | "0" or "1" |
プリントフックを無効化する場合は "0"、有効化する場合は "1" (新規バッファに対するデフォルト)
-| day_change | "0" または "1" |
+// TRANSLATION MISSING
+| day_change +
+ _(WeeChat ≥ 0.4.3)_ | "0" または "1" |
日付変更メッセージを隠す場合は "0"、表示する場合は
"1" (新規バッファに対するデフォルト)
+// TRANSLATION MISSING
+| clear +
+ _(WeeChat ≥ 0.4.4)_ | "0" or "1" |
+ "0" to prevent user from clearing buffer with the command `/buffer clear`,
+ "1" to let user clear the buffer (default for a new buffer)
+ (note: even when it is set to "0", the buffer can still be cleared with
+ the function <<_weechat_buffer_clear,weechat_buffer_clear>>)
+
| title | 任意の文字列 |
指定したバッファの新しいタイトルを設定
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 3877f676e..dbbf97a2f 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -598,7 +598,7 @@ COMMAND_CALLBACK(buffer)
ptr_buffer2 = ptr_buffer2->next_buffer)
{
if ((ptr_buffer2->number == ptr_buffer->number)
- && (ptr_buffer2->type == GUI_BUFFER_TYPE_FORMATTED))
+ && ptr_buffer2->clear)
{
gui_buffer_clear (ptr_buffer2);
}
@@ -609,7 +609,7 @@ COMMAND_CALLBACK(buffer)
}
else
{
- if (buffer->type == GUI_BUFFER_TYPE_FORMATTED)
+ if (buffer->clear)
gui_buffer_clear (buffer);
}
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 65ab5cd3c..b0570b71c 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -76,7 +76,7 @@ char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] =
char *gui_buffer_properties_get_integer[] =
{ "number", "layout_number", "layout_number_merge_order", "type", "notify",
- "num_displayed", "active", "print_hooks_enabled", "day_change",
+ "num_displayed", "active", "print_hooks_enabled", "day_change", "clear",
"lines_hidden", "prefix_max_length", "time_for_each_line", "nicklist",
"nicklist_case_sensitive", "nicklist_max_length", "nicklist_display_groups",
"nicklist_count", "nicklist_groups_count", "nicklist_nicks_count",
@@ -97,13 +97,14 @@ char *gui_buffer_properties_get_pointer[] =
NULL
};
char *gui_buffer_properties_set[] =
-{ "unread", "display", "print_hooks_enabled", "day_change", "number", "name",
- "short_name", "type", "notify", "title", "time_for_each_line", "nicklist",
- "nicklist_case_sensitive", "nicklist_display_groups", "highlight_words",
- "highlight_words_add", "highlight_words_del", "highlight_regex",
- "highlight_tags_restrict", "highlight_tags", "hotlist_max_level_nicks",
- "hotlist_max_level_nicks_add", "hotlist_max_level_nicks_del",
- "input", "input_pos", "input_get_unknown_commands",
+{ "unread", "display", "print_hooks_enabled", "day_change", "clear", "number",
+ "name", "short_name", "type", "notify", "title", "time_for_each_line",
+ "nicklist", "nicklist_case_sensitive", "nicklist_display_groups",
+ "highlight_words", "highlight_words_add", "highlight_words_del",
+ "highlight_regex", "highlight_tags_restrict", "highlight_tags",
+ "hotlist_max_level_nicks", "hotlist_max_level_nicks_add",
+ "hotlist_max_level_nicks_del", "input", "input_pos",
+ "input_get_unknown_commands",
NULL
};
@@ -592,6 +593,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->active = 1;
new_buffer->print_hooks_enabled = 1;
new_buffer->day_change = 1;
+ new_buffer->clear = 1;
/* close callback */
new_buffer->close_callback = close_callback;
@@ -980,6 +982,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
return buffer->print_hooks_enabled;
else if (string_strcasecmp (property, "day_change") == 0)
return buffer->day_change;
+ else if (string_strcasecmp (property, "clear") == 0)
+ return buffer->clear;
else if (string_strcasecmp (property, "lines_hidden") == 0)
return buffer->lines->lines_hidden;
else if (string_strcasecmp (property, "prefix_max_length") == 0)
@@ -1166,6 +1170,9 @@ gui_buffer_set_type (struct t_gui_buffer *buffer, enum t_gui_buffer_type type)
gui_line_free_all (buffer);
buffer->type = type;
+ if (type == GUI_BUFFER_TYPE_FREE)
+ buffer->clear = 0;
+
gui_buffer_ask_chat_refresh (buffer, 2);
(void) hook_signal_send ("buffer_type_changed",
@@ -1751,6 +1758,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
gui_buffer_ask_chat_refresh (buffer, 2);
}
}
+ else if (string_strcasecmp (property, "clear") == 0)
+ {
+ error = NULL;
+ number = strtol (value, &error, 10);
+ if (error && !error[0])
+ buffer->clear = (number) ? 1 : 0;
+ }
else if (string_strcasecmp (property, "number") == 0)
{
error = NULL;
@@ -2442,7 +2456,7 @@ gui_buffer_clear_all ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED)
+ if (ptr_buffer->clear)
gui_buffer_clear (ptr_buffer);
}
}
@@ -3809,6 +3823,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_buffer, active, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, print_hooks_enabled, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, day_change, INTEGER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_buffer, clear, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, title, STRING, 0, NULL, NULL);
@@ -3985,6 +4000,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "day_change", buffer->day_change))
return 0;
+ if (!infolist_new_var_integer (ptr_item, "clear", buffer->clear))
+ return 0;
if (!infolist_new_var_integer (ptr_item, "first_line_not_read", buffer->lines->first_line_not_read))
return 0;
if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines->lines_hidden))
@@ -4191,6 +4208,7 @@ gui_buffer_print_log ()
log_printf (" active. . . . . . . . . : %d", ptr_buffer->active);
log_printf (" print_hooks_enabled . . : %d", ptr_buffer->print_hooks_enabled);
log_printf (" day_change. . . . . . . : %d", ptr_buffer->day_change);
+ log_printf (" clear . . . . . . . . . : %d", ptr_buffer->clear);
log_printf (" close_callback. . . . . : 0x%lx", ptr_buffer->close_callback);
log_printf (" close_callback_data . . : 0x%lx", ptr_buffer->close_callback_data);
log_printf (" title . . . . . . . . . : '%s'", ptr_buffer->title);
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index c9d8e2674..25298bba7 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -98,6 +98,8 @@ struct t_gui_buffer
/* 2 = the only active (merged) */
int print_hooks_enabled; /* 1 if print hooks are enabled */
int day_change; /* 1 if "day change" displayed */
+ int clear; /* 1 if clear of buffer is allowed */
+ /* with command /buffer clear */
/* close callback */
int (*close_callback)(void *data, /* called when buffer is closed */